Bug 987549 - Wait until BrowserElement child scripts have been loaded before dispatching inputMethod setActive request. r=yxl

This commit is contained in:
Jan Jongboom 2014-04-02 08:51:46 -04:00
parent 091b0c9469
commit fc5a26259f
2 changed files with 33 additions and 16 deletions

View File

@ -15,12 +15,6 @@ function debug(msg) {
// mozbrowser API clients.
docShell.isActive = true;
let infos = sendSyncMessage('browser-element-api:call',
{ 'msg_name': 'hello' })[0];
docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
docShell.setFullscreenAllowed(infos.fullscreenAllowed);
function parentDocShell(docshell) {
if (!docshell) {
return null;
@ -57,3 +51,8 @@ if (!('BrowserElementIsPreloaded' in this)) {
}
var BrowserElementIsReady = true;
let infos = sendSyncMessage('browser-element-api:call',
{ 'msg_name': 'hello' })[0];
docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
docShell.setFullscreenAllowed(infos.fullscreenAllowed);

View File

@ -366,9 +366,11 @@ BrowserElementParent.prototype = {
return true;
},
_recvHello: function(data) {
_recvHello: function() {
debug("recvHello");
this._ready = true;
// Inform our child if our owner element's document is invisible. Note
// that we must do so here, rather than in the BrowserElementParent
// constructor, because the BrowserElementChild may not be initialized when
@ -382,7 +384,7 @@ BrowserElementParent.prototype = {
fullscreenAllowed:
this._frameElement.hasAttribute('allowfullscreen') ||
this._frameElement.hasAttribute('mozallowfullscreen')
}
};
},
_fireCtxMenuEvent: function(data) {
@ -724,15 +726,31 @@ BrowserElementParent.prototype = {
} else {
let reqOld = XPCNativeWrapper.unwrap(activeInputFrame)
.setInputMethodActive(false);
reqOld.onsuccess = function() {
activeInputFrame = null;
this._sendSetInputMethodActiveDOMRequest(req, isActive);
// We wan't to continue regardless whether this req succeeded
reqOld.onsuccess = reqOld.onerror = function() {
let setActive = function() {
activeInputFrame = null;
this._sendSetInputMethodActiveDOMRequest(req, isActive);
}.bind(this);
if (this._ready) {
setActive();
return;
}
// Wait for the hello event from BrowserElementChild
let onReady = function(aMsg) {
if (this._isAlive() && (aMsg.data.msg_name === 'hello')) {
setActive();
this._mm.removeMessageListener('browser-element-api:call',
onReady);
}
}.bind(this);
this._mm.addMessageListener('browser-element-api:call', onReady);
}.bind(this);
reqOld.onerror = function() {
Services.DOMRequest.fireErrorAsync(req,
'Failed to deactivate the old input method: ' +
reqOld.error + '.');
};
}
} else {
this._sendSetInputMethodActiveDOMRequest(req, isActive);