mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 927592 - add modal dialog handling when document is ready, and only in B2G, r=jgriffin
This commit is contained in:
parent
0c41ab1753
commit
7842fbb562
@ -59,6 +59,8 @@ let heartbeatCallback = function () {}; // Called by the simpletest methods.
|
||||
let originalOnError;
|
||||
//timer for doc changes
|
||||
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
//timer for readystate
|
||||
let readyStateTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
// Send move events about this often
|
||||
let EVENT_INTERVAL = 30; // milliseconds
|
||||
// For assigning unique ids to all touches
|
||||
@ -163,6 +165,20 @@ function startListeners() {
|
||||
addMessageListenerId("Marionette:deleteCookie", deleteCookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used during newSession and restart, called to set up the modal dialog listener in b2g
|
||||
*/
|
||||
function waitForReady() {
|
||||
if (content.document.readyState == 'complete') {
|
||||
readyStateTimer.cancel();
|
||||
content.addEventListener("mozbrowsershowmodalprompt", modalHandler, false);
|
||||
content.addEventListener("unload", waitForReady, false);
|
||||
}
|
||||
else {
|
||||
readyStateTimer.initWithCallback(waitForReady, 100, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we start a new session. It registers the
|
||||
* current environment, and resets all values
|
||||
@ -170,7 +186,9 @@ function startListeners() {
|
||||
function newSession(msg) {
|
||||
isB2G = msg.json.B2G;
|
||||
resetValues();
|
||||
content.addEventListener("mozbrowsershowmodalprompt", modalHandler, false);
|
||||
if (isB2G) {
|
||||
readyStateTimer.initWithCallback(waitForReady, 100, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +206,9 @@ function sleepSession(msg) {
|
||||
*/
|
||||
function restart(msg) {
|
||||
removeMessageListener("Marionette:restart", restart);
|
||||
content.addEventListener("mozbrowsershowmodalprompt", modalHandler, false);
|
||||
if (isB2G) {
|
||||
readyStateTimer.initWithCallback(waitForReady, 100, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
registerSelf();
|
||||
}
|
||||
|
||||
@ -237,7 +257,9 @@ function deleteSession(msg) {
|
||||
removeMessageListenerId("Marionette:getAllCookies", getAllCookies);
|
||||
removeMessageListenerId("Marionette:deleteAllCookies", deleteAllCookies);
|
||||
removeMessageListenerId("Marionette:deleteCookie", deleteCookie);
|
||||
if (isB2G) {
|
||||
content.removeEventListener("mozbrowsershowmodalprompt", modalHandler, false);
|
||||
}
|
||||
this.elementManager.reset();
|
||||
// reset frame to the top-most frame
|
||||
curFrame = content;
|
||||
|
Loading…
Reference in New Issue
Block a user