Bug 810376 - make content wait for document ready when switching frames, r=jgriffin

This commit is contained in:
Malini Das 2012-11-14 13:35:44 -05:00
Родитель 7587e98f7d
Коммит 0b78ab336e
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -51,6 +51,8 @@ let sandbox;
let asyncTestRunning = false;
let asyncTestCommandId;
let asyncTestTimeoutId;
//timer for doc changes
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
/**
* Called when listener is first started up.
@ -797,6 +799,18 @@ function clearElement(msg) {
* its index in window.frames, or the iframe's name or id.
*/
function switchToFrame(msg) {
function checkLoad() {
let errorRegex = /about:.+(error)|(blocked)\?/;
if (curWindow.document.readyState == "complete") {
sendOk();
return;
}
else if (curWindow.document.readyState == "interactive" && errorRegex.exec(curWindow.document.baseURI)) {
sendError("Error loading page", 13, null);
return;
}
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
}
let foundFrame = null;
let frames = curWindow.document.getElementsByTagName("iframe");
//Until Bug 761935 lands, we won't have multiple nested OOP iframes. We will only have one.
@ -806,7 +820,7 @@ function switchToFrame(msg) {
if ((msg.json.value == null) && (msg.json.element == null)) {
curWindow = content;
curWindow.focus();
sendOk();
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
return;
}
if (msg.json.element != undefined) {
@ -865,7 +879,7 @@ function switchToFrame(msg) {
else {
curWindow = curWindow.contentWindow;
curWindow.focus();
sendOk();
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
}
}