unique-cookie-partition.https.html (1974B)
1 <!DOCTYPE html> 2 <title>Test cookies accessed from a Fenced Frame Tree</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/utils.js"></script> 6 <script src="/common/utils.js"></script> 7 8 <body> 9 <script> 10 const cookie_value_key = token(); 11 const kAssertion = "Cookie accessed from unique fenced frame tree partition "; 12 const kAssertion_outer = "Cookie values changed in the fenced frame tree should not impact the outer frame"; 13 14 async function runTest(test_type) { 15 document.cookie = 'A=outer; SameSite=Lax'; 16 document.cookie = 'B=outer; SameSite=None; Secure'; 17 const fenced_frame = 18 attachFencedFrame(generateURL( 19 `resources/unique-cookie-partition-inner.https.html`, 20 [cookie_value_key, test_type])); 21 22 result = await nextValueFromServer(cookie_value_key); 23 switch (test_type) { 24 case "top-level fenced frame": 25 assert_equals(result, "F=fenced; C=fenced; D=fenced; E=fenced", kAssertion + test_type); 26 break; 27 case "nested iframe": 28 assert_equals(result, "F=fenced; C=fenced; D=fenced; G=nested_in_fenced_frame; E=fenced", kAssertion + test_type); 29 break; 30 case "nested fenced frame": 31 assert_equals(result, "G=nested_in_fenced_frame", kAssertion + test_type); 32 break; 33 } 34 35 // The cookie values changed in the fenced frame tree should not impact the outer frame. 36 const result_outer_frame = document.cookie; 37 assert_equals(result_outer_frame, "A=outer; B=outer", kAssertion_outer); 38 39 // Clean up the fenced frame 40 document.body.removeChild(fenced_frame); 41 } 42 43 promise_test(async () => { 44 return runTest("top-level fenced frame"); 45 }, "Cookie access from top-level fenced frame"); 46 47 promise_test(async () => { 48 return runTest("nested iframe"); 49 }, "Cookie access from iframe nested in a fenced frame"); 50 51 promise_test(async () => { 52 return runTest("nested fenced frame"); 53 }, "Cookie access from nested fenced frame"); 54 </script> 55 </body>