Bug 1180754 - Get serviceworkerobject-scripturl test passing. r=bkelly
☠☠ backed out by e55283c9b6a0 ☠ ☠
authorNikhil Marathe <nsm.nikhil@gmail.com>
Mon, 31 Aug 2015 17:52:52 -0700
changeset 294339 1dbf68298734ad14579849f3534fa07c6e897059
parent 294338 e4fb01e4e3cd2eed2668c0efc85c35f8a8d42224
child 294340 6b470e90aef5b8b6c250673a10184bf0ee3dcf68
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1180754
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 1180754 - Get serviceworkerobject-scripturl test passing. r=bkelly This commit does several things: 1. Change to https so the test does not fail due to security exceptions. 2. Change function service_worker_unregister to get around the "getRegistration() matches most specific registration" issue by matching exact scope. 3. Uses the URL object for the "absolute" test instead of relying on server substitution since it achieves the same thing. 4. Allows fragments in the scriptURL since I cannot find anything in the spec preventing this. I have filed https://github.com/slightlyoff/ServiceWorker/issues/742 to resolve this. Update web-platform-tests expected data
testing/web-platform/mozilla/meta/MANIFEST.json
testing/web-platform/mozilla/meta/service-workers/service-worker/serviceworkerobject-scripturl.sub.html.ini
testing/web-platform/mozilla/tests/service-workers/service-worker/resources/test-helpers.sub.js
testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html
testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.sub.html
--- a/testing/web-platform/mozilla/meta/MANIFEST.json
+++ b/testing/web-platform/mozilla/meta/MANIFEST.json
@@ -431,20 +431,20 @@
           }
         ],
         "service-workers/service-worker/service-worker-csp-script.https.html": [
           {
             "path": "service-workers/service-worker/service-worker-csp-script.https.html",
             "url": "/_mozilla/service-workers/service-worker/service-worker-csp-script.https.html"
           }
         ],
-        "service-workers/service-worker/serviceworkerobject-scripturl.sub.html": [
+        "service-workers/service-worker/serviceworkerobject-scripturl.https.html": [
           {
-            "path": "service-workers/service-worker/serviceworkerobject-scripturl.sub.html",
-            "url": "/_mozilla/service-workers/service-worker/serviceworkerobject-scripturl.sub.html"
+            "path": "service-workers/service-worker/serviceworkerobject-scripturl.https.html",
+            "url": "/_mozilla/service-workers/service-worker/serviceworkerobject-scripturl.https.html"
           }
         ],
         "service-workers/service-worker/shared-worker-controlled.https.html": [
           {
             "path": "service-workers/service-worker/shared-worker-controlled.https.html",
             "url": "/_mozilla/service-workers/service-worker/shared-worker-controlled.https.html"
           }
         ],
@@ -547,9 +547,9 @@
       }
     },
     "reftest_nodes": {}
   },
   "reftest_nodes": {},
   "rev": null,
   "url_base": "/_mozilla/",
   "version": 2
-}
\ No newline at end of file
+}
deleted file mode 100644
--- a/testing/web-platform/mozilla/meta/service-workers/service-worker/serviceworkerobject-scripturl.sub.html.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[serviceworkerobject-scripturl.sub.html]
-  type: testharness
-  [Verify the scriptURL property: relative]
-    expected: FAIL
-
-  [Verify the scriptURL property: with-fragment]
-    expected: FAIL
-
-  [Verify the scriptURL property: absolute]
-    expected: FAIL
-
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/test-helpers.sub.js
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/test-helpers.sub.js
@@ -8,20 +8,23 @@ function service_worker_unregister_and_r
   return service_worker_unregister(test, scope)
     .then(function() {
         return navigator.serviceWorker.register(url, options);
       })
     .catch(unreached_rejection(test,
                                'unregister and register should not fail'));
 }
 
-function service_worker_unregister(test, documentUrl) {
-  return navigator.serviceWorker.getRegistration(documentUrl)
+// This unregisters the registration that precisely matches scope. Use this
+// when unregistering by scope. If no registration is found, it just resolves.
+function service_worker_unregister(test, scope) {
+  var absoluteScope = (new URL(scope, window.location).href);
+  return navigator.serviceWorker.getRegistration(scope)
     .then(function(registration) {
-        if (registration)
+        if (registration && registration.scope === absoluteScope)
           return registration.unregister();
       })
     .catch(unreached_rejection(test, 'unregister should not fail'));
 }
 
 function service_worker_unregister_and_done(test, scope) {
   return service_worker_unregister(test, scope)
     .then(test.done.bind(test));
rename from testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.sub.html
rename to testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.sub.html
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html
@@ -3,26 +3,25 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/test-helpers.sub.js"></script>
 <script>
 
 function url_test(name, url) {
   var scope = 'resources/scope/' + name;
   async_test(function(t) {
-    var expectedURL = normalizeURL(url);
+    var expectedURL = (new URL(url, window.location)).toString();
     service_worker_unregister_and_register(t, url, scope)
       .then(function(registration) {
           var worker = registration.installing;
           assert_equals(worker.scriptURL, expectedURL,
                         'Returned ServiceWorker object should have scriptURL');
           service_worker_unregister_and_done(t, scope);
         })
       .catch(unreached_rejection(t));
   }, 'Verify the scriptURL property: ' + name);
 }
 
 url_test('relative', 'resources/empty-worker.js');
 url_test('with-fragment', 'resources/empty-worker.js#ref');
-url_test('absolute',
-         'http://{{domains[www]}}:{{ports[http][0]}}/service-worker/resources/empty-worker.js');
+url_test('absolute', (new URL('./resources/empty-worker.js', window.location)).href);
 
 </script>