browsing-topics-permissions-policy-default.tentative.https.sub.html (3256B)
1 <!doctype html> 2 <body> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src=/browsing-topics/resources/header-util.sub.js></script> 6 <script src=/browsing-topics/resources/load_img.sub.js></script> 7 <script src=/browsing-topics/resources/permissions-policy-util.sub.js></script> 8 <script src=/common/utils.js></script> 9 <script> 10 'use strict'; 11 const header = 'Default permissions policy'; 12 13 promise_test(async t => { 14 let topics = await document.browsingTopics(); 15 assert_equals(topics.length, 0); 16 }, header + ' allows document.browsingTopics() in the current page.'); 17 18 async_test(t => { 19 test_topics_feature_availability_in_subframe(t, /*is_same_origin=*/true, 20 expect_topics_feature_available); 21 }, header + ' allows document.browsingTopics() in same-origin iframes.'); 22 23 async_test(t => { 24 test_topics_feature_availability_in_subframe(t, /*is_same_origin=*/false, 25 expect_topics_feature_available); 26 }, header + ' allows document.browsingTopics() in cross-origin iframes.'); 27 28 const same_origin_url = '/browsing-topics/resources/check-topics-request-header.py'; 29 const cross_origin_url = 'https://{{domains[www]}}:{{ports[https][0]}}' + 30 same_origin_url; 31 32 promise_test(async t => { 33 let response = await fetch(same_origin_url, {browsingTopics: true}); 34 let topics_header = await response.text(); 35 assert_equals(topics_header, EMPTY_TOPICS_HEADER); 36 }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics fetch request.'); 37 38 promise_test(async t => { 39 let response = await fetch(cross_origin_url, {browsingTopics: true}); 40 let topics_header = await response.text(); 41 assert_equals(topics_header, EMPTY_TOPICS_HEADER); 42 }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics fetch request.'); 43 44 promise_test(async t => { 45 let topics_header = await load_topics_image( 46 /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true); 47 assert_equals(topics_header, EMPTY_TOPICS_HEADER); 48 }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics img request.'); 49 50 promise_test(async t => { 51 let topics_header = await load_topics_image( 52 /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false); 53 assert_equals(topics_header, EMPTY_TOPICS_HEADER); 54 }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics img request.'); 55 56 async_test(t => { 57 test_topics_iframe_navigation_header( 58 t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true, 59 expect_topics_header_available); 60 }, header + ' allows the \'Sec-Browsing-Topics\' header to be sent for the same-origin iframe navigation request.'); 61 62 async_test(t => { 63 test_topics_iframe_navigation_header( 64 t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false, 65 expect_topics_header_available); 66 }, header + ' allows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin iframe navigation request.'); 67 68 </script> 69 </body>