tor-browser

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

frame-navigation.https.html (3697B)


      1 <!DOCTYPE html>
      2 <title>Test fenced frame navigations (by a parent frame setting its src). </title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/get-host-info.sub.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 
     11 <script>
     12 promise_test(async () => {
     13  // This test checks that fenced frames can be navigated (given a new src).
     14  // The access pattern is as follows, to exercise same- and cross-origin
     15  // navigations in root and nested fenced frames.
     16 
     17  // [root]                 [nested]
     18  // simple (origin 1)
     19  // create-nested (origin 2)
     20  //                        simple (origin 1)
     21  //                        simple (origin 2)
     22  //                        simple (origin 2)
     23  // simple (origin 2)
     24 
     25  const navigation_key = token();
     26  const navigation_ack_key = token();
     27 
     28  // Create URL prefixes to simulate different origins.
     29  // (www1 and www2 are different origins)
     30  const simple_url = generateURL(
     31      "resources/frame-navigation-inner-simple.https.html",
     32      [navigation_key, navigation_ack_key]);
     33  const nested_url = generateURL(
     34      "resources/frame-navigation-inner-create-nested.https.html",
     35      [navigation_key, navigation_ack_key]);
     36  const origin1_simple_url = getRemoteOriginURL(simple_url);
     37  const origin2_nested_url = getRemoteOriginURL(nested_url)
     38      .toString().replace("www1", "www2");
     39  const origin2_simple_url = getRemoteOriginURL(simple_url)
     40      .toString().replace("www1", "www2");
     41 
     42  // Create a root fenced frame.
     43  root_frame = attachFencedFrame(origin1_simple_url);
     44  const root_load1_actual = await nextValueFromServer(navigation_key);
     45  const root_load1_expected = "pass";
     46  assert_equals(root_load1_actual, root_load1_expected,
     47                "The 1st root fenced frame navigation succeeded");
     48 
     49  // Navigate the root fenced frame to a second site (which will nest).
     50  root_frame.config = new FencedFrameConfig(origin2_nested_url);
     51  const root_load2_actual = await nextValueFromServer(navigation_key);
     52  const root_load2_expected = "create-nested";
     53  assert_equals(root_load2_actual, root_load2_expected,
     54      "The 2nd root fenced frame navigation (cross-origin) succeeded");
     55  writeValueToServer(navigation_ack_key, "ACK");
     56 
     57  // Check that all of the nested navigations succeed.
     58  const nested_load1_actual = await nextValueFromServer(navigation_key);
     59  const nested_load1_expected = "pass";
     60  assert_equals(nested_load1_actual, nested_load1_expected,
     61                "The 1st nested fenced frame navigation succeeded");
     62  writeValueToServer(navigation_ack_key, "ACK");
     63 
     64  const nested_load2_actual = await nextValueFromServer(navigation_key);
     65  const nested_load2_expected = "pass";
     66  assert_equals(nested_load2_actual, nested_load2_expected,
     67      "The 2nd nested fenced frame navigation (cross-origin) succeeded");
     68  writeValueToServer(navigation_ack_key, "ACK");
     69 
     70  const nested_load3_actual = await nextValueFromServer(navigation_key);
     71  const nested_load3_expected = "pass";
     72  assert_equals(nested_load3_actual, nested_load3_expected,
     73         "The 3rd nested fenced frame navigation (same-origin) succeeded");
     74  writeValueToServer(navigation_ack_key, "ACK");
     75 
     76  // Navigate the root fenced frame.
     77  root_frame.config = root_frame.config = new FencedFrameConfig(origin2_simple_url);
     78  const root_load3_actual = await nextValueFromServer(navigation_key);
     79  const root_load3_expected = "pass";
     80  assert_equals(root_load3_actual, root_load3_expected,
     81                "The 3rd root fenced frame navigation (same-origin) succeeded");
     82 
     83 }, "Fenced frame navigation should succeed");
     84 </script>
     85 
     86 </body>