File: bug449780_window.xhtml

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; 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 (83 lines) | stat: -rw-r--r-- 2,761 bytes parent folder | download | duplicates (18)
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
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window title="Mozilla Bug 449780" onload="setTimeout(doTheTest, 0);"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <hbox id="parent">
  </hbox>

  <!-- test code goes here -->
  <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
  <script type="application/javascript" src="docshell_helpers.js" />
  <script type="application/javascript"><![CDATA[
    function addBrowser(parent, width, height) {
      var b =
        document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser");
      b.setAttribute("type", "content");
      b.setAttribute("id", "content");
      b.setAttribute("width", width);
      b.setAttribute("height", height);
      b.setAttribute("remote", SpecialPowers.Services.appinfo.sessionHistoryInParent);
      if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
        b.setAttribute("maychangeremoteness", "true");
      }
      document.getElementById("parent").appendChild(b);
      return b;
    }

    let f1 = addBrowser("parent", 300, 200);

    /** Test for Bug 449780 */
    var doc1 = "data:text/html,<html><body>This is a test</body></html>";
    var doc2 = "data:text/html,<html><body>This is a second test</body></html>";

    async function doTheTest() {
      await promisePageNavigation({
        uri: doc1,
      });
      let { origDOM, modifiedDOM } = await SpecialPowers.spawn(f1, [], () => {
        var origDOM = content.document.documentElement.innerHTML;
        content.document.body.textContent = "Modified";
        var modifiedDOM = content.document.documentElement.innerHTML;
        isnot(origDOM, modifiedDOM, "DOM should be different");
        return { origDOM, modifiedDOM };
      });

      await promisePageNavigation({
        uri: doc2,
      });

      await promisePageNavigation({
        back: true,
      });

      await SpecialPowers.spawn(f1, [modifiedDOM], (modifiedDOM) => {
        is(content.document.documentElement.innerHTML, modifiedDOM, "Should have been bfcached");
      });

      await promisePageNavigation({
        forward: true,
      });

      f1.removeAttribute("id");
      let f2 = addBrowser("parent", 300, 200);

      // Make sure there's a document or the swap will fail.
      await promisePageNavigation({
        uri: "about:blank",
      });

      f1.swapDocShells(f2);

      await promisePageNavigation({
        back: true,
      });

      await SpecialPowers.spawn(f2, [origDOM], (origDOM) => {
        is(content.document.documentElement.innerHTML, origDOM, "Should not have been bfcached");
      });

      finish();
    }
  ]]></script>
</window>