browser/components/sessionstore/test/browser_463205.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 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 "use strict";
     6 const URL = ROOT + "browser_463205_sample.html";
     8 /**
     9  * Bug 463205 - Check URLs before restoring form data to make sure a malicious
    10  * website can't modify frame URLs and make us inject form data into the wrong
    11  * web pages.
    12  */
    13 add_task(function test_check_urls_before_restoring() {
    14   // Add a blank tab.
    15   let tab = gBrowser.addTab("about:blank");
    16   let browser = tab.linkedBrowser;
    17   yield promiseBrowserLoaded(browser);
    19   // Restore form data with a valid URL.
    20   ss.setTabState(tab, getState(URL));
    21   yield promiseTabRestored(tab);
    23   let value = yield getInputValue(browser, {id: "text"});
    24   is(value, "foobar", "value was restored");
    26   // Restore form data with an invalid URL.
    27   ss.setTabState(tab, getState("http://example.com/"));
    28   yield promiseTabRestored(tab);
    30   let value = yield getInputValue(browser, {id: "text"});
    31   is(value, "", "value was not restored");
    33   // Cleanup.
    34   gBrowser.removeTab(tab);
    35 });
    37 function getState(url) {
    38   return JSON.stringify({
    39     entries: [{url: URL}],
    40     formdata: {url: url, id: {text: "foobar"}}
    41   });
    42 }

mercurial