зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676769 - [devtools] Use document.documentURI to detect print preview documents r=ochameau
DevToolsFrameChild actor excludes about:blank windows to avoid creating unnecessary targets. In the parent process we are supposed to also exclude about:blank windows when fetching the browsing-contexts that should be debugged. However the parent-process logic relies on checking the documentURI to exclude about:blank. The actor relies on a docShell flag called hasLoadedNonBlankURI. The printpreview browser element uses an about:blank window, but still displays a document different from about:blank. Consequently the parent process check considers this document as valid, because of its documentURI. But the child actor throws because of the hasLoadedNonBlankURI flag. This changeset adds an additional check for `window.document.documentURI` in the child actor. Also adds a new mochitest to check that we can open the BrowserToolbox and inspect the print preview Differential Revision: https://phabricator.services.mozilla.com/D97153
This commit is contained in:
Родитель
3236acba9d
Коммит
34ec69f339
|
@ -28,5 +28,6 @@ skip-if = os == 'win' || debug || (bits == 64 && !debug && (os == 'mac' || os ==
|
||||||
[browser_browser_toolbox_evaluation_context.js]
|
[browser_browser_toolbox_evaluation_context.js]
|
||||||
[browser_browser_toolbox_fission_contentframe_inspector.js]
|
[browser_browser_toolbox_fission_contentframe_inspector.js]
|
||||||
[browser_browser_toolbox_fission_inspector.js]
|
[browser_browser_toolbox_fission_inspector.js]
|
||||||
skip-if = (os == 'linux' || os == 'mac' || (os == 'win' && os_version == '10.0')) && bits == 64 #Bug 1605107
|
skip-if = (os == 'linux' || os == 'mac' || (os == 'win' && os_version == '10.0')) && bits == 64 #Bug 1605107
|
||||||
|
[browser_browser_toolbox_print_preview.js]
|
||||||
[browser_browser_toolbox_rtl.js]
|
[browser_browser_toolbox_rtl.js]
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
// There are shutdown issues for which multiple rejections are left uncaught.
|
||||||
|
// See bug 1018184 for resolving these issues.
|
||||||
|
const { PromiseTestUtils } = ChromeUtils.import(
|
||||||
|
"resource://testing-common/PromiseTestUtils.jsm"
|
||||||
|
);
|
||||||
|
PromiseTestUtils.allowMatchingRejectionsGlobally(/File closed/);
|
||||||
|
|
||||||
|
// On debug test machine, it takes about 50s to run the test.
|
||||||
|
requestLongerTimeout(4);
|
||||||
|
|
||||||
|
// Test that the MultiProcessBrowserToolbox can be opened when print preview is
|
||||||
|
// started, and can select elements in the print preview document.
|
||||||
|
add_task(async function() {
|
||||||
|
// Forces the Browser Toolbox to open on the inspector by default
|
||||||
|
await pushPref("devtools.browsertoolbox.panel", "inspector");
|
||||||
|
|
||||||
|
// Open the tab *after* opening the Browser Toolbox in order to force creating the remote frames
|
||||||
|
// late and exercise frame target watching code.
|
||||||
|
await addTab(`data:text/html,<div id="test-div">PRINT PREVIEW TEST</div>`);
|
||||||
|
|
||||||
|
info("Start the print preview for the current tab");
|
||||||
|
document.getElementById("cmd_printPreview").doCommand();
|
||||||
|
|
||||||
|
const ToolboxTask = await initBrowserToolboxTask({
|
||||||
|
enableBrowserToolboxFission: true,
|
||||||
|
});
|
||||||
|
await ToolboxTask.importFunctions({
|
||||||
|
selectNodeFront,
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasCloseButton = await ToolboxTask.spawn(null, async () => {
|
||||||
|
/* global gToolbox */
|
||||||
|
const inspector = gToolbox.getPanel("inspector");
|
||||||
|
|
||||||
|
info("Select the printpreview document in the markup view");
|
||||||
|
const browser = await selectNodeFront(
|
||||||
|
inspector,
|
||||||
|
inspector.walker,
|
||||||
|
'browser[printpreview="true"]'
|
||||||
|
);
|
||||||
|
const browserTarget = await browser.connectToRemoteFrame();
|
||||||
|
const walker = (await browserTarget.getFront("inspector")).walker;
|
||||||
|
|
||||||
|
info("Select the #test-div in the print preview document");
|
||||||
|
await selectNodeFront(inspector, walker, "#test-div");
|
||||||
|
return !!gToolbox.doc.getElementById("toolbox-close");
|
||||||
|
});
|
||||||
|
ok(!hasCloseButton, "Browser toolbox doesn't have a close button");
|
||||||
|
|
||||||
|
await ToolboxTask.destroy();
|
||||||
|
});
|
|
@ -41,15 +41,23 @@ function shouldNotifyWindowGlobal(windowGlobal, watchedBrowserId) {
|
||||||
const window = Services.wm.getCurrentInnerWindowWithId(
|
const window = Services.wm.getCurrentInnerWindowWithId(
|
||||||
windowGlobal.innerWindowId
|
windowGlobal.innerWindowId
|
||||||
);
|
);
|
||||||
// For some unknown reason, the print preview of PDFs generates an about:blank document,
|
|
||||||
// which, on the parent process, has windowGlobal.documentURI.spec set to the pdf's URL.
|
// For some unknown reason, the print preview of PDFs generates an about:blank
|
||||||
// So that Frame target helper accept this WindowGlobal and instantiate a target for it.
|
// document, which, on the parent process, has windowGlobal.documentURI.spec
|
||||||
|
// set to the pdf's URL. So that Frame target helper accepts this WindowGlobal
|
||||||
|
// and instantiates a target for it.
|
||||||
// Which is great as this is a valuable document to debug.
|
// Which is great as this is a valuable document to debug.
|
||||||
// But at the end of the day, in the content process, this ends up being an about:blank document,
|
// But in the content process, this ends up being an about:blank document, and
|
||||||
// and hasLoadedNonBlankURI is always false.
|
// hasLoadedNonBlankURI is always false. Nonetheless, this isn't a real empty
|
||||||
// As print preview uses a dialog, check for `opener` being set. It is hard to find
|
// about:blank. We end up loading resource://pdf.js/web/viewer.html.
|
||||||
// any very good differenciator...
|
// But `window.location` is set to about:blank, while `document.documentURI`
|
||||||
if (!window.docShell.hasLoadedNonBlankURI && !browsingContext.opener) {
|
// is set to the pretty printed PDF...
|
||||||
|
// So we end up checking the documentURI in order to see if that's a special
|
||||||
|
// not-really-blank about:blank document!
|
||||||
|
if (
|
||||||
|
!window.docShell.hasLoadedNonBlankURI &&
|
||||||
|
window.document?.documentURI === "about:blank"
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче