Bug 1252592. JS warnings should not trigger error events on shared workers. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 01 Mar 2016 16:53:26 -0500
changeset 322824 c2fe2cdc11b19d5f29bdf4c7245e29f9fb060c21
parent 322823 0d93fe6d72c6722c2e825594b6f2f3e52736ccda
child 322825 5b8e45b227f3d3278cdbbc97aaae6cb4515dd7f9
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1252592
milestone47.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 1252592. JS warnings should not trigger error events on shared workers. r=khuey
dom/workers/WorkerPrivate.cpp
dom/workers/test/sharedWorker_sharedWorker.js
dom/workers/test/test_sharedWorker.html
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -3143,16 +3143,24 @@ WorkerPrivateParent<Derived>::BroadcastE
                                                     const nsAString& aFilename,
                                                     const nsAString& aLine,
                                                     uint32_t aLineNumber,
                                                     uint32_t aColumnNumber,
                                                     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);
+    return;
+  }
+
   AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
   GetAllSharedWorkers(sharedWorkers);
 
   if (sharedWorkers.IsEmpty()) {
     return;
   }
 
   AutoTArray<WindowAction, 10> windowActions;
--- a/dom/workers/test/sharedWorker_sharedWorker.js
+++ b/dom/workers/test/sharedWorker_sharedWorker.js
@@ -67,16 +67,21 @@ onconnect = function(event) {
   }
   if (!(event.ports[0] == event.source)) {
     throw new Error("'connect' event source property is incorrect!");
   }
   if (event.data) {
     throw new Error("'connect' event has data: " + event.data);
   }
 
+  // "".contains("") should trigger a warning in debug builds, but NOT fire
+  // error events at us.  If we ever actually remove contains() we'll need
+  // something else to test this case.
+  "".contains("");
+
   event.ports[0].onmessage = function(event) {
     if (!(event instanceof MessageEvent)) {
       throw new Error("'message' event is not a MessageEvent!");
     }
     if (!("ports" in event)) {
       throw new Error("'message' event doesn't have a 'ports' property!");
     }
     if (event.ports === null) {
--- a/dom/workers/test/test_sharedWorker.html
+++ b/dom/workers/test/test_sharedWorker.html
@@ -17,17 +17,17 @@
       <script class="testbody">
         "use strict";
 
         const href = window.location.href;
         const filename = "sharedWorker_sharedWorker.js";
         const sentMessage = "ping";
         const errorFilename = href.substring(0, href.lastIndexOf("/") + 1) +
                               filename;
-        const errorLine = 86;
+        const errorLine = 91;
         const errorColumn = 0;
 
         var worker = new SharedWorker(filename);
 
         ok(worker instanceof SharedWorker, "Got SharedWorker instance");
         ok(!("postMessage" in worker), "SharedWorker has no 'postMessage'");
         ok(worker.port instanceof MessagePort,
           "Shared worker has MessagePort");