shared-worker-partitioned-cookies.tentative.https.html (2172B)
1 <!DOCTYPE html> 2 <head> 3 <meta charset="utf-8"/> 4 <meta name="timeout" content="long"> 5 <title>SharedWorker: Partitioned Cookies</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/test-helpers.sub.js"></script> 9 <script src="/common/get-host-info.sub.js"></script> 10 <script src="support/shared-worker-partitioned-cookies-helper.js"></script> 11 </head> 12 13 <body> 14 <script> 15 16 promise_test(async () => { 17 // Set a Partitioned cookie. 18 document.cookie = 19 '__Host-partitioned=123; Secure; Path=/; SameSite=None; Partitioned;'; 20 assert_true(document.cookie.includes('__Host-partitioned=123')); 21 22 // Set an unpartitioned cookie. 23 document.cookie = 'unpartitioned=456; Secure; Path=/; SameSite=None;'; 24 assert_true(document.cookie.includes('unpartitioned=456')); 25 26 const worker = new SharedWorker('support/shared-worker-echo-cookies.js'); 27 const next_message = worker_message_generator(worker); 28 29 worker.port.postMessage({type: 'test_message'}); 30 const msg1 = await next_message(); 31 assert_true(msg1.ok, 'Message passing'); 32 33 worker.port.postMessage({type: 'echo_cookies_http'}); 34 const msg2 = await next_message(); 35 assert_true(msg2.ok, 'Get cookies'); 36 assert_true( 37 msg2.cookies.includes('__Host-partitioned'), 38 'Can access partitioned cookie via HTTP'); 39 assert_true( 40 msg2.cookies.includes('unpartitioned'), 41 'Can access unpartitioned cookie via HTTP'); 42 43 worker.port.postMessage({type: 'echo_cookies_import'}); 44 const msg3 = await next_message(); 45 assert_true(msg3.ok, 'Get cookies'); 46 assert_true(msg3.cookies.includes( 47 '__Host-partitioned'), 48 'Can access partitioned cookie via importScripts'); 49 assert_true( 50 msg3.cookies.includes('unpartitioned'), 51 'Can access unpartitioned cookie via importScripts'); 52 53 const popup = window.open( 54 new URL( 55 `./support/shared-worker-partitioned-cookies-3p-window.html?origin=${ 56 encodeURIComponent(self.location.origin)}`, 57 get_host_info().HTTPS_NOTSAMESITE_ORIGIN + self.location.pathname)); 58 await fetch_tests_from_window(popup); 59 }); 60 61 </script> 62 </body>