browser/components/sessionstore/test/browser_463206.js

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 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 function test() {
     6   /** Test for Bug 463206 **/
     8   waitForExplicitFinish();
    10   let testURL = "http://mochi.test:8888/browser/" +
    11     "browser/components/sessionstore/test/browser_463206_sample.html";
    13   var frameCount = 0;
    14   let tab = gBrowser.addTab(testURL);
    15   tab.linkedBrowser.addEventListener("load", function(aEvent) {
    16     // wait for all frames to load completely
    17     if (frameCount++ < 5)
    18       return;
    19     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
    21     function typeText(aTextField, aValue) {
    22       aTextField.value = aValue;
    24       let event = aTextField.ownerDocument.createEvent("UIEvents");
    25       event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0);
    26       aTextField.dispatchEvent(event);
    27     }
    29     let doc = tab.linkedBrowser.contentDocument;
    30     typeText(doc.getElementById("out1"), Date.now());
    31     typeText(doc.getElementsByName("1|#out2")[0], Math.random());
    32     typeText(doc.defaultView.frames[0].frames[1].document.getElementById("in1"), new Date());
    34     let tab2 = gBrowser.duplicateTab(tab);
    35     whenTabRestored(tab2, function() {
    36       let doc = tab2.linkedBrowser.contentDocument;
    37       let win = tab2.linkedBrowser.contentWindow;
    38       isnot(doc.getElementById("out1").value,
    39             win.frames[1].document.getElementById("out1").value,
    40             "text isn't reused for frames");
    41       isnot(doc.getElementsByName("1|#out2")[0].value, "",
    42             "text containing | and # is correctly restored");
    43       is(win.frames[1].document.getElementById("out2").value, "",
    44             "id prefixes can't be faked");
    45       // Disabled for now, Bug 588077
    46       // isnot(win.frames[0].frames[1].document.getElementById("in1").value, "",
    47       //       "id prefixes aren't mixed up");
    48       is(win.frames[1].frames[0].document.getElementById("in1").value, "",
    49             "id prefixes aren't mixed up");
    51       // clean up
    52       gBrowser.removeTab(tab2);
    53       gBrowser.removeTab(tab);
    55       finish();
    56     });
    57   }, true);
    58 }

mercurial