Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Bug 810376 - make content wait for document ready when switching fram…
Browse files Browse the repository at this point in the history
…es, r=jgriffin, a=NPOTB
  • Loading branch information
Malini Das committed Nov 14, 2012
1 parent dbcaeff commit ae97944
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions testing/marionette/marionette-listener.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ let sandbox;
let asyncTestRunning = false; let asyncTestRunning = false;
let asyncTestCommandId; let asyncTestCommandId;
let asyncTestTimeoutId; let asyncTestTimeoutId;
//timer for doc changes
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);


/** /**
* Called when listener is first started up. * Called when listener is first started up.
Expand Down Expand Up @@ -797,6 +799,18 @@ function clearElement(msg) {
* its index in window.frames, or the iframe's name or id. * its index in window.frames, or the iframe's name or id.
*/ */
function switchToFrame(msg) { 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 foundFrame = null;
let frames = curWindow.document.getElementsByTagName("iframe"); let frames = curWindow.document.getElementsByTagName("iframe");
//Until Bug 761935 lands, we won't have multiple nested OOP iframes. We will only have one. //Until Bug 761935 lands, we won't have multiple nested OOP iframes. We will only have one.
Expand All @@ -806,7 +820,7 @@ function switchToFrame(msg) {
if ((msg.json.value == null) && (msg.json.element == null)) { if ((msg.json.value == null) && (msg.json.element == null)) {
curWindow = content; curWindow = content;
curWindow.focus(); curWindow.focus();
sendOk(); checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
return; return;
} }
if (msg.json.element != undefined) { if (msg.json.element != undefined) {
Expand Down Expand Up @@ -865,7 +879,7 @@ function switchToFrame(msg) {
else { else {
curWindow = curWindow.contentWindow; curWindow = curWindow.contentWindow;
curWindow.focus(); curWindow.focus();
sendOk(); checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
} }
} }


Expand Down

0 comments on commit ae97944

Please sign in to comment.