Bug 1483505: Test ServiceWorkerContainer.register() with a data: URL r=asuth
authorYaron Tausky <ytausky@mozilla.com>
Wed, 22 Aug 2018 15:12:40 +0000
changeset 490602 0e8f94baa6075cb38b8782ab05c5306eb3490f5e
parent 490601 6fc9afb46004610e53c0dca8e151c7cb346d4f46
child 490603 3f29d9aef185203912597b32bd1270d78d9e499d
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1483505
milestone63.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 1483505: Test ServiceWorkerContainer.register() with a data: URL r=asuth The proper response to a registration attempt with a data: URL is a TypeError, yet we currently reject with a Security error. See spec.: https://w3c.github.io/ServiceWorker/#start-register Currently this test is expected to fail. Differential Revision: https://phabricator.services.mozilla.com/D3406
testing/web-platform/meta/service-workers/service-worker/registration-script-url.https.html.ini
testing/web-platform/tests/service-workers/service-worker/resources/registration-tests-script-url.js
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/service-workers/service-worker/registration-script-url.https.html.ini
@@ -0,0 +1,4 @@
+[registration-script-url.https.html]
+  [Script URL is a data URL]
+    expected: FAIL
+
--- a/testing/web-platform/tests/service-workers/service-worker/resources/registration-tests-script-url.js
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/registration-tests-script-url.js
@@ -32,16 +32,25 @@ function registration_tests_script_url(r
       var scope = 'resources/scope/encoded-slash-in-script-url';
       return promise_rejects(t,
           check_error_types ? new TypeError : null,
           register_method(script, {scope: scope}),
           'URL-encoded backslash in the script URL should be rejected.');
     }, 'Script URL including uppercase URL-encoded backslash');
 
   promise_test(function(t) {
+      var script = 'data:application/javascript,';
+      var scope = 'resources/scope/data-url-in-script-url';
+      return promise_rejects(t,
+          check_error_types ? new TypeError : null,
+          register_method(script, {scope: scope}),
+          'Data URLs should not be registered as service workers.');
+    }, 'Script URL is a data URL');
+
+  promise_test(function(t) {
       var script = 'resources/././empty-worker.js';
       var scope = 'resources/scope/parent-reference-in-script-url';
       return register_method(script, {scope: scope})
         .then(function(registration) {
             assert_equals(
               get_newest_worker(registration).scriptURL,
               normalizeURL('resources/empty-worker.js'),
               'Script URL including self-reference should be normalized.');