tor-browser

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

select-url-report-event.tentative.https.sub.html (2310B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/common/utils.js"></script>
      5 <script src="/shared-storage/resources/util.js"></script>
      6 <script src="/fenced-frame/resources/utils.js"></script>
      7 
      8 <body>
      9 <script>
     10 'use strict';
     11 
     12 // Poll the server for the test result.
     13 async function waitForReportCount(id) {
     14  const url = `/shared-storage/resources/report.py?query&token=${id}`;
     15  for (let i = 0; i < 30; ++i) {
     16      const response = await fetch(url);
     17      let count = response.headers.get("Count");
     18 
     19      if (!count || count === '0') {
     20          await new Promise(resolve => step_timeout(resolve, 100));
     21          continue;
     22      }
     23 
     24      return parseInt(count);
     25  }
     26  assert_true(false, 'timeout');
     27 }
     28 
     29 for (const resolve_to_config of [true, false]) {
     30  promise_test(async () => {
     31    const ancestor_key = token();
     32    let url0 = generateURL("/shared-storage/resources/sender0.html",
     33                           [ancestor_key]);
     34    let url1 = generateURL("/shared-storage/resources/sender1.html",
     35                           [ancestor_key]);
     36 
     37    await addModuleOnce("/shared-storage/resources/simple-module.js");
     38 
     39    const report_id = token();
     40    const reportURL = `/shared-storage/resources/report.py?token=${report_id}`;
     41    let select_url_result = await sharedStorage.selectURL(
     42        "test-url-selection-operation", [
     43            {url: url0,
     44            reportingMetadata:
     45                {
     46                    'click': reportURL,
     47                    'mouse interaction':
     48                    "/shared-storage/resources/receiver1.html"
     49                }
     50            }, {url: url1}
     51        ], {data: {'mockResult': 0}, resolveToConfig: resolve_to_config,
     52            keepAlive: resolve_to_config});
     53    assert_true(validateSelectURLResult(select_url_result, resolve_to_config));
     54    attachFencedFrame(select_url_result, 'opaque-ads');
     55    const result0 = await nextValueFromServer(ancestor_key);
     56    assert_equals(result0, "sender0_reported");
     57 
     58    const reportCount = await waitForReportCount(report_id);
     59    assert_equals(reportCount, 1, `Num reports received: ${reportCount}`);
     60  }, 'selectURL() with reportEvent(), selectURL() resolves to ' +
     61    (resolve_to_config ? 'config' : 'urn:uuid'));
     62 }
     63 
     64 </script>
     65 </body>