browser/components/sessionstore/test/browser_463205.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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