tor-browser

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

select-url-saved-query-same-origin-multi-query.tentative.https.sub.html (2491B)


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