зеркало из https://github.com/mozilla/pjs.git
Bug 521802 - mochitest-browser-chrome: browser_459906.js intermittent failure, r=zeniko
This commit is contained in:
Родитель
19dff71131
Коммит
61ff54c6a0
|
@ -36,56 +36,48 @@
|
|||
|
||||
function test() {
|
||||
/** Test for Bug 459906 **/
|
||||
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
||||
let testURL = "http://localhost:8888/browser/" +
|
||||
"browser/components/sessionstore/test/browser/browser_459906_sample.html";
|
||||
let uniqueValue = "<b>Unique:</b> " + Date.now();
|
||||
|
||||
|
||||
var frameCount = 0;
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
// wait for all frames to load completely
|
||||
if (frameCount++ < 2)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let iframes = tab.linkedBrowser.contentWindow.frames;
|
||||
iframes[1].document.body.innerHTML = uniqueValue;
|
||||
|
||||
|
||||
frameCount = 0;
|
||||
let tab2 = gBrowser.duplicateTab(tab);
|
||||
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
// wait for all frames to load (and reload!) completely
|
||||
if (frameCount++ < 2)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let pass = 0;
|
||||
const MAX_PASS = 6;
|
||||
executeSoon(function() {
|
||||
info("Checking innerHTML, pass: " + (pass + 1));
|
||||
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
||||
if (iframes[1].document.body.innerHTML != uniqueValue &&
|
||||
++pass <= MAX_PASS) {
|
||||
setTimeout(arguments.callee, 500);
|
||||
return;
|
||||
}
|
||||
is(iframes[1].document.body.innerHTML, uniqueValue,
|
||||
"rich textarea's content correctly duplicated");
|
||||
|
||||
|
||||
let innerDomain = null;
|
||||
try {
|
||||
innerDomain = iframes[0].document.domain;
|
||||
}
|
||||
catch (ex) { /* throws for chrome: documents */ }
|
||||
is(innerDomain, "localhost", "XSS exploit prevented!");
|
||||
|
||||
|
||||
// clean up
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
|
||||
finish();
|
||||
});
|
||||
}, true);
|
||||
|
|
|
@ -8,8 +8,14 @@
|
|||
<iframe></iframe>
|
||||
|
||||
<script type="application/javascript">
|
||||
frames[0].addEventListener("DOMContentLoaded", function() {
|
||||
frames[0].removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
var loadCount = 0;
|
||||
frames[0].addEventListener("DOMContentLoaded", handleLoad, false);
|
||||
frames[1].addEventListener("DOMContentLoaded", handleLoad, false);
|
||||
function handleLoad() {
|
||||
if (++loadCount < 2)
|
||||
return;
|
||||
frames[0].removeEventListener("DOMContentLoaded", handleLoad, false);
|
||||
frames[1].removeEventListener("DOMContentLoaded", handleLoad, false);
|
||||
frames[0].document.designMode = "on";
|
||||
frames[0].document.__defineGetter__("designMode", function() {
|
||||
// inject a cross domain file ...
|
||||
|
@ -26,11 +32,11 @@
|
|||
r.overrideMimeType("text/plain");
|
||||
r.send(null);
|
||||
}
|
||||
|
||||
|
||||
return "on";
|
||||
});
|
||||
|
||||
|
||||
frames[1].document.designMode = "on";
|
||||
}, false);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче