Bug 1697525 - Prevent calling printPreview().print() r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D107918
This commit is contained in:
Kagami Sascha Rosylight 2021-03-12 16:20:24 +00:00
Родитель 91fdeec18c
Коммит 258f0f6b52
3 изменённых файлов: 13 добавлений и 1 удалений

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

@ -0,0 +1,6 @@
<!DOCTYPE html>
<script>
window.addEventListener('load', () => {
SpecialPowers.wrap(self).printPreview()?.print()
})
</script>

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

@ -260,3 +260,4 @@ asserts(0-1) load 1623918.html # May hit an assertion if the <input> element's a
load 1656925.html
skip-if(Android) load 1665792.html # Print preview on android doesn't fly
load 1681729.html
load 1697525.html

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

@ -5241,7 +5241,12 @@ Nullable<WindowProxyHolder> nsGlobalWindowOuter::Print(
if (docToPrint->IsStaticDocument() &&
(aIsPreview == IsPreview::Yes ||
StaticPrefs::print_tab_modal_enabled())) {
MOZ_DIAGNOSTIC_ASSERT(aForWindowDotPrint == IsForWindowDotPrint::No);
if (aForWindowDotPrint == IsForWindowDotPrint::Yes) {
aError.ThrowNotSupportedError(
"Calling print() from a print preview is unsupported, did you intend "
"to call printPreview() instead?");
return nullptr;
}
// We're already a print preview window, just reuse our browsing context /
// content viewer.
bc = sourceBC;