[WPT] Add module version of service-worker/registration-script.https.html

Bug: 1129795
Change-Id: Ibff0827b206b9a0290fcdbcaccb3c57cae2a00da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2413725
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810076}
diff --git a/service-workers/service-worker/registration-script-module.https.html b/service-workers/service-worker/registration-script-module.https.html
new file mode 100644
index 0000000..9e39a1f
--- /dev/null
+++ b/service-workers/service-worker/registration-script-module.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title>Service Worker: Registration (module script)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
+<script src="resources/registration-tests-script.js"></script>
+<script>
+registration_tests_script(
+    (script, options) => navigator.serviceWorker.register(
+        script,
+        Object.assign({type: 'module'}, options)),
+    'module');
+</script>
diff --git a/service-workers/service-worker/registration-script.https.html b/service-workers/service-worker/registration-script.https.html
index f70b9e6..f1e51fd 100644
--- a/service-workers/service-worker/registration-script.https.html
+++ b/service-workers/service-worker/registration-script.https.html
@@ -5,5 +5,8 @@
 <script src="resources/test-helpers.sub.js"></script>
 <script src="resources/registration-tests-script.js"></script>
 <script>
-registration_tests_script((script, options) => navigator.serviceWorker.register(script, options));
+registration_tests_script(
+    (script, options) => navigator.serviceWorker.register(script, options),
+    'classic'
+);
 </script>
diff --git a/service-workers/service-worker/resources/registration-tests-script.js b/service-workers/service-worker/resources/registration-tests-script.js
index 4d08efd..f400bb9 100644
--- a/service-workers/service-worker/resources/registration-tests-script.js
+++ b/service-workers/service-worker/resources/registration-tests-script.js
@@ -1,6 +1,6 @@
 // Registration tests that mostly exercise the service worker script contents or
 // response.
-function registration_tests_script(register_method) {
+function registration_tests_script(register_method, type) {
   promise_test(function(t) {
       var script = 'resources/invalid-chunked-encoding.py';
       var scope = 'resources/scope/invalid-chunked-encoding/';
@@ -46,14 +46,16 @@
           'Registration of script including uncaught exception should fail.');
     }, 'Registering script including uncaught exception');
 
-  promise_test(function(t) {
-      var script = 'resources/malformed-worker.py?import-malformed-script';
-      var scope = 'resources/scope/import-malformed-script';
-      return promise_rejects_js(t,
-          TypeError,
-          register_method(script, {scope: scope}),
-          'Registration of script importing malformed script should fail.');
-    }, 'Registering script importing malformed script');
+  if (type === 'classic') {
+    promise_test(function(t) {
+        var script = 'resources/malformed-worker.py?import-malformed-script';
+        var scope = 'resources/scope/import-malformed-script';
+        return promise_rejects_js(t,
+            TypeError,
+            register_method(script, {scope: scope}),
+            'Registration of script importing malformed script should fail.');
+      }, 'Registering script importing malformed script');
+  }
 
   promise_test(function(t) {
       var script = 'resources/no-such-worker.js';
@@ -64,14 +66,16 @@
           'Registration of non-existent script should fail.');
     }, 'Registering non-existent script');
 
-  promise_test(function(t) {
-      var script = 'resources/malformed-worker.py?import-no-such-script';
-      var scope = 'resources/scope/import-no-such-script';
-      return promise_rejects_js(t,
-          TypeError,
-          register_method(script, {scope: scope}),
-          'Registration of script importing non-existent script should fail.');
-    }, 'Registering script importing non-existent script');
+  if (type === 'classic') {
+    promise_test(function(t) {
+        var script = 'resources/malformed-worker.py?import-no-such-script';
+        var scope = 'resources/scope/import-no-such-script';
+        return promise_rejects_js(t,
+            TypeError,
+            register_method(script, {scope: scope}),
+            'Registration of script importing non-existent script should fail.');
+      }, 'Registering script importing non-existent script');
+  }
 
   promise_test(function(t) {
       var script = 'resources/malformed-worker.py?caught-exception';