2009-09-04 19:03:43 -07:00
|
|
|
<!-- Testcase originally by <moz_bug_r_a4@yahoo.com> -->
|
|
|
|
|
|
|
|
<title>Test for bug 464620 (injection on DOM node insertion)</title>
|
|
|
|
|
|
|
|
<iframe></iframe>
|
|
|
|
<iframe></iframe>
|
|
|
|
<iframe onload="setup()"></iframe>
|
|
|
|
|
|
|
|
<script>
|
2010-03-12 13:53:36 -08:00
|
|
|
var targetUrl = "http://mochi.test:8888/browser/" +
|
2011-12-16 01:11:21 -08:00
|
|
|
"browser/components/sessionstore/test/browser_464620_xd.html";
|
2009-09-04 19:03:43 -07:00
|
|
|
var firstPass;
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-09-04 19:03:43 -07:00
|
|
|
function setup() {
|
|
|
|
if (firstPass !== undefined)
|
|
|
|
return;
|
|
|
|
firstPass = frames[2].location.href == "about:blank";
|
|
|
|
if (firstPass) {
|
2013-02-19 10:32:29 -08:00
|
|
|
frames[0].location = 'data:text/html;charset=utf-8,<body onload="parent.step()">a</body>';
|
|
|
|
frames[1].location = 'data:text/html;charset=utf-8,<body onload="document.designMode=\'on\';">XXX</body>';
|
2009-09-04 19:03:43 -07:00
|
|
|
}
|
|
|
|
frames[2].location = targetUrl;
|
|
|
|
}
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-09-04 19:03:43 -07:00
|
|
|
function step() {
|
|
|
|
frames[0].document.designMode = "on";
|
|
|
|
if (firstPass)
|
|
|
|
return;
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-09-04 19:03:43 -07:00
|
|
|
var body = frames[0].document.body;
|
|
|
|
body.addEventListener("DOMNodeInserted", function() {
|
|
|
|
body.removeEventListener("DOMNodeInserted", arguments.callee, true);
|
|
|
|
xss();
|
|
|
|
}, true);
|
|
|
|
}
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-09-04 19:03:43 -07:00
|
|
|
function xss() {
|
|
|
|
var documentInjected = false;
|
|
|
|
document.getElementsByTagName("iframe")[1].onload =
|
|
|
|
function() { documentInjected = true; };
|
|
|
|
frames[1].location = targetUrl;
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-09-04 19:03:43 -07:00
|
|
|
for (var c = 0; !documentInjected && c < 20; c++) {
|
|
|
|
var r = new XMLHttpRequest();
|
|
|
|
r.open("GET", location.href, false);
|
|
|
|
r.overrideMimeType("text/plain");
|
|
|
|
r.send(null);
|
|
|
|
}
|
|
|
|
document.getElementById("state").textContent = "done";
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2013-09-11 07:10:01 -07:00
|
|
|
var event = new MessageEvent('464620_b', { bubbles: true, cancelable: false,
|
|
|
|
data: "done", origin: location.href,
|
|
|
|
source: window });
|
2009-09-04 19:03:43 -07:00
|
|
|
document.dispatchEvent(event);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<p id="state">pending</p>
|