tor-browser

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

automatic-beacon-data-multiple-ancestors.https.html (2254B)


      1 <!DOCTYPE html>
      2 <title>Test window.fence.setReportEventDataForAutomaticBeacons</title>
      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="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-actions.js"></script>
     10 <script src="/resources/testdriver-vendor.js"></script>
     11 <script src="/common/get-host-info.sub.js"></script>
     12 <script src="resources/automatic-beacon-helper.js"></script>
     13 
     14 <body>
     15 <script>
     16 promise_test(async(t) => {
     17  // This test creates the following frame tree:
     18  // Root Frame (A)
     19  //  └─Fenced Frame (A1) [sets valid data]
     20  //     └─IFrame (A2) [sets invalid data]
     21  //        └─IFrame (B) [performs navigation]
     22  // It then checks that B's navigation uses the data set in A1 and not A2,
     23  // since A1's data is valid for B to use.
     24  const fencedframe = await attachFencedFrameContext({
     25    generator_api: 'fledge', register_beacon: true
     26  });
     27 
     28  const valid_beacon = {
     29    eventType: "reserved.top_navigation_start",
     30    eventData: "This is the start data",
     31    destination: ["buyer"],
     32    crossOriginExposed: true
     33  }
     34 
     35  const invalid_beacon = {
     36    eventType: "reserved.top_navigation_start",
     37    eventData: "This data should not be used",
     38    destination: ["buyer"],
     39    crossOriginExposed: false
     40  }
     41 
     42  await fencedframe.execute(async (valid_beacon, invalid_beacon)=> {
     43    window.fence.setReportEventDataForAutomaticBeacons(valid_beacon);
     44 
     45    const iframe = await attachIFrameContext();
     46    await iframe.execute((valid_beacon, invalid_beacon) => {
     47      window.fence.setReportEventDataForAutomaticBeacons(invalid_beacon);
     48    }, [valid_beacon, invalid_beacon]);
     49 
     50    return setupAutomaticBeacon(iframe, [],
     51        "resources/close.html", NavigationTrigger.CrossOriginClick,
     52        "_blank");
     53  }, [valid_beacon, invalid_beacon]);
     54 
     55  await multiClick(10, 10, fencedframe.element)
     56 
     57  await verifyBeaconData(valid_beacon.eventType, valid_beacon.eventData,
     58      get_host_info().HTTPS_REMOTE_ORIGIN);
     59 }, 'An automatic beacon from uses the first valid ancestor-set data.');
     60 
     61 </script>
     62 </body>