tor-browser

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

select-url-limit-multiple-worklets.tentative.https.sub.html (1955B)


      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-selecturl-limit/resources/utils.js"></script>
      6 <script src="/shared-storage/resources/util.js"></script>
      7 <script src="/fenced-frame/resources/utils.js"></script>
      8 
      9 <body>
     10 <script>
     11 'use strict';
     12 
     13 promise_test(async () => {
     14  const ancestorKey = token();
     15  const perOriginBitLimit = 3;
     16  const numUrls = 8;
     17  const urls = generateUrls(numUrls, "/shared-storage/resources/frame",
     18                            [ancestorKey]);
     19  const bitsPerCall = Math.log2(numUrls);
     20 
     21  for (let i = 0; i < Math.floor(perOriginBitLimit / bitsPerCall); ++i) {
     22    let worklet = await sharedStorage.createWorklet("/shared-storage/resources/simple-module.js");
     23    let config = await worklet.selectURL(
     24      "test-url-selection-operation", urls,
     25      {data: {'mockResult': 1}, keepAlive: true, resolveToConfig: true});
     26    assert_true(config instanceof FencedFrameConfig);
     27    attachFencedFrame(config, 'opaque-ads');
     28    const result = await nextValueFromServer(ancestorKey);
     29    assert_equals(result, "frame1_loaded",
     30                 `for index ${i} when budget should remain;`);
     31  }
     32 
     33  // The per-origin per-pageload bit limit for `selectURL()` has been
     34  // reached. The next call should return the default URL.
     35  let worklet = await sharedStorage.createWorklet("/shared-storage/resources/simple-module.js");
     36  let config = await worklet.selectURL(
     37      "test-url-selection-operation", urls,
     38      {data: {'mockResult': 1}, resolveToConfig: true});
     39  assert_true(config instanceof FencedFrameConfig);
     40  attachFencedFrame(config, 'opaque-ads');
     41  const result = await nextValueFromServer(ancestorKey);
     42  assert_equals(result, "frame0_loaded", 'when budget should be exhausted;');
     43 
     44 }, 'selectURL() called on multiple worklets, with per-origin per-pageload limit');
     45 </script>
     46 </body>