зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1747107 - [remote] Replace FrameContextUtils::getOsPid with isParentProcess r=webdriver-reviewers,jgraham,whimboo. CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D134663
This commit is contained in:
Родитель
c4f5279fc3
Коммит
0c179363d6
|
@ -10,6 +10,7 @@ prefs =
|
|||
[browser_events_handler.js]
|
||||
[browser_events_module_internal.js]
|
||||
[browser_events_module_protocol.js]
|
||||
[browser_frame_context_utils.js]
|
||||
[browser_handle_command_errors.js]
|
||||
[browser_handle_simple_command.js]
|
||||
[browser_registry.js]
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { isBrowsingContextCompatible } = ChromeUtils.import(
|
||||
"chrome://remote/content/shared/messagehandler/transports/FrameContextUtils.jsm"
|
||||
);
|
||||
const TEST_COM_PAGE = "https://example.com/document-builder.sjs?html=com";
|
||||
const TEST_NET_PAGE = "https://example.net/document-builder.sjs?html=net";
|
||||
|
||||
// Test helpers from FrameContextUtils in various processes.
|
||||
add_task(async function() {
|
||||
const tab1 = BrowserTestUtils.addTab(gBrowser, TEST_COM_PAGE);
|
||||
const contentBrowser1 = tab1.linkedBrowser;
|
||||
await BrowserTestUtils.browserLoaded(contentBrowser1);
|
||||
const browserId1 = contentBrowser1.browsingContext.browserId;
|
||||
|
||||
const tab2 = BrowserTestUtils.addTab(gBrowser, TEST_NET_PAGE);
|
||||
const contentBrowser2 = tab2.linkedBrowser;
|
||||
await BrowserTestUtils.browserLoaded(contentBrowser2);
|
||||
const browserId2 = contentBrowser2.browsingContext.browserId;
|
||||
|
||||
const parentBrowser1 = createParentBrowserElement(tab1, "content");
|
||||
const parentBrowser2 = createParentBrowserElement(tab1, "chrome");
|
||||
|
||||
info("Check browsing context compatibility for content browser 1");
|
||||
await checkBrowsingContextCompatible(contentBrowser1, undefined, true);
|
||||
await checkBrowsingContextCompatible(contentBrowser1, browserId1, true);
|
||||
await checkBrowsingContextCompatible(contentBrowser1, browserId2, false);
|
||||
|
||||
info("Check browsing context compatibility for content browser 2");
|
||||
await checkBrowsingContextCompatible(contentBrowser2, undefined, true);
|
||||
await checkBrowsingContextCompatible(contentBrowser2, browserId1, false);
|
||||
await checkBrowsingContextCompatible(contentBrowser2, browserId2, true);
|
||||
|
||||
info("Check browsing context compatibility for parent browser 1");
|
||||
await checkBrowsingContextCompatible(parentBrowser1, undefined, false);
|
||||
await checkBrowsingContextCompatible(parentBrowser1, browserId1, false);
|
||||
await checkBrowsingContextCompatible(parentBrowser1, browserId2, false);
|
||||
|
||||
info("Check browsing context compatibility for parent browser 2");
|
||||
await checkBrowsingContextCompatible(parentBrowser2, undefined, false);
|
||||
await checkBrowsingContextCompatible(parentBrowser2, browserId1, false);
|
||||
await checkBrowsingContextCompatible(parentBrowser2, browserId2, false);
|
||||
|
||||
gBrowser.removeTab(tab1);
|
||||
gBrowser.removeTab(tab2);
|
||||
});
|
||||
|
||||
async function checkBrowsingContextCompatible(browser, browserId, expected) {
|
||||
const options = { browserId };
|
||||
info("Check browsing context compatibility from the parent process");
|
||||
is(isBrowsingContextCompatible(browser.browsingContext, options), expected);
|
||||
|
||||
info(
|
||||
"Check browsing context compatibility from the browsing context's process"
|
||||
);
|
||||
await SpecialPowers.spawn(
|
||||
browser,
|
||||
[browserId, expected],
|
||||
(_browserId, _expected) => {
|
||||
const FrameContextUtils = ChromeUtils.import(
|
||||
"chrome://remote/content/shared/messagehandler/transports/FrameContextUtils.jsm"
|
||||
);
|
||||
is(
|
||||
FrameContextUtils.isBrowsingContextCompatible(content.browsingContext, {
|
||||
browserId: _browserId,
|
||||
}),
|
||||
_expected
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
|
@ -62,12 +62,3 @@ function hasSessionDataFlag(browser) {
|
|||
return content.hasSessionDataFlag;
|
||||
});
|
||||
}
|
||||
|
||||
function createParentBrowserElement(tab, type) {
|
||||
const parentBrowser = gBrowser.ownerDocument.createXULElement("browser");
|
||||
parentBrowser.setAttribute("type", type);
|
||||
const container = gBrowser.getBrowserContainer(tab.linkedBrowser);
|
||||
container.appendChild(parentBrowser);
|
||||
|
||||
return parentBrowser;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,25 @@ function createFrameForUri(uri) {
|
|||
return `<iframe src="${encodeURI(uri)}"></iframe>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a XUL browser element in the provided XUL tab, with the provided type.
|
||||
*
|
||||
* @param {xul:tab} tab
|
||||
* The XUL tab in which the browser element should be inserted.
|
||||
* @param {String} type
|
||||
* The type attribute of the browser element, "chrome" or "content".
|
||||
* @return {xul:browser}
|
||||
* The created browser element.
|
||||
*/
|
||||
function createParentBrowserElement(tab, type) {
|
||||
const parentBrowser = gBrowser.ownerDocument.createXULElement("browser");
|
||||
parentBrowser.setAttribute("type", type);
|
||||
const container = gBrowser.getBrowserContainer(tab.linkedBrowser);
|
||||
container.appendChild(parentBrowser);
|
||||
|
||||
return parentBrowser;
|
||||
}
|
||||
|
||||
// Create a test page with 2 iframes:
|
||||
// - one with a different eTLD+1 (example.com)
|
||||
// - one with a nested iframe on a different eTLD+1 (example.net)
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
|
||||
const EXPORTED_SYMBOLS = ["isBrowsingContextCompatible"];
|
||||
|
||||
function getOsPid(browsingContext) {
|
||||
function isParentProcess(browsingContext) {
|
||||
if (browsingContext instanceof CanonicalBrowsingContext) {
|
||||
return browsingContext.currentWindowGlobal.osPid;
|
||||
return browsingContext.currentWindowGlobal.osPid === -1;
|
||||
}
|
||||
|
||||
return browsingContext.window.osPid;
|
||||
// If `browsingContext` is not a `CanonicalBrowsingContext`, then we are
|
||||
// necessarily in a content process page.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,11 +37,6 @@ function isBrowsingContextCompatible(browsingContext, options = {}) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Skip window globals running in the parent process, unless we want to
|
||||
// support debugging Chrome context, see Bug 1713440.
|
||||
if (getOsPid(browsingContext) === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Skip privileged contexts until we support debugging Chrome context, see Bug 1713440.
|
||||
return !isParentProcess(browsingContext);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче