Skip to content

Commit b434048

Browse files
feat(firefox): roll to r1573 (#43908)
Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com>
1 parent 1af60d9 commit b434048

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

‎browser_patches/firefox/juggler/content/PageAgent.js‎

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -502,36 +502,45 @@ export class PageAgent {
502502
repeat,
503503
keyCode
504504
});
505-
if (type === 'keydown') {
506-
if (text && text !== key) {
507-
tip.commitCompositionWith(text, keyEvent);
508-
} else {
509-
const flags = 0;
510-
// On macOS, Firefox treats Option+<printable key> as text input. Empty text
511-
// means no text should be inserted, so we consume keydown after the page
512-
// has seen it, which prevents the keypress, same as in Chromium and WebKit.
513-
const suppressTextInput = !text && [...key].length === 1 && Services.appinfo.OS === 'Darwin';
514-
if (!suppressTextInput) {
515-
tip.keydown(keyEvent, flags);
505+
const windowUtils = frame.domWindow().windowUtils;
506+
const microTaskLevel = windowUtils.microTaskLevel;
507+
// The actor's WebIDL callback raises the microtask level. Reset it while
508+
// dispatching so checkpoints run between DOM events, as with native input.
509+
windowUtils.microTaskLevel = 0;
510+
try {
511+
if (type === 'keydown') {
512+
if (text && text !== key) {
513+
tip.commitCompositionWith(text, keyEvent);
516514
} else {
517-
const dispose = helper.addEventListener(this._docShell.chromeEventHandler, 'keydown', event => {
518-
if (event.altKey && !event.ctrlKey && !event.metaKey)
519-
event.preventDefault();
520-
}, { capture: true, mozSystemGroup: true });
521-
try {
515+
const flags = 0;
516+
// On macOS, Firefox treats Option+<printable key> as text input. Empty text
517+
// means no text should be inserted, so we consume keydown after the page
518+
// has seen it, which prevents the keypress, same as in Chromium and WebKit.
519+
const suppressTextInput = !text && [...key].length === 1 && Services.appinfo.OS === 'Darwin';
520+
if (!suppressTextInput) {
522521
tip.keydown(keyEvent, flags);
523-
} finally {
524-
dispose();
522+
} else {
523+
const dispose = helper.addEventListener(this._docShell.chromeEventHandler, 'keydown', event => {
524+
if (event.altKey && !event.ctrlKey && !event.metaKey)
525+
event.preventDefault();
526+
}, { capture: true, mozSystemGroup: true });
527+
try {
528+
tip.keydown(keyEvent, flags);
529+
} finally {
530+
dispose();
531+
}
525532
}
526533
}
534+
} else if (type === 'keyup') {
535+
if (text)
536+
throw new Error(`keyup does not support text option`);
537+
const flags = 0;
538+
tip.keyup(keyEvent, flags);
539+
} else {
540+
throw new Error(`Unknown type ${type}`);
527541
}
528-
} else if (type === 'keyup') {
529-
if (text)
530-
throw new Error(`keyup does not support text option`);
531-
const flags = 0;
532-
tip.keyup(keyEvent, flags);
533-
} else {
534-
throw new Error(`Unknown type ${type}`);
542+
} finally {
543+
windowUtils.microTaskLevel = microTaskLevel;
535544
}
536545
}
537546

‎packages/playwright-core/browsers.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"name": "firefox",
20-
"revision": "1572",
20+
"revision": "1573",
2121
"installByDefault": true,
2222
"browserVersion": "159.0",
2323
"title": "Firefox"

0 commit comments

Comments
 (0)