Commit af56e43c authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Refactor fetch-error.https.html

This changes the test to use the useful utility functions.

Bug: 1017861
Change-Id: Idc399d439b803d52ca44ede417890e0a8a4ae550
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880245
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Auto-Submit: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710237}
parent cac8a2ca
......@@ -7,34 +7,27 @@
</head>
<body>
<script>
var scope = "resources";
var registration;
const scope = "./resources/in-scope";
promise_test(async (test) => {
registration = await navigator.serviceWorker.register("fetch-error-worker.js", { scope : scope });
var activeWorker = registration.active;
if (activeWorker)
return;
activeWorker = registration.installing;
return new Promise(resolve => {
activeWorker.addEventListener('statechange', () => {
if (activeWorker.state === "activated")
resolve();
});
});
const registration = await service_worker_unregister_and_register(
test, "./resources/fetch-error-worker.js", scope);
promise_test(async () => registration.unregister(),
"Unregister service worker");
await wait_for_state(test, registration.installing, 'activated');
}, "Setup service worker");
promise_test(async (test) => {
const iframe = await with_iframe(scope);
test.add_cleanup(() => iframe.remove());
const response = await iframe.contentWindow.fetch("fetch-error-test");
await response.text().then(assert_unreached, (error) => { assert_true(error.message.includes("Sorry")); });
iframe.remove();
try {
await response.text();
assert_unreached();
} catch (error) {
assert_true(error.message.includes("Sorry"));
}
}, "Make sure a load that makes progress does not time out");
promise_test(async () => {
registration.unregister();
}, "Unregister service worker");
</script>
</body>
</html>
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