tor-browser

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

select-url-saved-query-key-tuples.tentative.https.sub.html (3917B)


      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 // Saved query results are stored in a map keyed by tuples as follows:
     18 // <data origin, script source URL, operation name, query name>.
     19 // If two queries share the same name, but the full tuple doesn't match,
     20 // then the queries are seen as distinct. In particular, queries cannot be
     21 // shared across different data origins, worklet script source URLs, or
     22 // worklet operation names.
     23 
     24 promise_test(async () => {
     25  const queryKey = "query";
     26  const mockResultKey = "mockresult";
     27  const urlCountKey = "urlcount";
     28  const moduleNameKey = "module";
     29  const operationNameKey = "operation";
     30  const expectSavedKey = "expectsaved";
     31  const expectSuccessKey = "expectsuccess";
     32 
     33  let url0 =  new URL(
     34      "/shared-storage/" +
     35      "resources/select-url-saved-query-inner.https.sub.html",
     36      location.href);
     37 
     38  // Initiate a query to be saved.
     39  url0.searchParams.append(queryKey, "query");
     40  url0.searchParams.append(mockResultKey, "1");
     41  url0.searchParams.append(moduleNameKey, "simple-module");
     42  url0.searchParams.append(operationNameKey, "test-url-selection-operation");
     43  url0.searchParams.append(urlCountKey, "4");
     44  url0.searchParams.append(expectSavedKey, "false");
     45  url0.searchParams.append(expectSuccessKey, "true");
     46  await attachIFrameWithEventListenerForSelectURLStatus(url0);
     47 
     48  // This second query will be distinct because its operation name differs. We
     49  // set a new mock result that differs from all previous results to verify
     50  // that we return this new result instead of re-using any previous result.
     51  let url1 = url0;
     52  url1.searchParams.delete(operationNameKey);
     53  url1.searchParams.append(operationNameKey, "test-url-selection-operation-2");
     54  url1.searchParams.delete(mockResultKey);
     55  url1.searchParams.append(mockResultKey, "2");
     56  await attachIFrameWithEventListenerForSelectURLStatus(url1);
     57 
     58  // This third query will be distinct because its script source URL differs. We
     59  // set a new mock result that differs from all previous results to verify
     60  // that we return this new result instead of re-using any previous result.
     61  let url2 = url0;
     62  url2.searchParams.delete(moduleNameKey);
     63  url2.searchParams.append(moduleNameKey, "simple-module2");
     64  url2.searchParams.delete(operationNameKey);
     65  url2.searchParams.append(operationNameKey , "test-url-selection-operation");
     66  url2.searchParams.delete(mockResultKey);
     67  url2.searchParams.append(mockResultKey, "3");
     68  await attachIFrameWithEventListenerForSelectURLStatus(url2);
     69 
     70  // This fourth query will be distinct because its data origin differs. We
     71  // set a new mock result that differs from all previous results to verify
     72  // that we return this new result instead of re-using any previous result.
     73  const crossOrigin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
     74  let url3 = updateUrlToUseNewOrigin(url0, crossOrigin);
     75  url3.searchParams.delete(moduleNameKey);
     76  url3.searchParams.append(moduleNameKey , "simple-module");
     77  url3.searchParams.delete(operationNameKey);
     78  url3.searchParams.append(operationNameKey, "test-url-selection-operation");
     79  url3.searchParams.delete(mockResultKey);
     80  url3.searchParams.append(mockResultKey, "4");
     81  url3.searchParams.delete(urlCountKey);
     82  url3.searchParams.append(urlCountKey, "5");
     83  await attachIFrameWithEventListenerForSelectURLStatus(url3);
     84 
     85 }, 'for selectURL(), saved queries are keyed on <origin, URL, operation, query>.');
     86 </script>
     87 </body>