referrer-policy-from-rules.https.html (1794B)
1 <!DOCTYPE html> 2 <meta name="timeout" content="long"> 3 <title>Prerender with the referrer policy specified in speculation rules</title> 4 5 <!--Split test cases due to the use of timeouts in test utilities.--> 6 <meta name="variant" content="?1-1"> 7 <meta name="variant" content="?2-last"> 8 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <script src="/common/dispatcher/dispatcher.js"></script> 12 <script src="/common/subset-tests.js"></script> 13 <script src="/common/utils.js"></script> 14 <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> 15 <script src="../resources/utils.js"></script> 16 <script src="resources/utils.js"></script> 17 18 <body> 19 <script> 20 setup(() => assertSpeculationRulesIsSupported()); 21 22 subsetTest(promise_test, async t => { 23 const {exec, tryToActivate} = await create_prerendered_page( 24 t, {}, 25 {referrer_policy: 'strict-origin-when-cross-origin'}, 26 {referrer_policy: 'strict-origin'}); 27 28 const actualReferrer = await exec(() => { return document.referrer; }); 29 const expectedReferrer = location.origin + "/"; 30 assert_equals(actualReferrer, expectedReferrer, 'must send the origin as the referrer'); 31 32 const result = await tryToActivate(); 33 assert_equals(result, 'activated'); 34 }, 'with "strict-origin" referrer policy in rule set overriding "strict-origin-when-cross-origin" of referring page'); 35 36 subsetTest(promise_test, async t => { 37 const {exec, tryToActivate} = await create_prerendered_page( 38 t, {}, 39 {referrer_policy: 'strict-origin-when-cross-origin'}, 40 {referrer_policy: 'no-referrrrrrrer'}); 41 const result = await tryToActivate(); 42 assert_equals(result, 'discarded'); 43 }, 'unrecognized policies invalidate the rule'); 44 </script>