browser/components/sessionstore/test/browser_464620_b.js

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
-rw-r--r--

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

     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 464620 (injection on DOM node insertion) **/
     8   waitForExplicitFinish();
    10   let testURL = "http://mochi.test:8888/browser/" +
    11     "browser/components/sessionstore/test/browser_464620_b.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++ < 6)
    18       return;
    19     this.removeEventListener("load", arguments.callee, true);
    21     executeSoon(function() {
    22       frameCount = 0;
    23       let tab2 = gBrowser.duplicateTab(tab);
    24       tab2.linkedBrowser.addEventListener("464620_b", function(aEvent) {
    25         tab2.linkedBrowser.removeEventListener("464620_b", arguments.callee, true);
    26         is(aEvent.data, "done", "XSS injection was attempted");
    28         // let form restoration complete and take into account the
    29         // setTimeout(..., 0) in sss_restoreDocument_proxy
    30         executeSoon(function() {
    31           setTimeout(function() {
    32             let win = tab2.linkedBrowser.contentWindow;
    33             isnot(win.frames[1].document.location, testURL,
    34                   "cross domain document was loaded");
    35             ok(!/XXX/.test(win.frames[1].document.body.innerHTML),
    36                "no content was injected");
    38             // clean up
    39             gBrowser.removeTab(tab2);
    40             gBrowser.removeTab(tab);
    42             finish();
    43           }, 0);
    44         });
    45       }, true, true);
    46     });
    47   }, true);
    48 }

mercurial