summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/frame-navigation.https.html
blob: f3464c94e9e434172fbc96bff10eaefc1c0bc7bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<title>Test fenced frame navigations (by a parent frame setting its src). </title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/utils.js"></script>

<body>

<script>
promise_test(async () => {
  // This test checks that fenced frames can be navigated (given a new src).
  // The access pattern is as follows, to exercise same- and cross-origin
  // navigations in root and nested fenced frames.

  // [root]                 [nested]
  // simple (origin 1)
  // create-nested (origin 2)
  //                        simple (origin 1)
  //                        simple (origin 2)
  //                        simple (origin 2)
  // simple (origin 2)

  const navigation_key = token();
  const navigation_ack_key = token();

  // Create URL prefixes to simulate different origins.
  // (www1 and www2 are different origins)
  const simple_url = generateURL(
      "resources/frame-navigation-inner-simple.https.html",
      [navigation_key, navigation_ack_key]);
  const nested_url = generateURL(
      "resources/frame-navigation-inner-create-nested.https.html",
      [navigation_key, navigation_ack_key]);
  const origin1_simple_url = getRemoteOriginURL(simple_url);
  const origin2_nested_url = getRemoteOriginURL(nested_url)
      .toString().replace("www1", "www2");
  const origin2_simple_url = getRemoteOriginURL(simple_url)
      .toString().replace("www1", "www2");

  // Create a root fenced frame.
  root_frame = attachFencedFrame(origin1_simple_url);
  const root_load1_actual = await nextValueFromServer(navigation_key);
  const root_load1_expected = "pass";
  assert_equals(root_load1_actual, root_load1_expected,
                "The 1st root fenced frame navigation succeeded");

  // Navigate the root fenced frame to a second site (which will nest).
  root_frame.config = new FencedFrameConfig(origin2_nested_url);
  const root_load2_actual = await nextValueFromServer(navigation_key);
  const root_load2_expected = "create-nested";
  assert_equals(root_load2_actual, root_load2_expected,
      "The 2nd root fenced frame navigation (cross-origin) succeeded");
  writeValueToServer(navigation_ack_key, "ACK");

  // Check that all of the nested navigations succeed.
  const nested_load1_actual = await nextValueFromServer(navigation_key);
  const nested_load1_expected = "pass";
  assert_equals(nested_load1_actual, nested_load1_expected,
                "The 1st nested fenced frame navigation succeeded");
  writeValueToServer(navigation_ack_key, "ACK");

  const nested_load2_actual = await nextValueFromServer(navigation_key);
  const nested_load2_expected = "pass";
  assert_equals(nested_load2_actual, nested_load2_expected,
      "The 2nd nested fenced frame navigation (cross-origin) succeeded");
  writeValueToServer(navigation_ack_key, "ACK");

  const nested_load3_actual = await nextValueFromServer(navigation_key);
  const nested_load3_expected = "pass";
  assert_equals(nested_load3_actual, nested_load3_expected,
         "The 3rd nested fenced frame navigation (same-origin) succeeded");
  writeValueToServer(navigation_ack_key, "ACK");

  // Navigate the root fenced frame.
  root_frame.config = root_frame.config = new FencedFrameConfig(origin2_simple_url);
  const root_load3_actual = await nextValueFromServer(navigation_key);
  const root_load3_expected = "pass";
  assert_equals(root_load3_actual, root_load3_expected,
                "The 3rd root fenced frame navigation (same-origin) succeeded");

}, "Fenced frame navigation should succeed");
</script>

</body>