From f3948b301e4d525fc076ba37836c87c24656c619 Mon Sep 17 00:00:00 2001 From: Emma Malysz Date: Thu, 21 Jan 2021 19:29:10 +0000 Subject: [PATCH] Bug 1683279, fix intermittent test error and use the focused window in PrintingSelectionChild.jsm r=mstriemer Differential Revision: https://phabricator.services.mozilla.com/D102618 --- toolkit/actors/PrintingSelectionChild.jsm | 14 ++++++++------ toolkit/components/printing/content/printUtils.js | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/toolkit/actors/PrintingSelectionChild.jsm b/toolkit/actors/PrintingSelectionChild.jsm index 87d802dde508..b13ced53ad89 100644 --- a/toolkit/actors/PrintingSelectionChild.jsm +++ b/toolkit/actors/PrintingSelectionChild.jsm @@ -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; } } diff --git a/toolkit/components/printing/content/printUtils.js b/toolkit/components/printing/content/printUtils.js index d1675cbe9892..1bbfbc1562c7 100644 --- a/toolkit/components/printing/content/printUtils.js +++ b/toolkit/components/printing/content/printUtils.js @@ -235,8 +235,7 @@ var PrintUtils = { "PrintingSelection" ); hasSelection = await sourceActor.sendQuery( - "PrintingSelection:HasSelection", - {} + "PrintingSelection:HasSelection" ); }