docshell/test/chrome/bug303267_window.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     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(nextTest,0);"
     9         title="bug 303267 test">
    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[
    15     // Define the generator-iterator for the tests.
    16     var tests = testIterator();
    18     ////
    19     // Execute the next test in the generator function.
    20     //
    21     function nextTest() {
    22       tests.next();
    23     }
    25     ////
    26     // Generator function for test steps for bug 303267:  When a page is 
    27     // displayed from the bfcache, the script globals should
    28     // remain intact from the page's initial load.
    29     //
    30     function testIterator()
    31     {
    32       // Load an initial test page which should be saved in the bfcache.
    33       var navData = {
    34         uri: getHttpUrl("bug303267.html"),
    35         eventsToListenFor: ["pageshow"],
    36         expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
    37         onNavComplete: nextTest
    38       };
    39       doPageNavigation(navData);
    40       yield undefined;
    42       // Save the HTML of the test page for later comparison.
    43       var originalHTML = getInnerHTMLById("div1");
    45       // Load a second test page.  The first test page's pagehide event should
    46       // have the .persisted property set to true, indicating that it was 
    47       // stored in the bfcache.
    48       navData = {
    49         uri: "data:text/html,<html><head><title>page2</title></head>" +
    50              "<body>bug303267, page2</body></html>",
    51         eventsToListenFor: ["pageshow", "pagehide"],
    52         expectedEvents: [ {type: "pagehide", 
    53                            title: "bug303267.html", 
    54                            persisted: true},
    55                           {type: "pageshow", 
    56                            title: "page2"} ],
    57         onNavComplete: nextTest
    58       };
    59       doPageNavigation(navData);
    60       yield undefined;
    62       // Go back.  Verify that the pageshow event for the original test page 
    63       // had a .persisted property of true, indicating that it came from the 
    64       // bfcache.
    65       navData = {
    66         back: true,
    67         eventsToListenFor: ["pageshow", "pagehide"],
    68         expectedEvents: [ {type: "pagehide", 
    69                            title: "page2"},
    70                           {type: "pageshow", 
    71                            title: "bug303267.html", 
    72                            persisted: true} ],
    73         onNavComplete: nextTest
    74       };
    75       doPageNavigation(navData);
    76       yield undefined;
    78       // After going back, if showpagecount() could access a global variable
    79       // and change the test div's innerHTML, then we pass.  Otherwise, it
    80       // threw an exception and the following test will fail.
    81       var newHTML = getInnerHTMLById("div1");
    82       isnot(originalHTML, 
    83         newHTML, "HTML not updated on pageshow; javascript broken?");
    85       // Tell the framework the test is finished.  Include the final 'yield' 
    86       // statement to prevent a StopIteration exception from being thrown.
    87       finish();
    88       yield undefined;
    89     }
    91     ////
    92     // Return the innerHTML of a particular element in the content document.
    93     //
    94     function getInnerHTMLById(id) {
    95       return TestWindow.getDocument().getElementById(id).innerHTML;
    96     }
    98   ]]></script>
   100   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
   101 </window>

mercurial