diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index 084edb5355c..df21a6fecbf 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -60,7 +60,7 @@ let CERTIFICATE_ERROR_PAGE_PREF = 'security.alternate_certificate_error_page'; let NS_ERROR_MODULE_BASE_OFFSET = 0x45; let NS_ERROR_MODULE_SECURITY= 21; function NS_ERROR_GET_MODULE(err) { - return ((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff) + return ((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff); } function NS_ERROR_GET_CODE(err) { @@ -82,7 +82,7 @@ let SSL_ERROR_BAD_CERT_DOMAIN = (SSL_ERROR_BASE + 12); function getErrorClass(errorCode) { let NSPRCode = -1 * NS_ERROR_GET_CODE(errorCode); - + switch (NSPRCode) { case SEC_ERROR_UNKNOWN_ISSUER: case SEC_ERROR_CA_CERT_INVALID: @@ -129,6 +129,9 @@ function BrowserElementChild() { this._nextPaintHandler = null; + this._isContentWindowCreated = false; + this._pendingSetInputMethodActive = []; + this._init(); }; @@ -566,6 +569,11 @@ BrowserElementChild.prototype = { this._addMozAfterPaintHandler(function () { sendAsyncMsg('documentfirstpaint'); }); + this._isContentWindowCreated = true; + // Handle pending SetInputMethodActive request. + while (this._pendingSetInputMethodActive.length > 0) { + this._recvSetInputMethodActive(this._pendingSetInputMethodActive.shift()); + } } }, @@ -904,6 +912,17 @@ BrowserElementChild.prototype = { _recvSetInputMethodActive: function(data) { let msgData = { id: data.json.id }; + if (!this._isContentWindowCreated) { + if (data.json.args.isActive) { + // To activate the input method, we should wait before the content + // window is ready. + this._pendingSetInputMethodActive.push(data); + return; + } + sendAsyncMsg('got-set-input-method-active', msgData); + msgData.successRv = null; + return; + } // Unwrap to access webpage content. let nav = XPCNativeWrapper.unwrap(content.document.defaultView.navigator); if (nav.mozInputMethod) { @@ -977,7 +996,7 @@ BrowserElementChild.prototype = { return; } - if (NS_ERROR_GET_MODULE(status) == NS_ERROR_MODULE_SECURITY && + if (NS_ERROR_GET_MODULE(status) == NS_ERROR_MODULE_SECURITY && getErrorClass(status) == Ci.nsINSSErrorsService.ERROR_CLASS_BAD_CERT) { // XXX Is there a point firing the event if the error page is not diff --git a/dom/inputmethod/mochitest/file_inputmethod.html b/dom/inputmethod/mochitest/file_inputmethod.html new file mode 100644 index 00000000000..f228a8d8d12 --- /dev/null +++ b/dom/inputmethod/mochitest/file_inputmethod.html @@ -0,0 +1,18 @@ + + + + + diff --git a/dom/inputmethod/mochitest/mochitest.ini b/dom/inputmethod/mochitest/mochitest.ini index 84c391c2eb6..84f79fcd7c9 100644 --- a/dom/inputmethod/mochitest/mochitest.ini +++ b/dom/inputmethod/mochitest/mochitest.ini @@ -2,6 +2,8 @@ support-files = inputmethod_common.js file_test_app.html + file_inputmethod.html [test_basic.html] +[test_bug944397.html] diff --git a/dom/inputmethod/mochitest/test_bug944397.html b/dom/inputmethod/mochitest/test_bug944397.html new file mode 100644 index 00000000000..e7f7fba56dc --- /dev/null +++ b/dom/inputmethod/mochitest/test_bug944397.html @@ -0,0 +1,89 @@ + + + + + Basic test for InputMethod API. + + + + + +Mozilla Bug 944397 + +

+
+
+
+ + +