tor-browser

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

get-nested-configs.https.html (4675B)


      1 <!DOCTYPE html>
      2 <title>window.fence.getNestedConfigs() test</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/utils.js"></script>
      6 <script src="/common/utils.js"></script>
      7 <script src="/common/get-host-info.sub.js"></script>
      8 
      9 <body>
     10 <script>
     11 promise_test(async (t) => {
     12  const key = token();
     13  const urn = await generateURNFromFledge(
     14      "resources/get-nested-configs-inner.html", [key]);
     15  attachFencedFrame(urn);
     16 
     17  const response = await nextValueFromServer(key);
     18  const [length] = response.split(",");
     19 
     20  assert_equals(length, '40', 'There should be 40 nested configurations.');
     21 }, 'getNestedConfigs() created by FLEDGE should return configurations');
     22 
     23 for (const resolve_to_config of [true, false]) {
     24  promise_test(async (t) => {
     25    const key = token();
     26    const select_url_result = await runSelectURL(
     27        generateURL("resources/get-nested-configs-inner.html", [key]),
     28        [], resolve_to_config);
     29    attachFencedFrame(select_url_result);
     30 
     31    const response = await nextValueFromServer(key);
     32    const [length, first_url] = response.split(",");
     33 
     34    assert_equals(length, '0', 'There should be 0 nested configurations.');
     35  }, 'getNestedConfigs() from a fenced frame with the ' +
     36     (resolve_to_config ? 'config' : 'urn:uuid') +
     37     ' from sharedStroage.selectURL() should be empty');
     38 }
     39 
     40 promise_test(async (t) => {
     41  const key = token();
     42  const url = generateURL("resources/get-nested-configs-inner.html", [key]);
     43  attachFencedFrame(url, mode='default');
     44 
     45  const response = await nextValueFromServer(key);
     46  const [length, first_url] = response.split(",");
     47 
     48  assert_equals(length, '0', 'There should be 0 nested configurations.');
     49 }, 'getNestedConfigs() from a default mode frame should be empty');
     50 
     51 promise_test(async (t) => {
     52  const key = token();
     53  const urn = await generateURNFromFledge(
     54      "resources/get-nested-configs-nested-iframe.html", [key]);
     55  attachFencedFrame(urn);
     56 
     57  const response = await nextValueFromServer(key);
     58  const [length, first_url] = response.split(",");
     59 
     60  assert_equals(length, '40', 'There should be 40 nested configurations.');
     61 }, 'getNestedConfigs() should work in a same-origin nested iframe');
     62 
     63 promise_test(async (t) => {
     64  const key = token();
     65 
     66  const nested_url = generateURL("resources/embeddee.html", [key]);
     67 
     68  // Navigate a fenced frame to `navigate-nested-config.html`. That page will
     69  // in turn create a nested fenced frame which will be navigated to the URN of
     70  // the first item in the nested configs list, `nested_url`.
     71  const urn = await generateURNFromFledge(
     72      "resources/navigate-nested-config.html", [key],
     73      [nested_url]);
     74  attachFencedFrame(urn);
     75 
     76  const response = await nextValueFromServer(key);
     77  assert_equals(response, 'PASS', 'The nested URL should load.');
     78 }, 'Nested configs created by FLEDGE should be navigable by fenced frame');
     79 
     80 promise_test(async (t) => {
     81  const key = token();
     82 
     83  const nested_url = generateURL("resources/embeddee.html", [key]);
     84 
     85  // Navigate a fenced frame to `navigate-nested-config.html`. That page will
     86  // in turn create a nested fenced frame which will be navigated to the URN of
     87  // the first item in the nested configs list, `nested_url`.
     88  const urn = await generateURNFromFledge(
     89      "resources/navigate-nested-config.html", [key],
     90      [nested_url]);
     91  attachIFrame(urn);
     92 
     93  const response = await nextValueFromServer(key);
     94  assert_equals(response, 'PASS', 'The nested URL should load.');
     95 }, 'Nested configs created by FLEDGE should be navigable by URN iframe');
     96 
     97 promise_test(async (t) => {
     98  const key = token();
     99 
    100  const nested_url = generateURL("resources/embeddee.html", [key]);
    101 
    102  // Navigate a fenced frame to `navigate-nested-config.html`. That page will
    103  // in turn create a nested fenced frame which will be navigated to the URN of
    104  // the first item in the nested configs list, `nested_url`. Since this URN
    105  // is invalid, the navigation should gracefully fail.
    106  const urn = await generateURNFromFledge(
    107      "resources/navigate-nested-config.html", [key],
    108      []);
    109  attachFencedFrame(urn);
    110 
    111  // There is no API to observe whether the document in the FencedFrame loaded
    112  // or not. Instead, set up a timeout. If the document loads, "PASS" will be
    113  // sent to the server. Otherwise "BLOCKED" will be sent after 1 second.
    114  step_timeout(() => {
    115    writeValueToServer(key, "BLOCKED");
    116  }, 1000);
    117 
    118  const response = await nextValueFromServer(key);
    119  assert_equals(response, 'BLOCKED', 'The nested URL should not load.');
    120 }, 'Navigating an invalid config should be handled gracefully');
    121 
    122 </script>
    123 </body>
    124 </html>