зеркало из https://github.com/mozilla/gecko-dev.git
Bug 810376 - make content wait for document ready when switching frames, r=jgriffin
This commit is contained in:
Родитель
7587e98f7d
Коммит
0b78ab336e
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче