Backed out 2 changesets (bug 1288768) for wptlint failure
authorPhil Ringnalda <philringnalda@gmail.com>
Sat, 28 Jan 2017 08:10:26 -0800
changeset 331532 7675a6d4b824f29f4cb1fd68c1b7d712e2d6b8bc
parent 331531 3361d527f683724d3d0f40a448cbef83cd2c7a87
child 331533 e72459157cf91f9332c7e852246333c82032d5c0
child 331578 e7b795db8b5b20c472d8070030e9b08c99a01db6
push id86285
push userphilringnalda@gmail.com
push dateSat, 28 Jan 2017 16:10:34 +0000
treeherdermozilla-inbound@7675a6d4b824 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1288768
milestone54.0a1
backs out3361d527f683724d3d0f40a448cbef83cd2c7a87
d8b8219c20d6af7f37a7f69d5b83d9f1e644323a
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
Backed out 2 changesets (bug 1288768) for wptlint failure Backed out changeset 3361d527f683 (bug 1288768) Backed out changeset d8b8219c20d6 (bug 1288768)
dom/events/Event.cpp
dom/events/Event.h
dom/security/test/csp/file_child-src_worker-redirect.html
dom/security/test/general/test_block_script_wrong_mime.html
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/test/test_404.html
dom/workers/test/test_bug1036484.html
dom/workers/test/test_loadError.html
testing/web-platform/meta/content-security-policy/worker-src/dedicated-fallback.sub.html.ini
testing/web-platform/meta/content-security-policy/worker-src/shared-fallback.sub.html.ini
testing/web-platform/meta/fetch/nosniff/worker.html.ini
testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm
testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
testing/web-platform/tests/workers/constructors/Worker/same-origin.html
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -397,27 +397,18 @@ Event::Init(mozilla::dom::EventTarget* a
 // static
 already_AddRefed<Event>
 Event::Constructor(const GlobalObject& aGlobal,
                    const nsAString& aType,
                    const EventInit& aParam,
                    ErrorResult& aRv)
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  return Constructor(t, aType, aParam);
-}
-
-// static
-already_AddRefed<Event>
-Event::Constructor(EventTarget* aEventTarget,
-                   const nsAString& aType,
-                   const EventInit& aParam)
-{
-  RefPtr<Event> e = new Event(aEventTarget, nullptr, nullptr);
-  bool trusted = e->Init(aEventTarget);
+  RefPtr<Event> e = new Event(t, nullptr, nullptr);
+  bool trusted = e->Init(t);
   e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
   e->SetTrusted(trusted);
   e->SetComposed(aParam.mComposed);
   return e.forget();
 }
 
 uint16_t
 Event::EventPhase() const
@@ -1211,17 +1202,17 @@ Event::Deserialize(const IPC::Message* a
   InitEvent(type, bubbles, cancelable);
   SetTrusted(trusted);
   SetComposed(composed);
 
   return true;
 }
 
 NS_IMETHODIMP_(void)
