Commit 7f78f14b authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[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: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810076}
parent 89b2ad00
This is a testharness.js-based test.
PASS Registering invalid chunked encoding script
PASS Registering invalid chunked encoding script with flush
FAIL Registering script including parse error assert_unreached: Should have rejected: Registration of script including parse error should fail. Reached unreachable code
FAIL Registering script including undefined error assert_unreached: Should have rejected: Registration of script including undefined error should fail. Reached unreachable code
FAIL Registering script including uncaught exception assert_unreached: Should have rejected: Registration of script including uncaught exception should fail. Reached unreachable code
PASS Registering non-existent script
PASS Registering script including caught exception
Harness: the test ran to completion.
<!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>
......@@ -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>
// 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 @@ function registration_tests_script(register_method) {
'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 @@ function registration_tests_script(register_method) {
'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';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment