Bug 1187470 - ServiceWorker scripts should not be treated parser warnings as errors. r=bkelly, a=sledru
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 13 Aug 2015 10:52:15 +0100
changeset 288792 10446b876d609310004a69517ae902129e05f6cb
parent 288791 b6a87b67374896098431f140af6b5645cc6647c1
child 288793 71d74dcbafd703dbd816314f2338be6c6c08c50f
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly, sledru
bugs1187470
milestone42.0a2
Bug 1187470 - ServiceWorker scripts should not be treated parser warnings as errors. r=bkelly, a=sledru
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
@@ -2953,16 +2953,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
@@ -1737,17 +1737,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],