Bug 1897371 - Handle selectionchange events in screenshots overlay.r=kcochrane

Differential Revision: https://phabricator.services.mozilla.com/D210813
This commit is contained in:
Niklas Baumgardner 2024-05-27 16:38:53 +00:00
parent 16de0305a2
commit 82745ae4d2
2 changed files with 14 additions and 2 deletions

View File

@ -83,8 +83,11 @@ export class ScreenshotsComponentChild extends JSWindowActorChild {
// Handle overlay events here
if (
ScreenshotsComponentChild.OVERLAY_EVENTS.includes(event.type) ||
ScreenshotsComponentChild.PREVENTABLE_EVENTS.includes(event.type)
[
...ScreenshotsComponentChild.OVERLAY_EVENTS,
...ScreenshotsComponentChild.PREVENTABLE_EVENTS,
"selectionchange",
].includes(event.type)
) {
if (!this.overlay?.initialized) {
return;

View File

@ -27,6 +27,15 @@ add_task(async function test_textSelectedDuringScreenshot() {
await helper.clickTestPageElement("selection");
// The selection doesn't get cleared in the tests so just manually
// remove the selection here.
// In real scenarios, the selection is cleared when the page is
// interacted with.
await ContentTask.spawn(browser, [], async () => {
let selection = content.window.getSelection();
selection.removeAllRanges();
});
let clipboardChanged = helper.waitForRawClipboardChange(
Math.round(rect.width),
Math.round(rect.height),