File: test_bug1740516.html

package info (click to toggle)
firefox 147.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,320 kB
  • sloc: cpp: 7,607,359; javascript: 6,533,295; ansic: 3,775,223; python: 1,415,500; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (79 lines) | stat: -rw-r--r-- 3,122 bytes parent folder | download | duplicates (11)
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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test pageshow event order for iframe</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <script>
    SimpleTest.waitForExplicitFinish();

    function waitForPageShow(outer, inner) {
      return new Promise((resolve) => {
        let results = [];
        outer.addEventListener("message", ({ data: persisted }) => {
          results.push({ name: outer.name, persisted });
          if (results.length == 2) {
            resolve(results);
          }
        }, { once: true });
        inner.addEventListener("message", ({ data: persisted }) => {
          results.push({ name: inner.name, persisted });
          if (results.length == 2) {
            resolve(results);
          }
        }, { once: true });
      });
    }
    async function runTest() {
      let outerBC = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("bug1740516_1");
      let innerBC = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("bug1740516_1_inner");

      let check = waitForPageShow(outerBC, innerBC).then(([first, second]) => {
        is(first.name, "bug1740516_1_inner", "Should get pageShow from inner iframe page first.");
        ok(!first.persisted, "First navigation shouldn't come from BFCache.");
        is(second.name, "bug1740516_1", "Should get pageShow from outer page second.");
        ok(!second.persisted, "First navigation shouldn't come from BFCache.");
      }, () => {
        ok(false, "The promises should not be rejected.");
      });
      window.open("file_bug1740516_1.html", "", "noopener");
      await check;

      check = waitForPageShow(outerBC, innerBC).then(([first, second]) => {
        is(first.name, "bug1740516_1_inner", "Should get pageShow from inner iframe page first.");
        ok(first.persisted, "Second navigation should come from BFCache");
        is(second.name, "bug1740516_1", "Should get pageShow from outer page second.");
        ok(second.persisted, "Second navigation should come from BFCache");
      }, () => {
        ok(false, "The promises should not be rejected.");
      });
      outerBC.postMessage("navigate");
      await check;

      check = waitForPageShow(outerBC, innerBC).then(([first, second]) => {
        is(first.name, "bug1740516_1_inner", "Should get pageShow from inner iframe page first.");
        ok(!first.persisted, "Third navigation should not come from BFCache");
        is(second.name, "bug1740516_1", "Should get pageShow from outer page second.");
        ok(!second.persisted, "Third navigation should not come from BFCache");
      }, () => {
        ok(false, "The promises should not be rejected.");
      });
      outerBC.postMessage("block_bfcache_and_navigate");
      await check;

      outerBC.postMessage("close");

      outerBC.close();
      innerBC.close();

      SimpleTest.finish();
    }
  </script>
</head>
<body onload="runTest();">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>