shared-storage-permissions-policy-self.tentative.https.sub.html (1916B)
1 <!doctype html> 2 <body> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src=/permissions-policy/resources/permissions-policy.js></script> 6 <script src="/shared-storage/resources/util.js"></script> 7 <script> 8 'use strict'; 9 const same_origin_src = '/shared-storage/resources/shared-storage-permissions-policy-helper.html'; 10 const same_origin_script = '/shared-storage/resources/simple-module.js'; 11 const cross_origin = 'https://{{domains[www]}}:{{ports[https][0]}}'; 12 const cross_origin_src = cross_origin + same_origin_src; 13 const cross_origin_script = cross_origin + same_origin_script; 14 const header = 'permissions policy header shared-storage=(self)'; 15 16 promise_test(async t => { 17 const allowed = await AreRegularSharedStorageMethodsAllowed(); 18 assert_true(allowed); 19 }, header + ' allows sharedStorage in the current page.'); 20 21 promise_test(async t => { 22 const worklet = await sharedStorage.createWorklet( 23 same_origin_script, 24 { credentials: "omit" }); 25 }, header + ' allows sharedStorage.createWorklet() with same-origin script'); 26 27 promise_test(async t => { 28 return promise_rejects_dom(t, "InvalidAccessError", 29 sharedStorage.createWorklet( 30 cross_origin_script, 31 { credentials: "omit", dataOrigin: "script-origin" })); 32 }, header + ' disallows sharedStorage.createWorklet() with cross-origin script'); 33 34 async_test(t => { 35 test_feature_availability('shared-storage', t, same_origin_src, 36 expect_feature_available_default); 37 }, header + ' allows sharedStorage in same-origin iframes.'); 38 39 async_test(t => { 40 test_feature_availability('shared-storage', t, cross_origin_src, 41 expect_feature_unavailable_default); 42 }, header + ' disallows sharedStorage in cross-origin iframes.'); 43 </script> 44 </body>