Bug 1965183 - Consider to set microtask level to 0 when dispatching events, r=masayuki,webdriver-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D248391
This commit is contained in:
committed by
opettay@mozilla.com
parent
5d41ea2cd4
commit
1e2a30af40
@@ -71,6 +71,13 @@ export class MarionetteCommandsChild extends JSWindowActorChild {
|
||||
const { eventName, details } = options;
|
||||
const win = this.contentWindow;
|
||||
|
||||
const windowUtils = win.windowUtils;
|
||||
const microTaskLevel = windowUtils.microTaskLevel;
|
||||
// Since we're being called as a webidl callback,
|
||||
// CallbackObjectBase::CallSetup::CallSetup has increased the microtask
|
||||
// level. Undo that temporarily so that microtask handling works closer
|
||||
// the way it would work when dispatching events natively.
|
||||
windowUtils.microTaskLevel = 0;
|
||||
try {
|
||||
switch (eventName) {
|
||||
case "synthesizeKeyDown":
|
||||
@@ -114,6 +121,8 @@ export class MarionetteCommandsChild extends JSWindowActorChild {
|
||||
}
|
||||
|
||||
throw e;
|
||||
} finally {
|
||||
windowUtils.microTaskLevel = microTaskLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,14 @@ class InputModule extends WindowGlobalBiDiModule {
|
||||
async _dispatchEvent(options) {
|
||||
const { eventName, details } = options;
|
||||
|
||||
const windowUtils = this.messageHandler.window.windowUtils;
|
||||
const microTaskLevel = windowUtils.microTaskLevel;
|
||||
// Since we're being called as a webidl callback,
|
||||
// CallbackObjectBase::CallSetup::CallSetup has increased the microtask
|
||||
// level. Undo that temporarily so that microtask handling works closer
|
||||
// the way it would work when dispatching events natively.
|
||||
windowUtils.microTaskLevel = 0;
|
||||
|
||||
try {
|
||||
switch (eventName) {
|
||||
case "synthesizeKeyDown":
|
||||
@@ -98,6 +106,8 @@ class InputModule extends WindowGlobalBiDiModule {
|
||||
}
|
||||
|
||||
throw e;
|
||||
} finally {
|
||||
windowUtils.microTaskLevel = microTaskLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user