Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 23 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /fetch/fetch-later/basic.tentative.https.window.html - WPT Dashboard Interop Dashboard
'use strict';
test(() => {
assert_throws_js(TypeError, () => fetchLater());
}, `fetchLater() cannot be called without request.`);
test(() => {
const result = fetchLater('/');
assert_false(result.activated, `result.activated should be false for '/'`);
}, `fetchLater() with same-origin (https) URL does not throw.`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
const result = fetchLater(url);
assert_false(result.activated, `result.activated should be false for ${url}`);
test(() => {
assert_throws_dom(
'SecurityError', () => fetchLater(httpUrl),
`should throw SecurityError for insecure http url ${httpUrl}`);
}, `fetchLater() throws SecurityError on non-trustworthy http URL.`);
test(() => {
}, `fetchLater() throws TypeError on file:// scheme.`);
test(() => {
}, `fetchLater() throws TypeError on ftp:// scheme.`);
test(() => {
}, `fetchLater() throws TypeError on ssh:// scheme.`);
test(() => {
}, `fetchLater() throws TypeError on wss:// scheme.`);
test(() => {
assert_throws_js(TypeError, () => fetchLater('about:blank'));
}, `fetchLater() throws TypeError on about: scheme.`);
test(() => {
assert_throws_js(TypeError, () => fetchLater(`javascript:alert('');`));
}, `fetchLater() throws TypeError on javascript: scheme.`);
test(() => {
assert_throws_js(TypeError, () => fetchLater('data:text/plain,Hello'));
}, `fetchLater() throws TypeError on data: scheme.`);
test(() => {
assert_throws_js(
}, `fetchLater() throws TypeError on blob: scheme.`);
test(() => {
assert_throws_js(
RangeError,
}, `fetchLater() throws RangeError on negative activateAfter.`);
test(() => {
const result = fetchLater('/');
assert_false(result.activated);
}, `fetchLater()'s return tells the deferred request is not yet sent.`);
test(() => {
const result = fetchLater('/');
assert_throws_js(TypeError, () => result.activated = true);
}, `fetchLater() throws TypeError when mutating its returned state.`);
test(() => {
const controller = new AbortController();
// Immediately aborts the controller.
controller.abort();
assert_throws_dom(
'AbortError', () => fetchLater('/', {signal: controller.signal}));
}, `fetchLater() throws AbortError when its initial abort signal is aborted.`);
test(() => {
const controller = new AbortController();
const result = fetchLater('/', {signal: controller.signal});
assert_false(result.activated);
controller.abort();
assert_false(result.activated);
}, `fetchLater() does not throw error when it is aborted before sending.`);