diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-12-30 08:46:47 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-12-30 20:29:20 -0500 |
commit | 0395a076c826ffed7f9a83f8b8f5d49730f773ba (patch) | |
tree | 56d6ebe0b4e6159b20ecc26265043ff01f7ae625 /mailnews/base/src/msgAsyncPrompter.js | |
parent | 357405f6356e28e5fa94cecc078b65c20433d236 (diff) | |
download | UXP-0395a076c826ffed7f9a83f8b8f5d49730f773ba.tar UXP-0395a076c826ffed7f9a83f8b8f5d49730f773ba.tar.gz UXP-0395a076c826ffed7f9a83f8b8f5d49730f773ba.tar.lz UXP-0395a076c826ffed7f9a83f8b8f5d49730f773ba.tar.xz UXP-0395a076c826ffed7f9a83f8b8f5d49730f773ba.zip |
Bug 1176399 - Multiple requests for master password when GMail OAuth2 is enabled.
Diffstat (limited to 'mailnews/base/src/msgAsyncPrompter.js')
-rw-r--r-- | mailnews/base/src/msgAsyncPrompter.js | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/mailnews/base/src/msgAsyncPrompter.js b/mailnews/base/src/msgAsyncPrompter.js index 58b5288e9..ae114683a 100644 --- a/mailnews/base/src/msgAsyncPrompter.js +++ b/mailnews/base/src/msgAsyncPrompter.js @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +Components.utils.import("resource://gre/modules/Deprecated.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Task.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -19,28 +20,46 @@ runnablePrompter.prototype = { _asyncPrompter: null, _hashKey: null, + _promiseAuthPrompt: function(listener) { + return new Promise((resolve, reject) => { + try { + listener.onPromptStartAsync({ onAuthResult: resolve }); + } catch (e) { + if (e.result == Components.results.NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED) { + // Fall back to onPromptStart, for add-ons compat + Deprecated.warning("onPromptStart has been replaced by onPromptStartAsync", + "https://bugzilla.mozilla.org/show_bug.cgi?id=1176399"); + let ok = listener.onPromptStart(); + resolve(ok); + } else { + reject(e); + } + } + }); + }, + run: Task.async(function *() { yield Services.logins.initializationPromise; this._asyncPrompter._log.debug("Running prompt for " + this._hashKey); let prompter = this._asyncPrompter._pendingPrompts[this._hashKey]; let ok = false; try { - ok = prompter.first.onPromptStart(); - } - catch (ex) { + ok = yield this._promiseAuthPrompt(prompter.first); + } catch (ex) { Components.utils.reportError("runnablePrompter:run: " + ex + "\n"); + prompter.first.onPromptCanceled(); } delete this._asyncPrompter._pendingPrompts[this._hashKey]; for (var consumer of prompter.consumers) { try { - if (ok) + if (ok) { consumer.onPromptAuthAvailable(); - else + } else { consumer.onPromptCanceled(); - } - catch (ex) { + } + } catch (ex) { // Log the error for extension devs and others to pick up. Components.utils.reportError("runnablePrompter:run: consumer.onPrompt* reported an exception: " + ex + "\n"); } |