Bug 1187470 - ServiceWorker scripts should not be treated parser warnings as errors, r=bkelly
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 13 Aug 2015 10:52:15 +0100
changeset 257548 8c3d49b034c1678d17b7c64c4ed872fa8d63e851
parent 257547 a4ad67fc1d3b7f4ff56e3310cc6b20232a682457
child 257549 3655d19ce241dfc7356beb4ee31f2382c0f5dd0f
push id63658
push useramarchesini@mozilla.com
push dateThu, 13 Aug 2015 09:54:13 +0000
treeherdermozilla-inbound@8c3d49b034c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1187470
milestone43.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 1187470 - ServiceWorker scripts should not be treated parser warnings as errors, r=bkelly
dom/workers/ServiceWorkerManager.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/test/serviceworkers/mochitest.ini
dom/workers/test/serviceworkers/strict_mode_error.js
dom/workers/test/serviceworkers/strict_mode_warning.js
dom/workers/test/serviceworkers/test_strict_mode_error.html
dom/workers/test/serviceworkers/test_strict_mode_warning.html
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -2949,16 +2949,17 @@ ServiceWorkerManager::HandleError(JSCont
                                   nsString aFilename,
                                   nsString aLine,
                                   uint32_t aLineNumber,
                                   uint32_t aColumnNumber,
                                   uint32_t aFlags)
 {
   AssertIsOnMainThread();
   MOZ_ASSERT(aPrincipal);
+  MOZ_ASSERT(!JSREPORT_IS_WARNING(aFlags));
 
   nsAutoCString scopeKey;
   nsresult rv = PrincipalToScopeKey(aPrincipal, scopeKey);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
 
   ServiceWorkerManager::RegistrationDataPerPrincipal* data;
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -1530,17 +1530,17 @@ private:
       AssertIsOnMainThread();
 
       if (aWorkerPrivate->IsFrozen()) {
         aWorkerPrivate->QueueRunnable(this);
         return true;
       }
 
       if (aWorkerPrivate->IsServiceWorker() || aWorkerPrivate->IsSharedWorker()) {
-        if (aWorkerPrivate->IsServiceWorker()) {
+        if (aWorkerPrivate->IsServiceWorker() && !JSREPORT_IS_WARNING(mFlags)) {
           nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
           MOZ_ASSERT(swm);
           bool handled = swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
                                           aWorkerPrivate->SharedWorkerName(),
                                           aWorkerPrivate->ScriptURL(),
                                           mMessage,
                                           mFilename, mLine, mLineNumber,
                                           mColumnNumber, mFlags);
--- a/dom/workers/test/serviceworkers/mochitest.ini
+++ b/dom/workers/test/serviceworkers/mochitest.ini
@@ -132,17 +132,17 @@ support-files =
   app-protocol/*
   force_refresh_worker.js
   sw_clients/refresher.html
   sw_clients/refresher_compressed.html
   sw_clients/refresher_compressed.html^headers^
   sw_clients/refresher_cached.html
   sw_clients/refresher_cached_compressed.html
   sw_clients/refresher_cached_compressed.html^headers^
-  strict_mode_error.js
+  strict_mode_warning.js
   skip_waiting_installed_worker.js
   skip_waiting_scope/index.html
   interception_featuredetect.js
   thirdparty/iframe1.html
   thirdparty/iframe2.html
   thirdparty/register.html
   thirdparty/unregister.html
   thirdparty/sw.js
@@ -231,16 +231,16 @@ skip-if = toolkit == "android" || toolki
 [test_notification_constructor_error.html]
 [test_notification_get.html]
 [test_sanitize.html]
 [test_sanitize_domain.html]
 [test_service_worker_allowed.html]
 [test_serviceworker_interfaces.html]
 [test_serviceworker_not_sharedworker.html]
 [test_skip_waiting.html]
-[test_strict_mode_error.html]
+[test_strict_mode_warning.html]
 [test_third_party_iframes.html]
 [test_unregister.html]
 [test_workerUnregister.html]
 [test_workerUpdate.html]
 [test_workerupdatefoundevent.html]
 [test_opaque_intercept.html]
 [test_fetch_event_client_postmessage.html]
rename from dom/workers/test/serviceworkers/strict_mode_error.js
rename to dom/workers/test/serviceworkers/strict_mode_warning.js
rename from dom/workers/test/serviceworkers/test_strict_mode_error.html
rename to dom/workers/test/serviceworkers/test_strict_mode_warning.html
--- a/dom/workers/test/serviceworkers/test_strict_mode_error.html
+++ b/dom/workers/test/serviceworkers/test_strict_mode_warning.html
@@ -1,31 +1,31 @@
 <!--
   Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/
 -->
 <!DOCTYPE HTML>
 <html>
 <head>
-  <title>Bug 1170550 - test registration of service worker scripts with a strict mode error</title>
+  <title>Bug 1170550 - test registration of service worker scripts with a strict mode warning</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test"></pre>
 <script class="testbody" type="text/javascript">
 
   function runTest() {
     navigator.serviceWorker
-      .register("strict_mode_error.js", {scope: "strict_mode_error"})
-      .catch(() => {
-        ok(true, "Registration failed as expected");
+      .register("strict_mode_warning.js", {scope: "strict_mode_warning"})
+      .then(() => {
+        ok(true, "Registration should not fail for warnings");
         SimpleTest.finish();
       });
   }
 
   SimpleTest.waitForExplicitFinish();
   onload = function() {
     SpecialPowers.pushPrefEnv({"set": [
       ["dom.serviceWorkers.exemptFromPerDomainMax", true],