tor-browser

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

select-url-saved-query-validate-index-before-storing.tentative.https.sub.html (2116B)


      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 returned index (2) is out of range for
     31  // a URL list of size 1. Hence the default index (0) will be returned.
     32  url0.searchParams.append(queryKey, "query");
     33  url0.searchParams.append(mockResultKey, "2");
     34  url0.searchParams.append(moduleNameKey, "simple-module");
     35  url0.searchParams.append(urlCountKey, "1");
     36  url0.searchParams.append(expectSavedKey, "false");
     37  url0.searchParams.append(expectSuccessKey, "false");
     38  await attachIFrameWithEventListenerForSelectURLStatus(url0);
     39 
     40  // Re-using the query on a URL list of larger size doesn't affect the
     41  // returned result even though 2 would have been in-range for a URL list
     42  // of size 4. This verifies that the default index (0) is stored
     43  // and retrieved in this case.
     44  let url1 = url0;
     45  url1.searchParams.delete(urlCountKey);
     46  url1.searchParams.append(urlCountKey, "4");
     47  url1.searchParams.delete(expectSavedKey);
     48  url1.searchParams.append(expectSavedKey, "true");
     49  await attachIFrameWithEventListenerForSelectURLStatus(url1);
     50 
     51 }, 'for selectURL(), a saved query result index is verified before storing,'
     52   + ' and the default is stored if the index is out of range.');
     53 </script>
     54 </body>