tor-browser

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

select-url-saved-query-cross-origin-multi-query.tentative.https.sub.html (2574B)


      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 operationNameKey = "operation";
     23  const expectSavedKey = "expectsaved";
     24  const expectSuccessKey = "expectsuccess";
     25 
     26  const crossOrigin = 'https://{{domains[www]}}:{{ports[https][0]}}';
     27  let url0 =  new URL(crossOrigin +
     28      "/shared-storage/" +
     29      "resources/select-url-saved-query-inner.https.sub.html",
     30      location.href);
     31 
     32  // Initiate a query to be saved.
     33  url0.searchParams.append(queryKey, "query0");
     34  url0.searchParams.append(mockResultKey, "2");
     35  url0.searchParams.append(moduleNameKey, "simple-module");
     36  url0.searchParams.append(operationNameKey, "test-slow-url-selection-operation");
     37  url0.searchParams.append(urlCountKey, "4");
     38  url0.searchParams.append(expectSavedKey, "false");
     39  url0.searchParams.append(expectSuccessKey, "true");
     40  const promise0 = attachIFrameWithEventListenerForSelectURLStatus(url0);
     41 
     42  // Initiate a second query to be saved without waiting for the first.
     43  let url1 = url0;
     44  url1.searchParams.delete(queryKey);
     45  url1.searchParams.append(queryKey, "query1");
     46  url1.searchParams.delete(mockResultKey);
     47  url1.searchParams.append(mockResultKey, "1");
     48  const promise1 = attachIFrameWithEventListenerForSelectURLStatus(url1);
     49 
     50  // Reuse the first query while the initial two queries are still resolving.
     51  let url2 = url0;
     52  url2.searchParams.delete(expectSavedKey);
     53  url2.searchParams.append(expectSavedKey, "true");
     54  const promise2 = attachIFrameWithEventListenerForSelectURLStatus(url2);
     55 
     56  // Reuse the second query.
     57  let url3 = url1;
     58  url3.searchParams.delete(expectSavedKey);
     59  url3.searchParams.append(expectSavedKey, "true");
     60  const promise3 = attachIFrameWithEventListenerForSelectURLStatus(url3);
     61 
     62  // Wait for all the promises to resolve.
     63  await Promise.all([promise0, promise1, promise2, promise3]);
     64 
     65 }, 'for selectURL(), multiple saved queries can be handled simultaneously.');
     66 </script>
     67 </body>