Skip to content
Browse files

Bug 810376 - make content wait for document ready when switching fram…

…es, r=jgriffin, a=NPOTB
  • Loading branch information...
1 parent dbcaeff commit ae9794440431e459983c95a0660abdb269c31a5d @malini malini committed Nov 14, 2012
Showing with 16 additions and 2 deletions.
  1. +16 −2 testing/marionette/marionette-listener.js
View
18 testing/marionette/marionette-listener.js
@@ -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);
}
}

0 comments on commit ae97944

Please sign in to comment.
Something went wrong with that request. Please try again.