Bug 1683279, fix intermittent test error and use the focused window in PrintingSelectionChild.jsm r=mstriemer

Differential Revision: https://phabricator.services.mozilla.com/D102618
This commit is contained in:
Emma Malysz 2021-01-21 19:29:10 +00:00
Родитель cc349bf06f
Коммит f3948b301e
2 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -12,17 +12,19 @@ class PrintingSelectionChild extends JSWindowActorChild {
receiveMessage(message) {
switch (message.name) {
case "PrintingSelection:HasSelection":
return this.hasSelection(this.document.ownerGlobal);
return this.hasSelection();
}
return undefined;
}
hasSelection(global) {
const { content } = global;
hasSelection() {
let focusedWindow = Services.focus.focusedWindow;
if (focusedWindow) {
let selection = focusedWindow.getSelection();
return selection.type == "Range";
}
let focusedWindow = Services.focus.focusedWindow || content;
let selection = focusedWindow.getSelection();
return selection.type == "Range";
return false;
}
}

Просмотреть файл

@ -235,8 +235,7 @@ var PrintUtils = {
"PrintingSelection"
);
hasSelection = await sourceActor.sendQuery(
"PrintingSelection:HasSelection",
{}
"PrintingSelection:HasSelection"
);
}