Bug 1260414 - WorkerDebuggerGlobalScope.setConsoleEventHandler should be able to receive a null param, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 29 Mar 2016 15:56:10 +0100
changeset 290936 11c3335d77fb751128c456daa204385d69678484
parent 290935 8b7a2b89ff39d5943ebc6b439f769a74dd38f3d3
child 290937 6835c3b9989a4c74ff3ef31ce4f7fb7cf730841a
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1260414
milestone48.0a1
Bug 1260414 - WorkerDebuggerGlobalScope.setConsoleEventHandler should be able to receive a null param, r=bz
dom/base/Console.cpp
dom/base/Console.h
dom/webidl/WorkerDebuggerGlobalScope.webidl
dom/workers/WorkerScope.cpp
dom/workers/WorkerScope.h
dom/workers/test/WorkerDebugger.console_debugger.js
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -2317,24 +2317,24 @@ Console::RetrieveConsoleEvents(JSContext
       return;
     }
 
     aEvents.AppendElement(value);
   }
 }
 
 void
-Console::SetConsoleEventHandler(AnyCallback& aHandler)
+Console::SetConsoleEventHandler(AnyCallback* aHandler)
 {
   AssertIsOnOwningThread();
 
   // We don't want to expose this functionality to main-thread yet.
   MOZ_ASSERT(!NS_IsMainThread());
 
-  mConsoleEventNotifier = &aHandler;
+  mConsoleEventNotifier = aHandler;
 }
 
 void
 Console::AssertIsOnOwningThread() const
 {
   MOZ_ASSERT(mOwningThread);
   MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
 }
--- a/dom/base/Console.h
+++ b/dom/base/Console.h
@@ -121,17 +121,17 @@ public:
   void
   ClearStorage();
 
   void
   RetrieveConsoleEvents(JSContext* aCx, nsTArray<JS::Value>& aEvents,
                         ErrorResult& aRv);
 
   void
-  SetConsoleEventHandler(AnyCallback& aHandler);
+  SetConsoleEventHandler(AnyCallback* aHandler);
 
 private:
   explicit Console(nsPIDOMWindowInner* aWindow);
 
   void
   Initialize(ErrorResult& aRv);
 
   void
--- a/dom/webidl/WorkerDebuggerGlobalScope.webidl
+++ b/dom/webidl/WorkerDebuggerGlobalScope.webidl
@@ -26,17 +26,17 @@ interface WorkerDebuggerGlobalScope : Ev
   void setImmediate(Function handler);
 
   void reportError(DOMString message);
 
   [Throws]
   sequence<any> retrieveConsoleEvents();
 
   [Throws]
-  void setConsoleEventHandler(AnyCallback handler);
+  void setConsoleEventHandler(AnyCallback? handler);
 };
 
 // So you can debug while you debug
 partial interface WorkerDebuggerGlobalScope {
   void dump(optional DOMString string);
 
   [Throws, Replaceable]
   readonly attribute Console console;
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -938,17 +938,17 @@ WorkerDebuggerGlobalScope::RetrieveConso
     return;
   }
 
   console->RetrieveConsoleEvents(aCx, aEvents, aRv);
 }
 
 void
 WorkerDebuggerGlobalScope::SetConsoleEventHandler(JSContext* aCx,
-                                                  AnyCallback& aHandler,
+                                                  AnyCallback* aHandler,
                                                   ErrorResult& aRv)
 {
   WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
   if (!scope) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
--- a/dom/workers/WorkerScope.h
+++ b/dom/workers/WorkerScope.h
@@ -335,17 +335,17 @@ public:
   void
   ReportError(JSContext* aCx, const nsAString& aMessage);
 
   void
   RetrieveConsoleEvents(JSContext* aCx, nsTArray<JS::Value>& aEvents,
                         ErrorResult& aRv);
 
   void
-  SetConsoleEventHandler(JSContext* aCx, AnyCallback& aHandler,
+  SetConsoleEventHandler(JSContext* aCx, AnyCallback* aHandler,
                          ErrorResult& aRv);
 
   Console*
   GetConsole(ErrorResult& aRv);
 
   Console*
   GetConsoleIfExists() const
   {
--- a/dom/workers/test/WorkerDebugger.console_debugger.js
+++ b/dom/workers/test/WorkerDebugger.console_debugger.js
@@ -19,16 +19,20 @@ function magic() {
   ok(Array.isArray(foo), "We received an array.");
   ok(foo.length >= 2, "At least 2 messages.");
 
   is(foo[0].arguments[0], "Can you see this console message?", "First message ok.");
   is(foo[1].arguments[0], "Can you see this second console message?", "Second message ok.");
 
   setConsoleEventHandler(function(consoleData) {
     is(consoleData.arguments[0], "Random message.", "Random message ok!");
+
+    // The consoleEventHandler can be null.
+    setConsoleEventHandler(null);
+
     finish();
   });
 }
 
 this.onmessage = function (event) {
   switch (event.data) {
   case "do magic":
     magic();