browser/components/sessionstore/test/browser_464620_a.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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 input) **/
     8   waitForExplicitFinish();
    10   let testURL = "http://mochi.test:8888/browser/" +
    11     "browser/components/sessionstore/test/browser_464620_a.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++ < 4)
    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_a", function(aEvent) {
    25         tab2.linkedBrowser.removeEventListener("464620_a", 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[0].document.location, testURL,
    34                   "cross domain document was loaded");
    35             ok(!/XXX/.test(win.frames[0].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