Commit 6c729607 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1667723 - Don't block opening the print dialog if the page sandbox...

Bug 1667723 - Don't block opening the print dialog if the page sandbox auxiliary navigations. r=nika

Matches other browsers and fixes the regression. Print dialogs really
aren't an auxiliary navigation, even though we implement them similarly.

Differential Revision: https://phabricator.services.mozilla.com/D91739
parent 8e5014ba
......@@ -18,6 +18,7 @@ skip-if = os == "mac"
support-files =
file_window_print.html
file_window_print_delayed_during_load.html
file_window_print_sandboxed_iframe.html
[browser_preview_in_container.js]
support-files =
......
......@@ -115,3 +115,37 @@ add_task(async function test_print_delayed_during_load() {
}
);
});
add_task(async function test_print_on_sandboxed_frame() {
// window.print() only shows print preview when print.tab_modal.enabled is
// true.
await SpecialPowers.pushPrefEnv({
set: [["print.tab_modal.enabled", true]],
});
is(
document.querySelector(".printPreviewBrowser"),
null,
"There shouldn't be any print preview browser"
);
await BrowserTestUtils.withNewTab(
`${TEST_PATH}file_window_print_sandboxed_iframe.html`,
async function(browser) {
info(
"Waiting for the first window.print() to run and ensure we're showing the preview..."
);
await BrowserTestUtils.waitForCondition(
() => !!document.querySelector(".printPreviewBrowser")
);
isnot(
document.querySelector(".printPreviewBrowser"),
null,
"Should open the print preview correctly"
);
gBrowser.getTabDialogBox(browser).abortAllDialogs();
}
);
});
<!doctype html>
<iframe sandbox="allow-same-origin allow-scripts allow-modals" src="about:blank" width="0" height="0"></iframe>
<script>
onload = function() {
document.querySelector("iframe").contentWindow.print();
};
</script>
......@@ -819,7 +819,10 @@ nsresult nsWindowWatcher::OpenWindowInternal(
if (Document* doc = parentWindow->GetDoc()) {
// Save sandbox flags for copying to new browsing context (docShell).
activeDocsSandboxFlags = doc->GetSandboxFlags();
if (activeDocsSandboxFlags & SANDBOXED_AUXILIARY_NAVIGATION) {
// Check to see if this frame is allowed to navigate, but don't check if
// we're printing, as that's not a real navigation.
if (aPrintKind == PRINT_NONE &&
(activeDocsSandboxFlags & SANDBOXED_AUXILIARY_NAVIGATION)) {
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment