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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 function test() {
michael@0 6 /** Test for Bug 464620 (injection on DOM node insertion) **/
michael@0 7
michael@0 8 waitForExplicitFinish();
michael@0 9
michael@0 10 let testURL = "http://mochi.test:8888/browser/" +
michael@0 11 "browser/components/sessionstore/test/browser_464620_b.html";
michael@0 12
michael@0 13 var frameCount = 0;
michael@0 14 let tab = gBrowser.addTab(testURL);
michael@0 15 tab.linkedBrowser.addEventListener("load", function(aEvent) {
michael@0 16 // wait for all frames to load completely
michael@0 17 if (frameCount++ < 6)
michael@0 18 return;
michael@0 19 this.removeEventListener("load", arguments.callee, true);
michael@0 20
michael@0 21 executeSoon(function() {
michael@0 22 frameCount = 0;
michael@0 23 let tab2 = gBrowser.duplicateTab(tab);
michael@0 24 tab2.linkedBrowser.addEventListener("464620_b", function(aEvent) {
michael@0 25 tab2.linkedBrowser.removeEventListener("464620_b", arguments.callee, true);
michael@0 26 is(aEvent.data, "done", "XSS injection was attempted");
michael@0 27
michael@0 28 // let form restoration complete and take into account the
michael@0 29 // setTimeout(..., 0) in sss_restoreDocument_proxy
michael@0 30 executeSoon(function() {
michael@0 31 setTimeout(function() {
michael@0 32 let win = tab2.linkedBrowser.contentWindow;
michael@0 33 isnot(win.frames[1].document.location, testURL,
michael@0 34 "cross domain document was loaded");
michael@0 35 ok(!/XXX/.test(win.frames[1].document.body.innerHTML),
michael@0 36 "no content was injected");
michael@0 37
michael@0 38 // clean up
michael@0 39 gBrowser.removeTab(tab2);
michael@0 40 gBrowser.removeTab(tab);
michael@0 41
michael@0 42 finish();
michael@0 43 }, 0);
michael@0 44 });
michael@0 45 }, true, true);
michael@0 46 });
michael@0 47 }, true);
michael@0 48 }

mercurial