summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/history-back-and-forward-should-not-work-in-fenced-tree-inner.html
blob: 9620249d76486c10197d923aa61be71e971e4d07 (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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="utils.js"></script>
<title>history-back-and-forward-should-not-work-in-fenced-tree-inner</title>

<body>
  <script>
    // This is a helper file that will serve as the document loaded inside
    // a fenced frame by 'history-back-and-forward-should-not-work-in-fenced
    // -tree' Once loaded, it will sequentially perform the back and forward
    // history navigations to observe whether these methods were successfuly
    // restricted for the fenced tree.

    const [history_navigation_performed_key, outer_page_ready_key,
           embed_scope] = parseKeylist();

    (async function () {
      const url = new URL(location.href);
      const test = url.searchParams.get("test");

      writeValueToServer(history_navigation_performed_key, "yes");

      // Execute history.back() within fenced frame and iframe.
      await nextValueFromServer(outer_page_ready_key);
      window.history.back();
      writeValueToServer(history_navigation_performed_key, "yes");

      // Execute history.forward() within fenced frame and iframe.
      await nextValueFromServer(outer_page_ready_key);
      window.history.forward();
      writeValueToServer(history_navigation_performed_key, "yes");

      if (embed_scope === "outerPage::fencedFrame::iframe") return;

      const iframe = document.createElement('iframe');
      const iframe_embed_scope = "outerPage::fencedFrame::iframe";
      iframe.src = generateURL(
          "history-back-and-forward-should-not-work-in-fenced-tree-" +
          "inner.html",
          [history_navigation_performed_key, outer_page_ready_key,
           iframe_embed_scope]);
      document.body.append(iframe);
    })();
  </script>
</body>