зеркало из https://github.com/mozilla/pjs.git
Bug 521889 - browser_461743.js is randomly timing out, r=zeniko
This commit is contained in:
Родитель
61ff54c6a0
Коммит
6aa5d9168b
|
@ -36,37 +36,36 @@
|
|||
|
||||
function test() {
|
||||
/** Test for Bug 461743 **/
|
||||
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
||||
let testURL = "http://localhost:8888/browser/" +
|
||||
"browser/components/sessionstore/test/browser/browser_461743_sample.html";
|
||||
|
||||
|
||||
let frameCount = 0;
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
info("New tab added");
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
info("New tab loaded");
|
||||
// Wait for all frames to load completely.
|
||||
if (frameCount++ < 2)
|
||||
return;
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
let tab2 = gBrowser.duplicateTab(tab);
|
||||
info("Duplicated tab");
|
||||
tab2.linkedBrowser.addEventListener("461743", function(aEvent) {
|
||||
tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
|
||||
is(aEvent.data, "done", "XSS injection was attempted");
|
||||
|
||||
executeSoon(function() {
|
||||
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
||||
let innerHTML = iframes[1].document.body.innerHTML;
|
||||
isnot(innerHTML, Components.utils.reportError.toString(),
|
||||
"chrome access denied!");
|
||||
|
||||
// clean up
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
finish();
|
||||
});
|
||||
}, true, true);
|
||||
});
|
||||
let tab2 = gBrowser.duplicateTab(tab);
|
||||
tab2.linkedBrowser.addEventListener("461743", function(aEvent) {
|
||||
tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
|
||||
is(aEvent.data, "done", "XSS injection was attempted");
|
||||
|
||||
executeSoon(function() {
|
||||
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
||||
let innerHTML = iframes[1].document.body.innerHTML;
|
||||
isnot(innerHTML, Components.utils.reportError.toString(),
|
||||
"chrome access denied!");
|
||||
|
||||
// Clean up.
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
finish();
|
||||
});
|
||||
}, true, true);
|
||||
}, true);
|
||||
}
|
||||
|
|
|
@ -10,17 +10,25 @@
|
|||
<script type="application/javascript">
|
||||
var chromeUrl = "chrome://global/content/mozilla.xhtml";
|
||||
var exploitUrl = "javascript:try { document.body.innerHTML = Components.utils.reportError; } catch (ex) { }";
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
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);
|
||||
|
||||
var flip = 0;
|
||||
MutationEvent.prototype.toString = function() {
|
||||
return flip++ == 0 ? chromeUrl : exploitUrl;
|
||||
};
|
||||
|
||||
|
||||
var href = Components.lookupMethod(frames[1].location, "href");
|
||||
var loadChrome = { handleEvent: href };
|
||||
var loadExploit = { handleEvent: href };
|
||||
|
||||
|
||||
function delay() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", location.href, false);
|
||||
|
@ -35,12 +43,12 @@
|
|||
frames[0].document.removeEventListener("DOMNodeInserted", loadExploit, true);
|
||||
frames[0].document.removeEventListener("DOMNodeInserted", done, true);
|
||||
}
|
||||
|
||||
|
||||
frames[0].document.addEventListener("DOMNodeInserted", loadChrome, true);
|
||||
frames[0].document.addEventListener("DOMNodeInserted", delay, true);
|
||||
frames[0].document.addEventListener("DOMNodeInserted", loadExploit, true);
|
||||
frames[0].document.addEventListener("DOMNodeInserted", done, true);
|
||||
|
||||
|
||||
frames[0].document.designMode = "on";
|
||||
};
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче