Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 6 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /connection-allowlist/tentative/speculation_rules_prerender.https.sub.window.html - WPT Dashboard Interop Dashboard
// META: script=/common/get-host-info.sub.js
// META: script=/common/utils.js
// META: script=/common/dispatcher/dispatcher.js
// META: script=/speculation-rules/prefetch/resources/utils.sub.js
// META: script=resources/utils.js
// META: timeout=long
const port = get_host_info().HTTPS_PORT_ELIDED;
const SUCCESS = true;
const FAILURE = false;
function prerender_test(origin, expectation) {
promise_test(
async t => {
const key = token();
const value = 'hello';
const params = new URLSearchParams();
params.set('key', key);
params.set('value', value);
const url = `${origin}${STORE_URL}?${params.toString()}`;
insertSpeculationRules({
prerender: [{source: 'list', urls: [url], eagerness: 'immediate'}]
});
if (expectation === SUCCESS) {
const result = await nextValueFromServer(key);
assert_equals(result, value);
} else {
const result = await Promise.race([
new Promise(r => t.step_timeout(r, 1000)), nextValueFromServer(key)
]);
assert_true(typeof result === 'undefined');
}
},
`Prerender to ${origin} ${
expectation === SUCCESS ? 'succeeds' : 'fails'}.`);
}
// Note: SpeculationRules API currently does not support cross-site prerender.
// Only same-site prerender is tested. See crbug.com/1176054.
const test_cases = [
// allowed by the allowlist.
];
for (let i = 0; i < test_cases.length; i++) {
prerender_test(test_cases[i].origin, test_cases[i].expectation);
}