-Event::SetOwner(EventTarget* aOwner)
+Event::SetOwner(mozilla::dom::EventTarget* aOwner)
 {
   mOwner = nullptr;
 
   if (!aOwner) {
     return;
   }
 
   nsCOMPtr<nsINode> n = do_QueryInterface(aOwner);
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -137,20 +137,16 @@ public:
   static CSSIntPoint GetScreenCoords(nsPresContext* aPresContext,
                                      WidgetEvent* aEvent,
                                      LayoutDeviceIntPoint aPoint);
   static CSSIntPoint GetOffsetCoords(nsPresContext* aPresContext,
                                      WidgetEvent* aEvent,
                                      LayoutDeviceIntPoint aPoint,
                                      CSSIntPoint aDefaultPoint);
 
-  static already_AddRefed<Event> Constructor(EventTarget* aEventTarget,
-                                             const nsAString& aType,
-                                             const EventInit& aParam);
-
   static already_AddRefed<Event> Constructor(const GlobalObject& aGlobal,
                                              const nsAString& aType,
                                              const EventInit& aParam,
                                              ErrorResult& aRv);
 
   // Implemented as xpidl method
   // void GetType(nsString& aRetval) {}
 
--- a/dom/security/test/csp/file_child-src_worker-redirect.html
+++ b/dom/security/test/csp/file_child-src_worker-redirect.html
@@ -18,18 +18,21 @@
     try {
       worker = new Worker('file_redirect_worker.sjs?path='
           + escape("/tests/dom/security/test/csp/file_child-src_worker.js")
           + "&redir=" + redir
           + "&page_id=" + page_id
           );
 
       worker.onerror = function(error) {
-        // this means CSP blocked it
-        var msg = !("message" in error) ? "blocked" : e.message;
+        var msg = error.message;
+        if (msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/)) {
+          // this means CSP blocked it
+          msg = "blocked";
+        }
         window.parent.postMessage({id:page_id, message:msg}, 'http://mochi.test:8888');
         error.preventDefault();
       };
 
       worker.onmessage = function(ev) {
         window.parent.postMessage({id:page_id, message:"allowed"}, 'http://mochi.test:8888');
 
       };
--- a/dom/security/test/general/test_block_script_wrong_mime.html
+++ b/dom/security/test/general/test_block_script_wrong_mime.html
@@ -48,16 +48,19 @@ function testWorker([mime, shouldLoad]) 
     let worker = new Worker("file_block_script_wrong_mime_server.sjs?type=worker&mime="+mime);
     worker.onmessage = (event) => {
       ok(shouldLoad, `worker with mime '${mime}' should load`)
       is(event.data, "worker-loaded", "worker should send correct message");
       resolve();
     };
     worker.onerror = (error) => {
       ok(!shouldLoad, `worker with wrong mime '${mime}' should be blocked`);
+      let msg = error.message;
+      ok(msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/),
+         "should gets correct error message");
       error.preventDefault();
       resolve();
     }
     worker.postMessage("dummy");
   });
 }
 
 // new Worker() with importScripts()
@@ -66,16 +69,19 @@ function testWorkerImportScripts([mime, 
     let worker = new Worker("file_block_script_wrong_mime_server.sjs?type=worker-import&mime="+mime);
     worker.onmessage = (event) => {
       ok(shouldLoad, `worker/importScripts with mime '${mime}' should load`)
       is(event.data, "worker-loaded", "worker should send correct message");
       resolve();
     };
     worker.onerror = (error) => {
       ok(!shouldLoad, `worker/importScripts with wrong mime '${mime}' should be blocked`);
+      let msg = error.message;
+      ok(msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/),
+         "should gets correct error message");
       error.preventDefault();
       resolve();
     }
     worker.postMessage("dummy");
   });
 }
 
 SimpleTest.waitForExplicitFinish();
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -489,92 +489,16 @@ private:
       WorkerControlRunnable::PostRun(aCx, aWorkerPrivate, aRunResult);
       return;
     }
     // Don't do anything here as it's possible that aWorkerPrivate has been
     // deleted.
   }
 };
 
-class ReportCompileErrorRunnable final : public WorkerRunnable
-{
-public:
-  static void
-  CreateAndDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-  {
-    MOZ_ASSERT(aWorkerPrivate);
-    aWorkerPrivate->AssertIsOnWorkerThread();
-
-    RefPtr<ReportCompileErrorRunnable> runnable =
-      new ReportCompileErrorRunnable(aCx, aWorkerPrivate);
-    runnable->Dispatch();
-  }
-
-private:
-  ReportCompileErrorRunnable(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-    : WorkerRunnable(aWorkerPrivate, ParentThreadUnchangedBusyCount)
-  {
-    aWorkerPrivate->AssertIsOnWorkerThread();
-  }
-
-  void
-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
-  {
-    aWorkerPrivate->AssertIsOnWorkerThread();
-
-    // Dispatch may fail if the worker was canceled, no need to report that as
-    // an error, so don't call base class PostDispatch.
-  }
-
-  bool
-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
-  {
-    if (aWorkerPrivate->IsFrozen() ||
-        aWorkerPrivate->IsParentWindowPaused()) {
-      MOZ_ASSERT(!IsDebuggerRunnable());
-      aWorkerPrivate->QueueRunnable(this);
-      return true;
-    }
-
-    if (aWorkerPrivate->IsSharedWorker()) {
-      aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, EmptyString(),
-                                                    EmptyString(),
-                                                    EmptyString(), 0, 0,
-                                                    JSREPORT_ERROR,
-                                                    /* isErrorEvent */ false);
-      return true;
-    }
-
-    if (aWorkerPrivate->IsServiceWorker()) {
-      RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
-      if (swm) {
-        swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
-                         aWorkerPrivate->WorkerName(),
-                         aWorkerPrivate->ScriptURL(),
-                         EmptyString(), EmptyString(), EmptyString(),
-                         0, 0, JSREPORT_ERROR, JSEXN_ERR);
-      }
-      return true;
-    }
-
-    if (!aWorkerPrivate->IsAcceptingEvents()) {
-      return true;
-    }
-
-    RefPtr<Event> event =
-      Event::Constructor(aWorkerPrivate, NS_LITERAL_STRING("error"),
-                         EventInit());
-    event->SetTrusted(true);
-
-    nsEventStatus status = nsEventStatus_eIgnore;
-    aWorkerPrivate->DispatchDOMEvent(nullptr, event, nullptr, &status);
-    return true;
-  }
-};
-
 class CompileScriptRunnable final : public WorkerRunnable
 {
   nsString mScriptURL;
 
 public:
   explicit CompileScriptRunnable(WorkerPrivate* aWorkerPrivate,
                                  const nsAString& aScriptURL)
   : WorkerRunnable(aWorkerPrivate),
@@ -608,25 +532,19 @@ private:
       // We never got as far as calling GetOrCreateGlobalScope, or it failed.
       // We have no way to enter a compartment, hence no sane way to report this
       // error.  :(
       rv.SuppressException();
       return false;
     }
 
     // Make sure to propagate exceptions from rv onto aCx, so that they will get
