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 @@ ...@@ -7,34 +7,27 @@
</head> </head>
<body> <body>
<script> <script>
var scope = "resources"; const scope = "./resources/in-scope";
var registration;
promise_test(async (test) => { promise_test(async (test) => {
registration = await navigator.serviceWorker.register("fetch-error-worker.js", { scope : scope }); const registration = await service_worker_unregister_and_register(
var activeWorker = registration.active; test, "./resources/fetch-error-worker.js", scope);
if (activeWorker) promise_test(async () => registration.unregister(),
return; "Unregister service worker");
activeWorker = registration.installing; await wait_for_state(test, registration.installing, 'activated');
return new Promise(resolve => {
activeWorker.addEventListener('statechange', () => {
if (activeWorker.state === "activated")
resolve();
});
});
}, "Setup service worker"); }, "Setup service worker");
promise_test(async (test) => { promise_test(async (test) => {
const iframe = await with_iframe(scope); const iframe = await with_iframe(scope);
test.add_cleanup(() => iframe.remove());
const response = await iframe.contentWindow.fetch("fetch-error-test"); const response = await iframe.contentWindow.fetch("fetch-error-test");
await response.text().then(assert_unreached, (error) => { assert_true(error.message.includes("Sorry")); }); try {
iframe.remove(); await response.text();
assert_unreached();
} catch (error) {
assert_true(error.message.includes("Sorry"));
}
}, "Make sure a load that makes progress does not time out"); }, "Make sure a load that makes progress does not time out");
promise_test(async () => {
registration.unregister();
}, "Unregister service worker");
</script> </script>
</body> </body>
</html> </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