Bug 1257480 - null check for GetOrCreateGlobalScope() in WorkerDebuggerGlobalScope, r=khuey
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 18 Mar 2016 14:04:57 +0100
changeset 289347 472e569106be3d4248f51028854c6366ee4140c8
parent 289346 5371f013cb35fa74d86fd76159c95992e73b459f
child 289348 d731a17eaece49a3496e7f6797d36bd67a15827e
push id30102
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 15:23:17 +0000
treeherdermozilla-central@720fb3d55e28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1257480
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1257480 - null check for GetOrCreateGlobalScope() in WorkerDebuggerGlobalScope, r=khuey
dom/webidl/WorkerDebuggerGlobalScope.webidl
dom/workers/WorkerScope.cpp
dom/workers/WorkerScope.h
--- a/dom/webidl/WorkerDebuggerGlobalScope.webidl
+++ b/dom/webidl/WorkerDebuggerGlobalScope.webidl
@@ -1,15 +1,16 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 [Global=(WorkerDebugger), Exposed=WorkerDebugger]
 interface WorkerDebuggerGlobalScope : EventTarget {
+  [Throws]
   readonly attribute object global;
 
   object createSandbox(DOMString name, object prototype);
 
   [Throws]
   void loadSubScript(DOMString url, optional object sandbox);
 
   void enterEventLoop();
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -691,19 +691,25 @@ WorkerDebuggerGlobalScope::WrapGlobalObj
 
   return WorkerDebuggerGlobalScopeBinding::Wrap(aCx, this, this, options,
                                                 GetWorkerPrincipal(), true,
                                                 aReflector);
 }
 
 void
 WorkerDebuggerGlobalScope::GetGlobal(JSContext* aCx,
-                                     JS::MutableHandle<JSObject*> aGlobal)
+                                     JS::MutableHandle<JSObject*> aGlobal,
+                                     ErrorResult& aRv)
 {
-  aGlobal.set(mWorkerPrivate->GetOrCreateGlobalScope(aCx)->GetWrapper());
+  WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
+  if (!scope) {
+    aRv.Throw(NS_ERROR_FAILURE);
+  }
+
+  aGlobal.set(scope->GetWrapper());
 }
 
 class WorkerDebuggerSandboxPrivate : public nsIGlobalObject,
                                      public nsWrapperCache
 {
 public:
   explicit WorkerDebuggerSandboxPrivate(JSObject *global)
   {
@@ -926,17 +932,20 @@ WorkerDebuggerGlobalScope::GetConsole(Er
 
   return mConsole;
 }
 
 void
 WorkerDebuggerGlobalScope::Dump(JSContext* aCx,
                                 const Optional<nsAString>& aString) const
 {
-  return mWorkerPrivate->GetOrCreateGlobalScope(aCx)->Dump(aString);
+  WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
+  if (scope) {
+    scope->Dump(aString);
+  }
 }
 
 nsIGlobalObject*
 GetGlobalObjectForGlobal(JSObject* global)
 {
   nsIGlobalObject* globalObject = nullptr;
   UNWRAP_WORKER_OBJECT(WorkerGlobalScope, global, globalObject);
 
--- a/dom/workers/WorkerScope.h
+++ b/dom/workers/WorkerScope.h
@@ -292,17 +292,18 @@ public:
 
   virtual JSObject*
   GetGlobalJSObject(void) override
   {
     return GetWrapper();
   }
 
   void
-  GetGlobal(JSContext* aCx, JS::MutableHandle<JSObject*> aGlobal);
+  GetGlobal(JSContext* aCx, JS::MutableHandle<JSObject*> aGlobal,
+            ErrorResult& aRv);
 
   void
   CreateSandbox(JSContext* aCx, const nsAString& aName,
                 JS::Handle<JSObject*> aPrototype,
                 JS::MutableHandle<JSObject*> aResult);
 
   void
   LoadSubScript(JSContext* aCx, const nsAString& aURL,