-    // reported after we return.  We want to propagate just JS exceptions,
-    // because all the other errors are handled when the script is loaded.
-    // See: https://dom.spec.whatwg.org/#concept-event-fire
-    if (rv.Failed() && !rv.IsJSException()) {
-      ReportCompileErrorRunnable::CreateAndDispatch(aCx, aWorkerPrivate);
-      rv.SuppressException();
-      return false;
-    }
-
+    // reported after we return.  We do this for all failures on rv, because now
+    // we're using rv to track all the state we care about.
+    //
     // This is a little dumb, but aCx is in the null compartment here because we
     // set it up that way in our Run(), since we had not created the global at
     // that point yet.  So we need to enter the compartment of our global,
     // because setting a pending exception on aCx involves wrapping into its
     // current compartment.  Luckily we have a global now.
     JSAutoCompartment ac(aCx, globalScope->GetGlobalJSObject());
     if (rv.MaybeSetPendingException(aCx)) {
       return false;
@@ -1194,18 +1112,17 @@ private:
         MOZ_ASSERT(!IsDebuggerRunnable());
         aWorkerPrivate->QueueRunnable(this);
         return true;
       }
 
       if (aWorkerPrivate->IsSharedWorker()) {
         aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, mMessage, mFilename,
                                                       mLine, mLineNumber,
-                                                      mColumnNumber, mFlags,
-                                                      /* isErrorEvent */ true);
+                                                      mColumnNumber, mFlags);
         return true;
       }
 
       // Service workers do not have a main thread parent global, so normal
       // worker error reporting will crash.  Instead, pass the error to
       // the ServiceWorkerManager to report on any controlled documents.
       if (aWorkerPrivate->IsServiceWorker()) {
         RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
@@ -3369,18 +3286,17 @@ template <class Derived>
 void
 WorkerPrivateParent<Derived>::BroadcastErrorToSharedWorkers(
                                                     JSContext* aCx,
                                                     const nsAString& aMessage,
                                                     const nsAString& aFilename,
                                                     const nsAString& aLine,
                                                     uint32_t aLineNumber,
                                                     uint32_t aColumnNumber,
-                                                    uint32_t aFlags,
-                                                    bool aIsErrorEvent)
+                                                    uint32_t aFlags)
 {
   AssertIsOnMainThread();
 
   if (JSREPORT_IS_WARNING(aFlags)) {
     // Don't fire any events anywhere.  Just log to console.
     // XXXbz should we log to all the consoles of all the relevant windows?
     LogErrorToConsole(aMessage, aFilename, aLine, aLineNumber, aColumnNumber,
                       aFlags, 0);
@@ -3401,52 +3317,41 @@ WorkerPrivateParent<Derived>::BroadcastE
   // multiple objects in a single window as well as objects in different
   // windows.
   for (size_t index = 0; index < sharedWorkers.Length(); index++) {
     RefPtr<SharedWorker>& sharedWorker = sharedWorkers[index];
 
     // May be null.
     nsPIDOMWindowInner* window = sharedWorker->GetOwner();
 
-    RefPtr<Event> event;
-
-    if (aIsErrorEvent) {
-      RootedDictionary<ErrorEventInit> errorInit(aCx);
-      errorInit.mBubbles = false;
-      errorInit.mCancelable = true;
-      errorInit.mMessage = aMessage;
-      errorInit.mFilename = aFilename;
-      errorInit.mLineno = aLineNumber;
-      errorInit.mColno = aColumnNumber;
-
-      event = ErrorEvent::Constructor(sharedWorker, NS_LITERAL_STRING("error"),
-                                      errorInit);
-    } else {
-      event = Event::Constructor(sharedWorker, NS_LITERAL_STRING("error"),
-                                 EventInit());
-    }
-
-    if (!event) {
+    RootedDictionary<ErrorEventInit> errorInit(aCx);
+    errorInit.mBubbles = false;
+    errorInit.mCancelable = true;
+    errorInit.mMessage = aMessage;
+    errorInit.mFilename = aFilename;
+    errorInit.mLineno = aLineNumber;
+    errorInit.mColno = aColumnNumber;
+
+    RefPtr<ErrorEvent> errorEvent =
+      ErrorEvent::Constructor(sharedWorker, NS_LITERAL_STRING("error"),
+                              errorInit);
+    if (!errorEvent) {
       ThrowAndReport(window, NS_ERROR_UNEXPECTED);
       continue;
     }
 
-    event->SetTrusted(true);
+    errorEvent->SetTrusted(true);
 
     bool defaultActionEnabled;
-    nsresult rv = sharedWorker->DispatchEvent(event, &defaultActionEnabled);
+    nsresult rv = sharedWorker->DispatchEvent(errorEvent, &defaultActionEnabled);
     if (NS_FAILED(rv)) {
       ThrowAndReport(window, rv);
       continue;
     }
 
-    if (!aIsErrorEvent) {
-      continue;
-    }
-
     if (defaultActionEnabled) {
       // Add the owning window to our list so that we will fire an error event
       // at it later.
       if (!windowActions.Contains(window)) {
         windowActions.AppendElement(WindowAction(window));
       }
     } else {
       size_t actionsIndex = windowActions.LastIndexOf(WindowAction(window));
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -398,18 +398,17 @@ public:
 
   void
   BroadcastErrorToSharedWorkers(JSContext* aCx,
                                 const nsAString& aMessage,
                                 const nsAString& aFilename,
                                 const nsAString& aLine,
                                 uint32_t aLineNumber,
                                 uint32_t aColumnNumber,
-                                uint32_t aFlags,
-                                bool aIsErrorEvent);
+                                uint32_t aFlags);
 
   void
   WorkerScriptLoaded();
 
   void
   QueueRunnable(nsIRunnable* aRunnable)
   {
     AssertIsOnParentThread();
--- a/dom/workers/test/test_404.html
+++ b/dom/workers/test/test_404.html
@@ -20,20 +20,22 @@ Tests of DOM Worker Threads
 
   worker.onmessage = function(event) {
     ok(false, "Shouldn't ever get a message!");
     SimpleTest.finish();
   }
 
   worker.onerror = function(event) {
     is(event.target, worker);
+    is(event.message, 'NetworkError: Failed to load worker script at "nonexistent_worker.js"');
     event.preventDefault();
     SimpleTest.finish();
   };
 
   worker.postMessage("dummy");
 
   SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
+
--- a/dom/workers/test/test_bug1036484.html
+++ b/dom/workers/test/test_bug1036484.html
@@ -20,16 +20,17 @@ function test(script) {
   var worker = new Worker(script);
 
   worker.onmessage = function(event) {
     ok(false, "Shouldn't ever get a message!");
   }
 
   worker.onerror = function(event) {
     is(event.target, worker);
+    ok(event.message.startsWith("NetworkError: Failed to load worker script"))
     event.preventDefault();
     runTests();
   };
 
   worker.postMessage("dummy");
 }
 
 var tests = [ '404_server.sjs', '404_server.sjs?js' ];
--- a/dom/workers/test/test_loadError.html
+++ b/dom/workers/test/test_loadError.html
@@ -8,55 +8,59 @@
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 "use strict";
 
+var loadErrorMessage = 'SecurityError: Failed to load worker script at "about:blank"';
+
 function nextTest() {
   (function(){
     function workerfunc() {
       var subworker = new Worker("about:blank");
       subworker.onerror = function(e) {
         e.preventDefault();
-        postMessage("ERROR");
+        postMessage(e.message);
       }
     }
     var b = new Blob([workerfunc+'workerfunc();']);
     var u = URL.createObjectURL(b);
     function callworker(i) {
       try {
         var w = new Worker(u);
         URL.revokeObjectURL(u);
         is(i, 0, 'worker creation succeeded');
       } catch (e) {
         is(i, 1, 'worker creation failed');
         SimpleTest.finish();
         return;
       }
       w.onmessage = function(e) {
-        is(e.data, "ERROR",
+        is(e.data, loadErrorMessage,
            "Should catch the error when loading inner script");
         if (++i < 2) callworker(i);
         else SimpleTest.finish();
       };
       w.onerrror = function(e) {
         ok(false, "Should not get any errors from this worker");
       }
     }
     callworker(0);
   })();
 }
 
 try {
   var worker = new Worker("about:blank");
   worker.onerror = function(e) {
     e.preventDefault();
+    is(e.message, loadErrorMessage,
+       "Should get the right error from the toplevel script");
     nextTest();
   }
 
   worker.onmessage = function(event) {
     ok(false, "Shouldn't get a message!");
     SimpleTest.finish();
   }
 } catch (e) {
--- a/testing/web-platform/meta/content-security-policy/worker-src/dedicated-fallback.sub.html.ini
+++ b/testing/web-platform/meta/content-security-policy/worker-src/dedicated-fallback.sub.html.ini
@@ -1,8 +1,9 @@
 [dedicated-fallback.sub.html]
   type: testharness
+  expected: ERROR
   [Same-origin dedicated worker allowed by host-source expression.]
     expected: FAIL
 
   [blob: dedicated worker allowed by 'blob:'.]
     expected: FAIL
 
--- a/testing/web-platform/meta/content-security-policy/worker-src/shared-fallback.sub.html.ini
+++ b/testing/web-platform/meta/content-security-policy/worker-src/shared-fallback.sub.html.ini
@@ -1,8 +1,9 @@
 [shared-fallback.sub.html]
   type: testharness
+  expected: ERROR
   [Same-origin dedicated worker allowed by 'self'.]
     expected: FAIL
 
   [blob: dedicated worker allowed by 'blob:'.]
     expected: FAIL
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/fetch/nosniff/worker.html.ini
@@ -0,0 +1,3 @@
+[worker.html]
+  type: testharness
+  expected: ERROR
--- a/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm
+++ b/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm
@@ -3,15 +3,15 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id=log></div>
 <script>
 async_test(function(t) {
   try {
     var w = new Worker("ftp://example.org/support/WorkerBasic.js");
     w.onerror = t.step_func_done(function(e) {
-      assert_true(e instanceof Event);
+      assert_true(e instanceof ErrorEvent);
     });
   } catch (e) {
     t.step_func_done(function(e) { assert_true(true); });
   }
 });
 </script>
--- a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
@@ -11,17 +11,17 @@
 // Needed to prevent a race condition if a worker throws an exception that may or may
 // not propogate to the window before the tests finish
 setup({allow_uncaught_exception: true});
 
 function testSharedWorkerHelper(t, script) {
   try {
     var worker = new SharedWorker(script, '');
     worker.onerror = t.step_func_done(function(e) {
-      assert_true(e instanceof Event);
+      assert_true(e instanceof ErrorEvent);
     });
   } catch (e) {
     t.step_func_done(function(e) { assert_true(true); });
   }
 }
 
 test(function() {
   assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
--- a/testing/web-platform/tests/workers/constructors/Worker/same-origin.html
+++ b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html
@@ -9,17 +9,17 @@
 // Needed to prevent a race condition if a worker throws an exception that may or may
 // not propogate to the window before the tests finish
 setup({allow_uncaught_exception: true});
 
 function testSharedWorkerHelper(t, script) {
   try {
     var worker = new SharedWorker(script, '');
     worker.onerror = t.step_func_done(function(e) {
-      assert_true(e instanceof Event);
+      assert_true(e instanceof ErrorEvent);
     });
   } catch (e) {
     t.step_func_done(function(e) { assert_true(true); });
   }
 }
 
 test(function() {
   assert_throws("SecurityError", function() { new Worker('unsupported:'); });