docshell/test/chrome/bug449780_window.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <window title="Mozilla Bug 449780" onload="doTheTest()"
     4   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     6   <hbox id="parent">
     7   </hbox>
     9   <!-- test code goes here -->
    10   <script type="application/javascript"><![CDATA[
    11     var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
    12     for each (var name in imports) {
    13       window[name] = window.opener.wrappedJSObject[name];
    14     }
    16     function $(id) {
    17       return document.getElementById(id);
    18     }
    20     function addBrowser(parent, id, width, height) {
    21       var b =
    22         document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser");
    23       b.setAttribute("type", "content");
    24       b.setAttribute("id", id);
    25       b.setAttribute("width", width);
    26       b.setAttribute("height", height);
    27       $(parent).appendChild(b);
    28     }
    29     addBrowser("parent", "f1", 300, 200);
    30     addBrowser("parent", "f2", 300, 200);
    32     /** Test for Bug 449780 **/
    33     var doc1 = "data:text/html,<html><body>This is a test</body></html>";
    34     var doc2 = "data:text/html,<html><body>This is a second test</body></html>";
    36     function getDOM(id) {
    37       return $(id).contentDocument.documentElement.innerHTML;
    38     }
    40     var tester = (function() {
    41       var origDOM = getDOM("f1");
    42       $("f1").contentDocument.body.textContent = "Modified";
    43       var modifiedDOM = getDOM("f1");
    44       isnot(origDOM, modifiedDOM, "DOM should be different");
    45       $("f1").contentWindow.location.href = doc2;
    46       yield undefined;
    48       $("f1").goBack();
    49       yield undefined;
    51       is(getDOM("f1"), modifiedDOM, "Should have been bfcached");
    52       $("f1").goForward();
    53       yield undefined;
    55       // Ignore the notifications during swap
    56       $("f1").removeEventListener("pageshow", testDriver, false);
    57       $("f1").swapDocShells($("f2"));
    58       $("f2").addEventListener("pageshow", testDriver, false);
    59       $("f2").goBack();
    60       yield undefined;
    62       is(getDOM("f2"), origDOM, "Should have not have been bfcached");
    63       window.close();
    64       SimpleTest.finish();
    65       yield undefined;
    66     })();
    68     function testDriver() {
    69       setTimeout(function() { tester.next() }, 0);
    70     }
    72     function doTheTest() {
    73       $("f1").addEventListener("pageshow", testDriver, false);
    74       $("f1").setAttribute("src", doc1);
    75     }
    76   ]]></script>
    77 </window>

mercurial