default-enabled-features-helper.js (2257B)
1 // This is a helper file used for the attribution-reporting-*.https.html tests. 2 // To use this, make sure you import these scripts: 3 // <script src="/resources/testharness.js"></script> 4 // <script src="/resources/testharnessreport.js"></script> 5 // <script src="/common/utils.js"></script> 6 // <script src="/common/dispatcher/dispatcher.js"></script> 7 // <script src="resources/utils.js"></script> 8 // <script src="/common/get-host-info.sub.js"></script> 9 10 async function runDefaultEnabledFeaturesTest(t, should_load, fenced_origin, 11 generator_api="fledge", allow="") { 12 const fencedframe = await attachFencedFrameContext({ 13 generator_api: generator_api, 14 attributes: [["allow", allow]], 15 origin: fenced_origin}); 16 17 if (!should_load) { 18 const fencedframe_blocked = new Promise(r => t.step_timeout(r, 1000)); 19 const fencedframe_loaded = fencedframe.execute(() => {}); 20 assert_equals(await Promise.any([ 21 fencedframe_blocked.then(() => "blocked"), 22 fencedframe_loaded.then(() => "loaded"), 23 ]), "blocked", "The fenced frame should not be loaded."); 24 return; 25 } 26 27 await fencedframe.execute((generator_api) => { 28 assert_true( 29 document.featurePolicy.allowsFeature('attribution-reporting'), 30 "Attribution reporting should be allowed if the fenced " + 31 "frame loaded using FLEDGE or shared storage."); 32 33 if (generator_api == "fledge") { 34 assert_true( 35 document.featurePolicy.allowsFeature('shared-storage'), 36 "Shared Storage should be allowed if the fenced " + 37 "frame loaded using FLEDGE."); 38 assert_true( 39 document.featurePolicy.allowsFeature('private-aggregation'), 40 "Private Aggregation should be allowed if the fenced " + 41 "frame loaded using FLEDGE."); 42 } else { 43 assert_true( 44 document.featurePolicy.allowsFeature('shared-storage'), 45 "Shared Storage should be allowed if the fenced " + 46 "frame loaded using Shared Storage."); 47 assert_false( 48 document.featurePolicy.allowsFeature('private-aggregation'), 49 "Private Aggregation should be disabled if the fenced " + 50 "frame loaded using Shared Storage."); 51 } 52 }, [generator_api]); 53 }