From c8cf52618b581d8172f318d52c091d917f40a181 Mon Sep 17 00:00:00 2001 From: Jay Lim Date: Mon, 23 Jul 2018 10:08:45 -0400 Subject: [PATCH] Bug 1472212 - Add e10s tests to ensure that URIs with the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag load in the privileged content process when the pref is turned on. r=Gijs URIs need to have both the URI_CAN_LOAD_IN_PRIVILEGED_CHILD and URI_MUST_LOAD_IN_CHILD flags in order for them to run in the privileged content process when the pref is turned on. MozReview-Commit-ID: 61dO5peNtNL --HG-- extra : rebase_source : f17e7ff205c2a4a32159bfedbe6f2f166086c679 extra : intermediate-source : 2e5de66c1f6004b97f544c89b001d2bc4ddfda1f extra : source : 9ff5280fc25a119d1aa80329b79c07b9910b5768 --- .../general/browser_e10s_about_process.js | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/browser/base/content/test/general/browser_e10s_about_process.js b/browser/base/content/test/general/browser_e10s_about_process.js index 408a4821f2ea..3983d3c4be13 100644 --- a/browser/base/content/test/general/browser_e10s_about_process.js +++ b/browser/base/content/test/general/browser_e10s_about_process.js @@ -1,5 +1,6 @@ const CHROME_PROCESS = E10SUtils.NOT_REMOTE; const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE; +const PRIVILEGED_CONTENT_PROCESS = E10SUtils.PRIVILEGED_REMOTE_TYPE; const CHROME = { id: "cb34538a-d9da-40f3-b61a-069f0b2cb9fb", @@ -16,11 +17,18 @@ const MUSTREMOTE = { path: "test-mustremote", flags: Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD, }; +const CANPRIVILEGEDREMOTE = { + id: "a04ffafe-6c63-4266-acae-0f4b093165aa", + path: "test-canprivilegedremote", + flags: Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD | + Ci.nsIAboutModule.URI_CAN_LOAD_IN_PRIVILEGED_CHILD, +}; const TEST_MODULES = [ CHROME, CANREMOTE, MUSTREMOTE, + CANPRIVILEGEDREMOTE, ]; function AboutModule() { @@ -79,36 +87,70 @@ registerCleanupFunction(() => { } }); -function test_url(url, chromeResult, webContentResult) { +function test_url(url, chromeResult, webContentResult, privilegedContentResult) { is(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS), chromeResult, "Check URL in chrome process."); is(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS), webContentResult, "Check URL in web content process."); + is(E10SUtils.canLoadURIInRemoteType(url, PRIVILEGED_CONTENT_PROCESS), + privilegedContentResult, "Check URL in privileged content process."); is(E10SUtils.canLoadURIInRemoteType(url + "#foo", CHROME_PROCESS), chromeResult, "Check URL with ref in chrome process."); is(E10SUtils.canLoadURIInRemoteType(url + "#foo", WEB_CONTENT_PROCESS), webContentResult, "Check URL with ref in web content process."); + is(E10SUtils.canLoadURIInRemoteType(url + "#foo", PRIVILEGED_CONTENT_PROCESS), + privilegedContentResult, "Check URL with ref in privileged content process."); is(E10SUtils.canLoadURIInRemoteType(url + "?foo", CHROME_PROCESS), chromeResult, "Check URL with query in chrome process."); is(E10SUtils.canLoadURIInRemoteType(url + "?foo", WEB_CONTENT_PROCESS), webContentResult, "Check URL with query in web content process."); + is(E10SUtils.canLoadURIInRemoteType(url + "?foo", PRIVILEGED_CONTENT_PROCESS), + privilegedContentResult, "Check URL with query in privileged content process."); is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", CHROME_PROCESS), chromeResult, "Check URL with query and ref in chrome process."); is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", WEB_CONTENT_PROCESS), webContentResult, "Check URL with query and ref in web content process."); + is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", PRIVILEGED_CONTENT_PROCESS), + privilegedContentResult, "Check URL with query and ref in privileged content process."); } add_task(async function test_chrome() { - test_url("about:" + CHROME.path, true, false); + test_url("about:" + CHROME.path, true, false, false); }); add_task(async function test_any() { - test_url("about:" + CANREMOTE.path, true, true); + test_url("about:" + CANREMOTE.path, true, true, false); }); add_task(async function test_remote() { - test_url("about:" + MUSTREMOTE.path, false, true); + test_url("about:" + MUSTREMOTE.path, false, true, false); +}); + +add_task(async function test_privileged_remote_true() { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.tabs.remote.separatePrivilegedContentProcess", true], + ], + }); + + // This shouldn't be taken literally. We will always use the privileged + // content type if the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag is enabled and + // the pref is turned on. + test_url("about:" + CANPRIVILEGEDREMOTE.path, false, false, true); +}); + +add_task(async function test_privileged_remote_false() { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.tabs.remote.separatePrivilegedContentProcess", false], + ], + }); + + // This shouldn't be taken literally. We will always use the privileged + // content type if the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag is enabled and + // the pref is turned on. + test_url("about:" + CANPRIVILEGEDREMOTE.path, false, true, false); });