зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1697836 - Avoid throwing when asking for a selection. r=emalysz
Selection may be null if the page got hidden in e.g., the afterprint event listener or somewhere else. Add a try catch for good measure, assuming there's no selection is always safe. I'll try to get an automated test-case for this working, though it might be tricky. Depends on D109714 Differential Revision: https://phabricator.services.mozilla.com/D109715
This commit is contained in:
Родитель
188f91724f
Коммит
06b663afd4
|
@ -22,9 +22,8 @@ class PrintingSelectionChild extends JSWindowActorChild {
|
|||
let focusedWindow = Services.focus.focusedWindow;
|
||||
if (focusedWindow) {
|
||||
let selection = focusedWindow.getSelection();
|
||||
return selection.type == "Range";
|
||||
return selection && selection.type == "Range";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,9 +235,11 @@ var PrintUtils = {
|
|||
let sourceActor = aBrowsingContext.currentWindowGlobal.getActor(
|
||||
"PrintingSelection"
|
||||
);
|
||||
hasSelection = await sourceActor.sendQuery(
|
||||
"PrintingSelection:HasSelection"
|
||||
);
|
||||
try {
|
||||
hasSelection = await sourceActor.sendQuery(
|
||||
"PrintingSelection:HasSelection"
|
||||
);
|
||||
} catch (ex) {}
|
||||
}
|
||||
|
||||
let sourceBrowser = aBrowsingContext.top.embedderElement;
|
||||
|
|
Загрузка…
Ссылка в новой задаче