зеркало из https://github.com/mozilla/fxa.git
Merge pull request #17215 from mozilla/fix-potential-webchannel-race
bug(settings): Make sure event handler is attached before message is sent
This commit is contained in:
Коммит
7914defaeb
|
@ -349,8 +349,6 @@ export class Firefox extends EventTarget {
|
|||
async fxaCanLinkAccount(
|
||||
options: FxACanLinkAccount
|
||||
): Promise<FxACanLinkAccountResponse> {
|
||||
this.send(FirefoxCommand.CanLinkAccount, options);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const eventHandler = (event: Event) => {
|
||||
const firefoxEvent = event as FirefoxEvent;
|
||||
|
@ -362,6 +360,7 @@ export class Firefox extends EventTarget {
|
|||
resolve(detail.message?.data as FxACanLinkAccountResponse);
|
||||
};
|
||||
window.addEventListener('WebChannelMessageToContent', eventHandler);
|
||||
this.send(FirefoxCommand.CanLinkAccount, options);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче