tor-browser

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

bug303267_window.xhtml (3218B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 
      4 <window id="303267Test"
      5        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      6        width="600"
      7        height="600"
      8        onload="setTimeout(runTests, 0);"
      9        title="bug 303267 test">
     10 
     11  <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
     12  <script type="application/javascript" src="docshell_helpers.js" />
     13  <script type="application/javascript"><![CDATA[
     14    ////
     15    // Bug 303267:  When a page is displayed from the bfcache, the script globals should
     16    // remain intact from the page's initial load.
     17    //
     18    async function runTests()
     19    {
     20      // Load an initial test page which should be saved in the bfcache.
     21      var navData = {
     22        uri: getHttpUrl("bug303267.html"),
     23        eventsToListenFor: ["pageshow"],
     24        expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
     25      };
     26      await promisePageNavigation(navData);
     27 
     28      // Save the HTML of the test page for later comparison.
     29      var originalHTML = await getInnerHTMLById("div1");
     30 
     31      // Load a second test page.  The first test page's pagehide event should
     32      // have the .persisted property set to true, indicating that it was 
     33      // stored in the bfcache.
     34      navData = {
     35        uri: "data:text/html,<html><head><title>page2</title></head>" +
     36             "<body>bug303267, page2</body></html>",
     37        eventsToListenFor: ["pageshow", "pagehide"],
     38        expectedEvents: [ {type: "pagehide", 
     39                           title: "bug303267.html", 
     40                           persisted: true},
     41                          {type: "pageshow", 
     42                           title: "page2"} ],
     43      };
     44      await promisePageNavigation(navData);
     45 
     46      // Go back.  Verify that the pageshow event for the original test page
     47      // had a .persisted property of true, indicating that it came from the 
     48      // bfcache.
     49      navData = {
     50        back: true,
     51        eventsToListenFor: ["pageshow", "pagehide"],
     52        expectedEvents: [ {type: "pagehide", 
     53                           title: "page2"},
     54                          {type: "pageshow", 
     55                           title: "bug303267.html", 
     56                           persisted: true} ],
     57      };
     58      await promisePageNavigation(navData);
     59 
     60      // After going back, if showpagecount() could access a global variable
     61      // and change the test div's innerHTML, then we pass.  Otherwise, it
     62      // threw an exception and the following test will fail.
     63      var newHTML = await getInnerHTMLById("div1");
     64      isnot(originalHTML, 
     65        newHTML, "HTML not updated on pageshow; javascript broken?");
     66 
     67      // Tell the framework the test is finished.
     68      finish();
     69    }
     70 
     71    ////
     72    // Return the innerHTML of a particular element in the content document.
     73    //
     74    function getInnerHTMLById(id) {
     75      return SpecialPowers.spawn(TestWindow.getBrowser(), [id], (id) => {
     76        return content.document.getElementById(id).innerHTML;
     77      });
     78    }
     79    
     80  ]]></script>
     81 
     82  <browser type="content" primary="true" flex="1" id="content" remote="true" maychangeremoteness="true" />
     83 </window>