tor-browser

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

select-url-saved-query-rejection.tentative.https.sub.html (2457B)


      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="/common/get-host-info.sub.js"></script>
      6 <script src="/shared-storage-selecturl-limit/resources/utils.js"></script>
      7 <script src="/shared-storage/resources/util.js"></script>
      8 <script src="/fenced-frame/resources/utils.js"></script>
      9 
     10 <body>
     11 <script>
     12 'use strict';
     13 
     14 // Note that we have set the site page bit limit to 6 and the overall page
     15 // bit limit to 12.
     16 
     17 promise_test(async () => {
     18  const queryKey = "query";
     19  const mockResultKey = "mockresult";
     20  const urlCountKey = "urlcount";
     21  const moduleNameKey = "module";
     22  const expectSavedKey = "expectsaved";
     23  const expectSuccessKey = "expectsuccess";
     24 
     25  let url0 =  new URL(
     26      "/shared-storage/" +
     27      "resources/select-url-saved-query-inner.https.sub.html",
     28      location.href);
     29 
     30  // We don't expect success because the operation definition has an
     31  // intentional error and will reject. Hence the default index (0) will be
     32  // returned and will also be stored for later use.
     33  url0.searchParams.append(queryKey, "query");
     34  url0.searchParams.append(mockResultKey, "2");
     35  url0.searchParams.append(moduleNameKey, "erroneous-function-module");
     36  url0.searchParams.append(urlCountKey, "4");
     37  url0.searchParams.append(expectSavedKey, "false");
     38  url0.searchParams.append(expectSuccessKey, "false");
     39  await attachIFrameWithEventListenerForSelectURLStatus(url0);
     40 
     41  // Re-using the query will retrieve the default index.
     42  let url1 = url0;
     43  url1.searchParams.delete(expectSavedKey);
     44  url1.searchParams.append(expectSavedKey, "true");
     45  await attachIFrameWithEventListenerForSelectURLStatus(url1);
     46 
     47  // Verify that worklet was run exactly once.
     48  const ancestorKey = token();
     49  const urls = generateUrls(2, "/shared-storage/resources/frame",
     50                            [ancestorKey]);
     51  const worklet = await sharedStorage.createWorklet(
     52      '/shared-storage/resources/erroneous-function-module.js');
     53  let config = await worklet.selectURL('verify-run-attempts', urls,
     54      {resolveToConfig: true});
     55  assert_true(config instanceof FencedFrameConfig);
     56  attachFencedFrame(config, 'opaque-ads');
     57  const result = await nextValueFromServer(ancestorKey);
     58  assert_equals(result, 'frame1_loaded', "expected 1 run attempt");
     59 
     60 }, 'for selectURL(), a saved query stores the default index on rejection.');
     61 </script>
     62 </body>