tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browsing-topics-permissions-policy-none.tentative.https.sub.html (3427B)


      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 = 'permissions policy header browsing-topics=()';
     12 
     13    promise_test(async t => {
     14      try {
     15        await document.browsingTopics();
     16      } catch (e) {
     17        assert_equals(e.message, TOPICS_PERMISSIONS_POLICY_ERROR_MESSAGE);
     18        return;
     19      }
     20      assert_unreached("did not reject");
     21    }, header + ' disallows document.browsingTopics() in the current page.');
     22 
     23    async_test(t => {
     24      test_topics_feature_availability_in_subframe(t, /*is_same_origin=*/true,
     25          expect_topics_feature_unavailable);
     26    }, header + ' disallows document.browsingTopics() in same-origin iframes.');
     27 
     28    async_test(t => {
     29      test_topics_feature_availability_in_subframe(t, /*is_same_origin=*/false,
     30          expect_topics_feature_unavailable);
     31    }, header + ' disallows document.browsingTopics() in cross-origin iframes.');
     32 
     33    const same_origin_url = '/browsing-topics/resources/check-topics-request-header.py';
     34    const cross_origin_url = 'https://{{domains[www]}}:{{ports[https][0]}}' +
     35      same_origin_url;
     36 
     37    promise_test(async t => {
     38      let response = await fetch(same_origin_url, {browsingTopics: true});
     39      let topics_header = await response.text();
     40      assert_equals(topics_header, "NO_TOPICS_HEADER");
     41    }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics fetch request.');
     42 
     43    promise_test(async t => {
     44      let response = await fetch(cross_origin_url, {browsingTopics: true});
     45      let topics_header = await response.text();
     46      assert_equals(topics_header, "NO_TOPICS_HEADER");
     47    }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics fetch request.');
     48 
     49    promise_test(async t => {
     50      let topics_header = await load_topics_image(
     51        /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true);
     52      assert_equals(topics_header, "NO_TOPICS_HEADER");
     53    }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics img request.');
     54 
     55    promise_test(async t => {
     56      let topics_header = await load_topics_image(
     57        /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false);
     58      assert_equals(topics_header, "NO_TOPICS_HEADER");
     59    }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics img request.');
     60 
     61    async_test(t => {
     62      test_topics_iframe_navigation_header(
     63          t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true,
     64          expect_topics_header_unavailable);
     65    }, header + ' disallows the \'Sec-Browsing-Topics\' header to be sent for the same-origin iframe navigation request.');
     66 
     67    async_test(t => {
     68      test_topics_iframe_navigation_header(
     69          t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false,
     70          expect_topics_header_unavailable);
     71    }, header + ' disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin iframe navigation request.');
     72  </script>
     73 </body>