tor-browser

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

bug449780_window.xhtml (2761B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 <window title="Mozilla Bug 449780" onload="setTimeout(doTheTest, 0);"
      4  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      5 
      6  <hbox id="parent">
      7  </hbox>
      8 
      9  <!-- test code goes here -->
     10  <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
     11  <script type="application/javascript" src="docshell_helpers.js" />
     12  <script type="application/javascript"><![CDATA[
     13    function addBrowser(parent, width, height) {
     14      var b =
     15        document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser");
     16      b.setAttribute("type", "content");
     17      b.setAttribute("id", "content");
     18      b.setAttribute("width", width);
     19      b.setAttribute("height", height);
     20      b.setAttribute("remote", SpecialPowers.Services.appinfo.sessionHistoryInParent);
     21      if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
     22        b.setAttribute("maychangeremoteness", "true");
     23      }
     24      document.getElementById("parent").appendChild(b);
     25      return b;
     26    }
     27 
     28    let f1 = addBrowser("parent", 300, 200);
     29 
     30    /** Test for Bug 449780 */
     31    var doc1 = "data:text/html,<html><body>This is a test</body></html>";
     32    var doc2 = "data:text/html,<html><body>This is a second test</body></html>";
     33 
     34    async function doTheTest() {
     35      await promisePageNavigation({
     36        uri: doc1,
     37      });
     38      let { origDOM, modifiedDOM } = await SpecialPowers.spawn(f1, [], () => {
     39        var origDOM = content.document.documentElement.innerHTML;
     40        content.document.body.textContent = "Modified";
     41        var modifiedDOM = content.document.documentElement.innerHTML;
     42        isnot(origDOM, modifiedDOM, "DOM should be different");
     43        return { origDOM, modifiedDOM };
     44      });
     45 
     46      await promisePageNavigation({
     47        uri: doc2,
     48      });
     49 
     50      await promisePageNavigation({
     51        back: true,
     52      });
     53 
     54      await SpecialPowers.spawn(f1, [modifiedDOM], (modifiedDOM) => {
     55        is(content.document.documentElement.innerHTML, modifiedDOM, "Should have been bfcached");
     56      });
     57 
     58      await promisePageNavigation({
     59        forward: true,
     60      });
     61 
     62      f1.removeAttribute("id");
     63      let f2 = addBrowser("parent", 300, 200);
     64 
     65      // Make sure there's a document or the swap will fail.
     66      await promisePageNavigation({
     67        uri: "about:blank",
     68      });
     69 
     70      f1.swapDocShells(f2);
     71 
     72      await promisePageNavigation({
     73        back: true,
     74      });
     75 
     76      await SpecialPowers.spawn(f2, [origDOM], (origDOM) => {
     77        is(content.document.documentElement.innerHTML, origDOM, "Should not have been bfcached");
     78      });
     79 
     80      finish();
     81    }
     82  ]]></script>
     83 </window>