Backed out 8 changesets (bug 1277803) for browser-chrome test failures a=backout

Backed out changeset 477890efdb88 (bug 1277803)
Backed out changeset 49da326bfe68 (bug 1277803)
Backed out changeset 2d17a40a9077 (bug 1277803)
Backed out changeset b1cb0a195ca1 (bug 1277803)
Backed out changeset c7d82459d152 (bug 1277803)
Backed out changeset 3be9a06248af (bug 1277803)
Backed out changeset 8d119ca96999 (bug 1277803)
Backed out changeset be767a6f7ecd (bug 1277803)
This commit is contained in:
Wes Kocher 2016-10-12 14:26:00 -07:00
parent 3770ad1b24
commit 2142de26c1
41 changed files with 25 additions and 1157 deletions

View File

@ -6453,7 +6453,7 @@
class="tab-throbber"
role="presentation"
layer="true" />
<xul:image xbl:inherits="src=image,loadingprincipal=iconLoadingPrincipal,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
<xul:image xbl:inherits="src=image,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
anonid="tab-icon-image"
class="tab-icon-image"
validate="never"

View File

@ -22,7 +22,7 @@ function getIconFile() {
NetUtil.asyncFetch({
uri: "http://www.example.com/browser/browser/components/contextualidentity/test/browser/favicon-normal32.png",
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
}, function(inputStream, status) {
let size = inputStream.available();
gFaviconData = NetUtil.readInputStreamToString(inputStream, size);

View File

@ -3,12 +3,6 @@ skip-if = buildapp == "mulet"
tags = usercontextid firstpartyisolation originattributes
support-files =
dummy.html
file_favicon.html
file_favicon.png
file_favicon.png^headers^
file_favicon_cache.html
file_favicon_cache.png
file_favicon_thirdParty.html
file_firstPartyBasic.html
file_sharedworker.html
file_sharedworker.js
@ -30,8 +24,6 @@ support-files =
worker_blobify.js
worker_deblobify.js
[browser_favicon_firstParty.js]
[browser_favicon_userContextId.js]
[browser_firstPartyIsolation.js]
[browser_localStorageIsolation.js]
[browser_blobURLIsolation.js]

View File

@ -1,334 +0,0 @@
/**
* Bug 1277803 - A test case for testing favicon loading across different first party domains.
*/
const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/PlacesUtils.jsm");
const FIRST_PARTY_ONE = "example.com";
const FIRST_PARTY_TWO = "example.org";
const THIRD_PARTY = "mochi.test:8888";
const TEST_SITE_ONE = "http://" + FIRST_PARTY_ONE;
const TEST_SITE_TWO = "http://" + FIRST_PARTY_TWO;
const THIRD_PARTY_SITE = "http://" + THIRD_PARTY;
const TEST_DIRECTORY = "/browser/browser/components/originattributes/test/browser/";
const TEST_PAGE = TEST_DIRECTORY + "file_favicon.html";
const TEST_THIRD_PARTY_PAGE = TEST_DIRECTORY + "file_favicon_thirdParty.html";
const TEST_CACHE_PAGE = TEST_DIRECTORY + "file_favicon_cache.html";
const FAVICON_URI = TEST_DIRECTORY + "file_favicon.png";
const TEST_FAVICON_CACHE_URI = TEST_DIRECTORY + "file_favicon_cache.png";
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
let makeURI = Cu.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
function clearAllImageCaches() {
let tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
.getService(SpecialPowers.Ci.imgITools);
let imageCache = tools.getImgCacheForDocument(window.document);
imageCache.clearCache(true); // true=chrome
imageCache.clearCache(false); // false=content
}
function clearAllPlacesFavicons() {
let faviconService = Cc["@mozilla.org/browser/favicon-service;1"]
.getService(Ci.nsIFaviconService);
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
if (aTopic === "places-favicons-expired") {
resolve();
Services.obs.removeObserver(observer, "places-favicons-expired", false);
}
}
};
Services.obs.addObserver(observer, "places-favicons-expired", false);
faviconService.expireAllFavicons();
});
}
function observeFavicon(aFirstPartyDomain, aExpectedCookie, aPageURI) {
let faviconReqXUL = false;
let faviconReqPlaces = false;
let expectedPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(aPageURI, { firstPartyDomain: aFirstPartyDomain });
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
// Make sure that the topic is 'http-on-modify-request'.
if (aTopic === "http-on-modify-request") {
// We check the firstPartyDomain for the originAttributes of the loading
// channel. All requests for the favicon should contain the correct
// firstPartyDomain. There are two requests for a favicon loading, one
// from the Places library and one from the XUL image. The difference
// of them is the loading principal. The Places will use the content
// principal and the XUL image will use the system principal.
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
let reqLoadInfo = httpChannel.loadInfo;
let loadingPrincipal = reqLoadInfo.loadingPrincipal;
let triggeringPrincipal = reqLoadInfo.triggeringPrincipal;
// Make sure this is a favicon request.
if (!httpChannel.URI.spec.endsWith(FAVICON_URI)) {
return;
}
// Check the first party domain.
is(reqLoadInfo.originAttributes.firstPartyDomain, aFirstPartyDomain,
"The loadInfo has correct first party domain");
if (loadingPrincipal.equals(systemPrincipal)) {
faviconReqXUL = true;
ok(triggeringPrincipal.equals(expectedPrincipal),
"The triggeringPrincipal of favicon loading from XUL should be the content principal.");
} else {
faviconReqPlaces = true;
ok(loadingPrincipal.equals(expectedPrincipal),
"The loadingPrincipal of favicon loading from Places should be the content prinicpal");
}
let faviconCookie = httpChannel.getRequestHeader("cookie");
is(faviconCookie, aExpectedCookie, "The cookie of the favicon loading is correct.");
} else {
ok(false, "Received unexpected topic: ", aTopic);
}
if (faviconReqXUL && faviconReqPlaces) {
Services.obs.removeObserver(observer, "http-on-modify-request", false);
resolve();
}
}
};
Services.obs.addObserver(observer, "http-on-modify-request", false);
});
}
function waitOnFaviconResponse(aFaviconURL) {
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
if (aTopic === "http-on-examine-response" ||
aTopic === "http-on-examine-cached-response") {
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
let loadInfo = httpChannel.loadInfo;
if (httpChannel.URI.spec !== aFaviconURL) {
return;
}
let result = {
topic: aTopic,
firstPartyDomain: loadInfo.originAttributes.firstPartyDomain
};
resolve(result);
Services.obs.removeObserver(observer, "http-on-examine-response", false);
Services.obs.removeObserver(observer, "http-on-examine-cached-response", false);
}
}
};
Services.obs.addObserver(observer, "http-on-examine-response", false);
Services.obs.addObserver(observer, "http-on-examine-cached-response", false);
});
}
function waitOnFaviconLoaded(aFaviconURL) {
return new Promise(resolve => {
let observer = {
onPageChanged(uri, attr, value, id) {
if (attr === Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON &&
value === aFaviconURL) {
resolve();
PlacesUtils.history.removeObserver(observer, false);
}
},
};
PlacesUtils.history.addObserver(observer, false);
});
}
function* openTab(aURL) {
let tab = gBrowser.addTab(aURL);
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
yield BrowserTestUtils.browserLoaded(browser);
return {tab, browser};
}
function* assignCookiesUnderFirstParty(aURL, aFirstParty, aCookieValue) {
// Open a tab under the given aFirstParty, and this tab will have an
// iframe which loads the aURL.
let tabInfo = yield openTabInFirstParty(aURL, aFirstParty);
// Add cookies into the iframe.
yield ContentTask.spawn(tabInfo.browser, aCookieValue, function* (value) {
content.document.cookie = value;
});
yield BrowserTestUtils.removeTab(tabInfo.tab);
}
function* generateCookies(aThirdParty) {
// we generate two different cookies for two first party domains.
let cookies = [];
cookies.push(Math.random().toString());
cookies.push(Math.random().toString());
let firstSiteURL;
let secondSiteURL;
if (aThirdParty) {
// Add cookies into the third party site with different first party domain.
firstSiteURL = THIRD_PARTY_SITE;
secondSiteURL = THIRD_PARTY_SITE;
} else {
// Add cookies into sites.
firstSiteURL = TEST_SITE_ONE;
secondSiteURL = TEST_SITE_TWO;
}
yield assignCookiesUnderFirstParty(firstSiteURL, TEST_SITE_ONE, cookies[0]);
yield assignCookiesUnderFirstParty(secondSiteURL, TEST_SITE_TWO, cookies[1]);
return cookies;
}
function* doTest(aTestPage, aExpectedCookies, aFaviconURL) {
let firstPageURI = makeURI(TEST_SITE_ONE + aTestPage);
let secondPageURI = makeURI(TEST_SITE_TWO + aTestPage);
// Start to observer the event of that favicon has been fully loaded.
let promiseFaviconLoaded = waitOnFaviconLoaded(aFaviconURL);
// Open the tab for the first site.
let tabInfo = yield openTab(TEST_SITE_ONE + aTestPage);
// Waiting until favicon requests are all made.
yield observeFavicon(FIRST_PARTY_ONE, aExpectedCookies[0], firstPageURI);
// Waiting until favicon loaded.
yield promiseFaviconLoaded;
// Close the tab.
yield BrowserTestUtils.removeTab(tabInfo.tab);
// Open the tab for the second site.
tabInfo = yield openTab(TEST_SITE_TWO + aTestPage);
// Waiting until favicon requests are all made.
yield observeFavicon(FIRST_PARTY_TWO, aExpectedCookies[1], secondPageURI);
yield BrowserTestUtils.removeTab(tabInfo.tab);
}
add_task(function* setup() {
// Make sure first party isolation is enabled.
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.firstparty.isolate", true]
]});
});
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
});
add_task(function* test_favicon_firstParty() {
for (let testThirdParty of [false, true]) {
// Clear all image caches and network caches before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Clear Places favicon caches.
yield clearAllPlacesFavicons();
let cookies = yield generateCookies(testThirdParty);
if (testThirdParty) {
yield doTest(TEST_THIRD_PARTY_PAGE, cookies, THIRD_PARTY_SITE + FAVICON_URI);
} else {
yield doTest(TEST_PAGE, cookies, TEST_SITE_ONE + FAVICON_URI);
}
}
});
add_task(function* test_favicon_cache_firstParty() {
// Clear all image caches and network caches before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Open the tab for the first site.
let tabInfoA = yield openTab(TEST_SITE_ONE + TEST_CACHE_PAGE);
// Start to observer the event of that favicon has been fully loaded and cached.
let promiseForFaviconLoaded = waitOnFaviconLoaded(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
// Wait for the favicon response of the first tab.
let response = yield waitOnFaviconResponse(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
// Make sure the favicon is loaded through the network and its first party domain is correct.
is(response.topic, "http-on-examine-response", "The favicon image should be loaded through network.");
is(response.firstPartyDomain, FIRST_PARTY_ONE, "We should only observe the network response for the first first party.");
// Waiting until the favicon has been loaded and cached.
yield promiseForFaviconLoaded;
// Open the tab again for checking the image cache is working correctly.
let tabInfoB = yield openTab(TEST_SITE_ONE + TEST_CACHE_PAGE);
// Start to observe the favicon response, the second tab actually will not
// make any network request since the favicon will be loaded by the cache for
// both Places and XUL image. So here, we are going to observe the favicon
// response for the third tab which opens with the second first party.
let promiseForFaviconResponse = waitOnFaviconResponse(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
// Open the tab for the second site.
let tabInfoC = yield openTab(TEST_SITE_TWO + TEST_CACHE_PAGE);
// Wait for the favicon response. In this case, we suppose to catch the
// response for the third tab but not the second tab since it will not
// go through the network.
response = yield promiseForFaviconResponse;
// Check that the favicon response has came from the network and it has the
// correct first party domain.
is(response.topic, "http-on-examine-response", "The favicon image should be loaded through network again.");
is(response.firstPartyDomain, FIRST_PARTY_TWO, "We should only observe the network response for the second first party.");
yield BrowserTestUtils.removeTab(tabInfoA.tab);
yield BrowserTestUtils.removeTab(tabInfoB.tab);
yield BrowserTestUtils.removeTab(tabInfoC.tab);
});

View File

@ -1,250 +0,0 @@
/**
* Bug 1277803 - A test caes for testing favicon loading across different userContextId.
*/
const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
const TEST_SITE = "http://mochi.test:8888";
const TEST_PAGE = TEST_SITE + "/browser/browser/components/originattributes/" +
"test/browser/file_favicon.html";
const FAVICON_URI = TEST_SITE + "/browser/browser/components/originattributes/" +
"test/browser/file_favicon.png";
const TEST_THIRD_PARTY_PAGE = "http://example.com/browser/browser/components/" +
"originattributes/test/browser/file_favicon_thirdParty.html";
const USER_CONTEXT_ID_PERSONAL = 1;
const USER_CONTEXT_ID_WORK = 2;
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
let makeURI = Cu.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
function clearAllImageCaches() {
var tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
.getService(SpecialPowers.Ci.imgITools);
var imageCache = tools.getImgCacheForDocument(window.document);
imageCache.clearCache(true); // true=chrome
imageCache.clearCache(false); // false=content
}
function clearAllPlacesFavicons() {
let faviconService = Cc["@mozilla.org/browser/favicon-service;1"]
.getService(Ci.nsIFaviconService);
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
if (aTopic === "places-favicons-expired") {
resolve();
Services.obs.removeObserver(observer, "places-favicons-expired", false);
}
}
};
Services.obs.addObserver(observer, "places-favicons-expired", false);
faviconService.expireAllFavicons();
});
}
function FaviconObserver(aUserContextId, aExpectedCookie, aPageURI) {
this.reset(aUserContextId, aExpectedCookie, aPageURI);
}
FaviconObserver.prototype = {
observe(aSubject, aTopic, aData) {
// Make sure that the topic is 'http-on-modify-request'.
if (aTopic === "http-on-modify-request") {
// We check the userContextId for the originAttributes of the loading
// channel. All requests for the favicon should contain the correct
// userContextId. There are two requests for a favicon loading, one
// from the Places library and one from the XUL image. The difference
// of them is the loading principal. The Places will use the content
// principal and the XUL image will use the system principal.
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
let reqLoadInfo = httpChannel.loadInfo;
let loadingPrincipal;
let triggeringPrincipal;
// Make sure this is a favicon request.
if (httpChannel.URI.spec !== FAVICON_URI) {
return;
}
if (reqLoadInfo) {
loadingPrincipal = reqLoadInfo.loadingPrincipal;
triggeringPrincipal = reqLoadInfo.triggeringPrincipal;
}
// Check the userContextId.
is(reqLoadInfo.originAttributes.userContextId, this._curUserContextId,
"The loadInfo has correct userContextId");
if (loadingPrincipal.equals(systemPrincipal)) {
this._faviconReqXUL = true;
ok(triggeringPrincipal.equals(this._expectedPrincipal),
"The triggeringPrincipal of favicon loading from XUL should be the content principal.");
} else {
this._faviconReqPlaces = true;
ok(loadingPrincipal.equals(this._expectedPrincipal),
"The loadingPrincipal of favicon loading from Places should be the content prinicpal");
}
let faviconCookie = httpChannel.getRequestHeader("cookie");
is(faviconCookie, this._expectedCookie, "The cookie of the favicon loading is correct.");
} else {
ok(false, "Received unexpected topic: ", aTopic);
}
if (this._faviconReqXUL && this._faviconReqPlaces) {
this._faviconLoaded.resolve();
}
},
reset(aUserContextId, aExpectedCookie, aPageURI) {
this._curUserContextId = aUserContextId;
this._expectedCookie = aExpectedCookie;
this._expectedPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(aPageURI, { userContextId: aUserContextId });
this._faviconReqXUL = false;
this._faviconReqPlaces = false;
this._faviconLoaded = new Promise.defer();
},
get promise() {
return this._faviconLoaded.promise;
}
};
function waitOnFaviconLoaded(aFaviconURL) {
return new Promise(resolve => {
let observer = {
onPageChanged(uri, attr, value, id) {
if (attr === Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON &&
value === aFaviconURL) {
resolve();
PlacesUtils.history.removeObserver(observer, false);
}
},
};
PlacesUtils.history.addObserver(observer, false);
});
}
function* generateCookies() {
// we generate two different cookies for two userContextIds.
let cookies = [];
cookies.push(Math.random().toString());
cookies.push(Math.random().toString());
// Then, we add cookies into the site for 'personal' and 'work'.
let tabInfoA = yield openTabInUserContext(TEST_SITE, USER_CONTEXT_ID_PERSONAL);
let tabInfoB = yield openTabInUserContext(TEST_SITE, USER_CONTEXT_ID_WORK);
yield ContentTask.spawn(tabInfoA.browser, cookies[0], function* (value) {
content.document.cookie = value;
});
yield ContentTask.spawn(tabInfoB.browser, cookies[1], function* (value) {
content.document.cookie = value;
});
yield BrowserTestUtils.removeTab(tabInfoA.tab);
yield BrowserTestUtils.removeTab(tabInfoB.tab);
return cookies;
}
function* doTest(aTestPage) {
let cookies = yield generateCookies();
let pageURI = makeURI(aTestPage);
// Create the observer object for observing request channels of the personal
// container.
let observer = new FaviconObserver(USER_CONTEXT_ID_PERSONAL, cookies[0], pageURI);
Services.obs.addObserver(observer, "http-on-modify-request", false);
// Open the tab with the personal container.
let tabInfo = yield openTabInUserContext(aTestPage, USER_CONTEXT_ID_PERSONAL);
// Waiting for favicon requests are all made.
yield observer.promise;
// Waiting for favicon loaded.
yield waitOnFaviconLoaded(FAVICON_URI);
// Close the tab.
yield BrowserTestUtils.removeTab(tabInfo.tab);
// Reset the observer for observing requests for the work container.
observer.reset(USER_CONTEXT_ID_WORK, cookies[1], pageURI);
tabInfo = yield openTabInUserContext(aTestPage, USER_CONTEXT_ID_WORK);
// Waiting for favicon requests are all made.
yield observer.promise;
Services.obs.removeObserver(observer, "http-on-modify-request", false);
yield BrowserTestUtils.removeTab(tabInfo.tab);
}
add_task(function* setup() {
// Make sure userContext is enabled.
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
});
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Clear Places favicon caches.
clearAllPlacesFavicons();
});
add_task(function* test_favicon_userContextId() {
// Clear all image caches before running the test.
clearAllImageCaches();
// Clear all network caches.
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Clear Places favicon caches.
yield clearAllPlacesFavicons();
yield doTest(TEST_PAGE);
});
add_task(function* test_thirdPartyFavicon_userContextId() {
// Clear all image caches before running the test.
clearAllImageCaches();
// Clear all network caches.
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Clear Places favicon caches.
yield clearAllPlacesFavicons();
yield doTest(TEST_THIRD_PARTY_PAGE);
});

View File

@ -1,11 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Favicon Test for originAttributes</title>
<link rel="icon" type="image/png" href="file_favicon.png" />
</head>
<body>
Favicon!!
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

View File

@ -1 +0,0 @@
Cache-Control: no-cache

View File

@ -1,11 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Favicon Test for originAttributes</title>
<link rel="icon" type="image/png" href="http://mochi.test:8888/browser/browser/components/originattributes/test/browser/file_favicon_cache.png" />
</head>
<body>
Third Party Favicon!!
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

View File

@ -1,11 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Favicon Test for originAttributes</title>
<link rel="icon" type="image/png" href="http://mochi.test:8888/browser/browser/components/originattributes/test/browser/file_favicon.png" />
</head>
<body>
Third Party Favicon!!
</body>
</html>

View File

@ -15,9 +15,6 @@ support-files =
popup.html
title.sjs
empty_file.html
file_favicon.html
file_favicon.png
file_favicon.png^headers^
[browser_privatebrowsing_DownloadLastDirWithCPS.js]
[browser_privatebrowsing_about.js]
@ -32,7 +29,6 @@ tags = trackingprotection
[browser_privatebrowsing_downloadLastDir.js]
[browser_privatebrowsing_downloadLastDir_c.js]
[browser_privatebrowsing_downloadLastDir_toggle.js]
[browser_privatebrowsing_favicon.js]
[browser_privatebrowsing_geoprompt.js]
[browser_privatebrowsing_lastpbcontextexited.js]
[browser_privatebrowsing_localStorage.js]

View File

@ -1,290 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This test make sure that the favicon of the private browsing is isolated.
const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
const TEST_SITE = "http://mochi.test:8888";
const TEST_DIRECTORY = "/browser/browser/components/privatebrowsing/test/browser/";
const TEST_PAGE = TEST_SITE + TEST_DIRECTORY + "file_favicon.html";
const FAVICON_URI = TEST_SITE + TEST_DIRECTORY + "file_favicon.png";
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
let makeURI = Cu.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
function clearAllImageCaches() {
let tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
.getService(SpecialPowers.Ci.imgITools);
let imageCache = tools.getImgCacheForDocument(window.document);
imageCache.clearCache(true); // true=chrome
imageCache.clearCache(false); // false=content
}
function clearAllPlacesFavicons() {
let faviconService = Cc["@mozilla.org/browser/favicon-service;1"]
.getService(Ci.nsIFaviconService);
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
if (aTopic === "places-favicons-expired") {
resolve();
Services.obs.removeObserver(observer, "places-favicons-expired", false);
}
}
};
Services.obs.addObserver(observer, "places-favicons-expired", false);
faviconService.expireAllFavicons();
});
}
function observeFavicon(aIsPrivate, aExpectedCookie, aPageURI) {
let faviconReqXUL = false;
let faviconReqPlaces = false;
let attr = {};
if (aIsPrivate) {
attr.privateBrowsingId = 1;
}
let expectedPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(aPageURI, attr);
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
// Make sure that the topic is 'http-on-modify-request'.
if (aTopic === "http-on-modify-request") {
// We check the privateBrowsingId for the originAttributes of the loading
// channel. All requests for the favicon should contain the correct
// privateBrowsingId. There are two requests for a favicon loading, one
// from the Places library and one from the XUL image. The difference
// of them is the loading principal. The Places will use the content
// principal and the XUL image will use the system principal.
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
let reqLoadInfo = httpChannel.loadInfo;
let loadingPrincipal = reqLoadInfo.loadingPrincipal;
let triggeringPrincipal = reqLoadInfo.triggeringPrincipal;
// Make sure this is a favicon request.
if (httpChannel.URI.spec !== FAVICON_URI) {
return;
}
// Check the privateBrowsingId.
if (aIsPrivate) {
is(reqLoadInfo.originAttributes.privateBrowsingId, 1, "The loadInfo has correct privateBrowsingId");
} else {
is(reqLoadInfo.originAttributes.privateBrowsingId, 0, "The loadInfo has correct privateBrowsingId");
}
if (loadingPrincipal.equals(systemPrincipal)) {
faviconReqXUL = true;
ok(triggeringPrincipal.equals(expectedPrincipal),
"The triggeringPrincipal of favicon loading from XUL should be the content principal.");
} else {
faviconReqPlaces = true;
ok(loadingPrincipal.equals(expectedPrincipal),
"The loadingPrincipal of favicon loading from Places should be the content prinicpal");
}
let faviconCookie = httpChannel.getRequestHeader("cookie");
is(faviconCookie, aExpectedCookie, "The cookie of the favicon loading is correct.");
} else {
ok(false, "Received unexpected topic: ", aTopic);
}
if (faviconReqXUL && faviconReqPlaces) {
resolve();
Services.obs.removeObserver(observer, "http-on-modify-request", false);
}
}
};
Services.obs.addObserver(observer, "http-on-modify-request", false);
});
}
function waitOnFaviconResponse(aFaviconURL) {
return new Promise(resolve => {
let observer = {
observe(aSubject, aTopic, aData) {
if (aTopic === "http-on-examine-response" ||
aTopic === "http-on-examine-cached-response") {
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
let loadInfo = httpChannel.loadInfo;
if (httpChannel.URI.spec !== aFaviconURL) {
return;
}
let result = {
topic: aTopic,
privateBrowsingId: loadInfo.originAttributes.privateBrowsingId
};
resolve(result);
Services.obs.removeObserver(observer, "http-on-examine-response", false);
Services.obs.removeObserver(observer, "http-on-examine-cached-response", false);
}
}
};
Services.obs.addObserver(observer, "http-on-examine-response", false);
Services.obs.addObserver(observer, "http-on-examine-cached-response", false);
});
}
function waitOnFaviconLoaded(aFaviconURL) {
return new Promise(resolve => {
let observer = {
onPageChanged(uri, attr, value, id) {
if (attr === Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON &&
value === aFaviconURL) {
resolve();
PlacesUtils.history.removeObserver(observer, false);
}
},
};
PlacesUtils.history.addObserver(observer, false);
});
}
function* assignCookies(aBrowser, aURL, aCookieValue){
let tabInfo = yield openTab(aBrowser, aURL);
yield ContentTask.spawn(tabInfo.browser, aCookieValue, function* (value) {
content.document.cookie = value;
});
yield BrowserTestUtils.removeTab(tabInfo.tab);
}
function* openTab(aBrowser, aURL) {
let tab = aBrowser.addTab(aURL);
// Select tab and make sure its browser is focused.
aBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = aBrowser.getBrowserForTab(tab);
yield BrowserTestUtils.browserLoaded(browser);
return {tab, browser};
}
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
});
add_task(function* test_favicon_privateBrowsing() {
// Clear all image caches before running the test.
clearAllImageCaches();
// Clear all favicons in Places.
yield clearAllPlacesFavicons();
// Create a private browsing window.
let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
let pageURI = makeURI(TEST_PAGE);
// Generate two random cookies for non-private window and private window
// respectively.
let cookies = [];
cookies.push(Math.random().toString());
cookies.push(Math.random().toString());
// Open a tab in private window and add a cookie into it.
yield assignCookies(privateWindow.gBrowser, TEST_SITE, cookies[0]);
// Open a tab in non-private window and add a cookie into it.
yield assignCookies(gBrowser, TEST_SITE, cookies[1]);
// Add the observer earlier in case we don't capture events in time.
let promiseObserveFavicon = observeFavicon(true, cookies[0], pageURI);
// Open a tab for the private window.
let tabInfo = yield openTab(privateWindow.gBrowser, TEST_PAGE);
// Waiting until favicon requests are all made.
yield promiseObserveFavicon;
// Close the tab.
yield BrowserTestUtils.removeTab(tabInfo.tab);
// Add the observer earlier in case we don't capture events in time.
promiseObserveFavicon = observeFavicon(false, cookies[1], pageURI);
// Open a tab for the non-private window.
tabInfo = yield openTab(gBrowser, TEST_PAGE);
// Waiting until favicon requests are all made.
yield promiseObserveFavicon;
// Close the tab.
yield BrowserTestUtils.removeTab(tabInfo.tab);
yield BrowserTestUtils.closeWindow(privateWindow);
});
add_task(function* test_favicon_cache_privateBrowsing() {
// Clear all image cahces and network cache before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
// Clear all favicons in Places.
yield clearAllPlacesFavicons();
// Create a private browsing window.
let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
// Add an observer for making sure the favicon has been loaded and cached.
let promiseFaviconLoaded = waitOnFaviconLoaded(FAVICON_URI);
// Open a tab for the non-private window.
let tabInfoNonPrivate = yield openTab(gBrowser, TEST_PAGE);
let response = yield waitOnFaviconResponse(FAVICON_URI);
yield promiseFaviconLoaded;
// Check that the favicon response has come from the network and it has the
// correct privateBrowsingId.
is(response.topic, "http-on-examine-response", "The favicon image should be loaded through network.");
is(response.privateBrowsingId, 0, "We should observe the network response for the non-private tab.");
// Open a tab for the private window.
let tabInfoPrivate = yield openTab(privateWindow.gBrowser, TEST_PAGE);
// Wait for the favicon response of the private tab.
response = yield waitOnFaviconResponse(FAVICON_URI);
// Make sure the favicon is loaded through the network and its privateBrowsingId is correct.
is(response.topic, "http-on-examine-response", "The favicon image should be loaded through the network again.");
is(response.privateBrowsingId, 1, "We should observe the network response for the private tab.");
yield BrowserTestUtils.removeTab(tabInfoPrivate.tab);
yield BrowserTestUtils.removeTab(tabInfoNonPrivate.tab);
yield BrowserTestUtils.closeWindow(privateWindow);
});

View File

@ -1,11 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Favicon Test for originAttributes</title>
<link rel="icon" type="image/png" href="file_favicon.png" />
</head>
<body>
Favicon!!
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

View File

@ -1 +0,0 @@
Cache-Control: no-cache

View File

@ -131,7 +131,6 @@ NS_CP_ContentTypeName(uint32_t contentType)
CASE_RETURN( TYPE_INTERNAL_SCRIPT_PRELOAD );
CASE_RETURN( TYPE_INTERNAL_IMAGE );
CASE_RETURN( TYPE_INTERNAL_IMAGE_PRELOAD );
CASE_RETURN( TYPE_INTERNAL_IMAGE_FAVICON );
CASE_RETURN( TYPE_INTERNAL_STYLESHEET );
CASE_RETURN( TYPE_INTERNAL_STYLESHEET_PRELOAD );
default:

View File

@ -8418,7 +8418,6 @@ nsContentUtils::InternalContentPolicyTypeToExternal(nsContentPolicyType aType)
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON:
return nsIContentPolicy::TYPE_IMAGE;
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:

View File

@ -557,7 +557,6 @@ GK_ATOM(listing, "listing")
GK_ATOM(listitem, "listitem")
GK_ATOM(listrows, "listrows")
GK_ATOM(load, "load")
GK_ATOM(loadingprincipal, "loadingprincipal")
GK_ATOM(localedir, "localedir")
GK_ATOM(localName, "local-name")
GK_ATOM(longdesc, "longdesc")

View File

@ -321,14 +321,6 @@ interface nsIContentPolicyBase : nsISupports
*/
const nsContentPolicyType TYPE_INTERNAL_STYLESHEET_PRELOAD = 40;
/**
* Indicates an internal constant for favicon.
*
* This will be mapped to TYPE_IMAGE before being passed
* to content policy implementations.
*/
const nsContentPolicyType TYPE_INTERNAL_IMAGE_FAVICON = 41;
/* When adding new content types, please update nsContentBlocker,
* NS_CP_ContentTypeName, nsCSPContext, all nsIContentPolicy
* implementations, the static_assert in dom/cache/DBSchema.cpp,

View File

@ -292,8 +292,7 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 &&
nsIContentPolicy::TYPE_INTERNAL_IMAGE == 37 &&
nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD == 38 &&
nsIContentPolicy::TYPE_INTERNAL_STYLESHEET == 39 &&
nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD == 40 &&
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON == 41,
nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD == 40,
"nsContentPolicyType values are as expected");
namespace {

View File

@ -181,7 +181,6 @@ InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aConte
break;
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON:
context = RequestContext::Image;
break;
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:

View File

@ -45,7 +45,7 @@ namespace dom {
* frame | TYPE_INTERNAL_FRAME
* hyperlink |
* iframe | TYPE_INTERNAL_IFRAME
* image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD, TYPE_INTERNAL_IMAGE_FAVICON
* image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD
* imageset | TYPE_IMAGESET
* import | Not supported by Gecko
* internal | TYPE_DOCUMENT, TYPE_XBL, TYPE_OTHER

View File

@ -51,7 +51,6 @@ static bool IsImageLoadInEditorAppType(nsILoadInfo* aLoadInfo)
nsContentPolicyType type = aLoadInfo->InternalContentPolicyType();
if (type != nsIContentPolicy::TYPE_INTERNAL_IMAGE &&
type != nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD &&
type != nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON &&
type != nsIContentPolicy::TYPE_IMAGESET) {
return false;
}

View File

@ -1,11 +0,0 @@
<html>
<head>
<link rel='icon' href='favicon_bug1277803.ico'>
</head>
<body>
Nothing to see here...
</body>
</html>

View File

@ -1,7 +0,0 @@
[DEFAULT]
support-files =
favicon_bug1277803.ico
bug1277803.html
[test_bug1277803.xul]
skip-if = os == 'android'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,99 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Bug 1277803 test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="600"
height="600"
onload="runTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
</body>
<script type="application/javascript"><![CDATA[
SimpleTest.requestCompleteLog();
let Ci = Components.interfaces;
let Cc = Components.classes;
let Cu = Components.utils;
let makeURI = Cu.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
const BASE_URI = "http://mochi.test:8888/chrome/dom/security/test/general/";
const FAVICON_URI = BASE_URI + "favicon_bug1277803.ico";
const LOADING_URI = BASE_URI + "bug1277803.html";
let testWindow; //will be used to trigger favicon load
let securityManager = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
let expectedPrincipal = securityManager.createCodebasePrincipal(makeURI(LOADING_URI), {});
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance();
// We expect 2 favicon loads, one from PlacesUIUtils.loadFavicon and one
// from XUL:image loads.
let requestXUL = false;
let requestPlaces = false;
function runTest() {
// Register our observer to intercept favicon requests.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe: function(aSubject, aTopic, aData)
{
// Make sure this is a favicon request.
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
if (FAVICON_URI != httpChannel.URI.spec) {
return;
}
// Ensure the topic is the one we set an observer for.
is(aTopic, "http-on-modify-request", "Expected observer topic");
// Check for the correct loadingPrincipal, triggeringPrincipal.
let triggeringPrincipal = httpChannel.loadInfo.triggeringPrincipal;
let loadingPrincipal = httpChannel.loadInfo.loadingPrincipal;
if (loadingPrincipal.equals(systemPrincipal)) {
// This is the favicon loading from XUL, which will have the system
// principal as its loading principal and have a content principal
// as its triggering principal.
ok(triggeringPrincipal.equals(expectedPrincipal),
"Correct triggeringPrincipal for favicon from XUL.");
requestXUL = true;
} else if (loadingPrincipal.equals(expectedPrincipal)) {
// This is the favicon loading from Places, which will have a
// content principal as its loading principal and triggering
// principal.
ok(triggeringPrincipal.equals(expectedPrincipal),
"Correct triggeringPrincipal for favicon from Places.");
requestPlaces = true;
} else {
ok(false, "An unexpected favicon request.")
}
// Cleanup after ourselves...
if (requestXUL && requestPlaces) {
os.removeObserver(this, "http-on-modify-request");
SimpleTest.finish();
}
}
}
os.addObserver(observer, "http-on-modify-request", false);
// Now that the observer is set up, trigger a favicon load with navigation
testWindow = window.open(LOADING_URI);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.registerCleanupFunction(function() {
if (testWindow) {
testWindow.close();
}
});
]]></script>
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
</window>

View File

@ -22,7 +22,6 @@ MOCHITEST_MANIFESTS += [
MOCHITEST_CHROME_MANIFESTS += [
'csp/chrome.ini',
'general/chrome.ini',
]
BROWSER_CHROME_MANIFESTS += [

View File

@ -743,28 +743,14 @@ NewImageChannel(nsIChannel** aResult,
nullptr, // loadGroup
callbacks,
aLoadFlags);
if (NS_FAILED(rv)) {
return rv;
}
if (aPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
// If this is a favicon loading, we will use the originAttributes from the
// loadingPrincipal as the channel's originAttributes. This allows the favicon
// loading from XUL will use the correct originAttributes.
NeckoOriginAttributes neckoAttrs;
neckoAttrs.InheritFromDocToNecko(BasePrincipal::Cast(aLoadingPrincipal)->OriginAttributesRef());
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
rv = loadInfo->SetOriginAttributes(neckoAttrs);
}
} else {
// either we are loading something inside a document, in which case
// we should always have a requestingNode, or we are loading something
// outside a document, in which case the loadingPrincipal and
// triggeringPrincipal should always be the systemPrincipal.
// However, there are exceptions: one is Notifications which create a
// channel in the parent prcoess in which case we can't get a requestingNode.
// However, there are two exceptions: one is Notifications and the
// other one is Favicons which create a channel in the parent prcoess
// in which case we can't get a requestingNode.
rv = NS_NewChannel(aResult,
aURI,
nsContentUtils::GetSystemPrincipal(),

View File

@ -48,7 +48,6 @@
#include "nsIContent.h"
#include "nsContentUtils.h"
#include "nsSerializationHelper.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
@ -227,29 +226,6 @@ nsImageBoxFrame::UpdateImage()
if (mUseSrcAttr) {
nsIDocument* doc = mContent->GetComposedDoc();
if (doc) {
// Use the serialized loadingPrincipal from the image element. Fall back
// to mContent's principal (SystemPrincipal) if not available.
nsContentPolicyType contentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE;
nsCOMPtr<nsIPrincipal> loadingPrincipal = mContent->NodePrincipal();
nsAutoString imageLoadingPrincipal;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::loadingprincipal,
imageLoadingPrincipal);
if (!imageLoadingPrincipal.IsEmpty()) {
nsCOMPtr<nsISupports> serializedPrincipal;
NS_DeserializeObject(NS_ConvertUTF16toUTF8(imageLoadingPrincipal),
getter_AddRefs(serializedPrincipal));
loadingPrincipal = do_QueryInterface(serializedPrincipal);
if (loadingPrincipal) {
// Set the content policy type to TYPE_INTERNAL_IMAGE_FAVICON for
// indicating it's a favicon loading.
contentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON;
} else {
// Fallback if the deserialization is failed.
loadingPrincipal = mContent->NodePrincipal();
}
}
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
nsCOMPtr<nsIURI> uri;
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
@ -257,11 +233,10 @@ nsImageBoxFrame::UpdateImage()
doc,
baseURI);
if (uri) {
nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc, loadingPrincipal,
nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc, mContent->NodePrincipal(),
doc->GetDocumentURI(), doc->GetReferrerPolicy(),
mListener, mLoadFlags,
EmptyString(), getter_AddRefs(mImageRequest),
contentPolicyType);
EmptyString(), getter_AddRefs(mImageRequest));
if (NS_SUCCEEDED(rv) && mImageRequest) {
nsLayoutUtils::RegisterImageRequestIfAnimated(presContext,

View File

@ -2408,18 +2408,6 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
return NS_OK;
}
// We skip the favicon loading here. The favicon loading might be
// triggered by the XUL image. For that case, the loadContext will have
// default originAttributes since the XUL image uses SystemPrincipal, but
// the loadInfo will use originAttributes from the content. Thus, the
// originAttributes between loadInfo and loadContext will be different.
// That's why we have to skip the comparison for the favicon loading.
if (nsContentUtils::IsSystemPrincipal(loadInfo->LoadingPrincipal()) &&
loadInfo->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
return NS_OK;
}
uint32_t loadContextAppId = 0;
nsresult rv = loadContext->GetAppId(&loadContextAppId);
if (NS_FAILED(rv)) {

View File

@ -2664,33 +2664,18 @@ HttpBaseChannel::ShouldIntercept(nsIURI* aURI)
return shouldIntercept;
}
#ifdef DEBUG
void HttpBaseChannel::AssertPrivateBrowsingId()
void HttpBaseChannel::CheckPrivateBrowsing()
{
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(this, loadContext);
// For addons it's possible that mLoadInfo is null.
if (!mLoadInfo) {
return;
if (mLoadInfo && loadContext) {
DocShellOriginAttributes docShellAttrs;
loadContext->GetOriginAttributes(docShellAttrs);
MOZ_ASSERT(mLoadInfo->GetOriginAttributes().mPrivateBrowsingId == docShellAttrs.mPrivateBrowsingId,
"PrivateBrowsingId values are not the same between LoadInfo and LoadContext.");
}
if (!loadContext) {
return;
}
// We skip testing of favicon loading here since it could be triggered by XUL image
// which uses SystemPrincipal. The SystemPrincpal doesn't have mPrivateBrowsingId.
if (nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal()) &&
mLoadInfo->InternalContentPolicyType() == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
return;
}
DocShellOriginAttributes docShellAttrs;
loadContext->GetOriginAttributes(docShellAttrs);
MOZ_ASSERT(mLoadInfo->GetOriginAttributes().mPrivateBrowsingId == docShellAttrs.mPrivateBrowsingId,
"PrivateBrowsingId values are not the same between LoadInfo and LoadContext.");
}
#endif
//-----------------------------------------------------------------------------
// nsHttpChannel::nsITraceableChannel

View File

@ -382,10 +382,8 @@ protected:
// for a possible synthesized response instead.
bool ShouldIntercept(nsIURI* aURI = nullptr);
#ifdef DEBUG
// Check if mPrivateBrowsingId matches between LoadInfo and LoadContext.
void AssertPrivateBrowsingId();
#endif
void CheckPrivateBrowsing();
friend class PrivateBrowsingChannel<HttpBaseChannel>;
friend class InterceptFailedOnStop;

View File

@ -1796,7 +1796,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
LOG(("HttpChannelChild::AsyncOpen [this=%p uri=%s]\n", this, mSpec.get()));
#ifdef DEBUG
AssertPrivateBrowsingId();
CheckPrivateBrowsing();
#endif
if (mCanceled)

View File

@ -5659,7 +5659,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
NS_CompareLoadInfoAndLoadContext(this);
#ifdef DEBUG
AssertPrivateBrowsingId();
CheckPrivateBrowsing();
#endif
NS_ENSURE_ARG_POINTER(listener);

View File

@ -422,7 +422,7 @@ AsyncFetchAndSetIconForPage::FetchFromNetwork() {
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
nsILoadInfo::SEC_ALLOW_CHROME |
nsILoadInfo::SEC_DISALLOW_SCRIPT,
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON);
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInterfaceRequestor> listenerRequestor =

View File

@ -413,7 +413,7 @@ nsFaviconService::ReplaceFaviconDataFromDataURL(nsIURI* aFaviconURI,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
nsILoadInfo::SEC_ALLOW_CHROME |
nsILoadInfo::SEC_DISALLOW_SCRIPT,
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON);
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
nsCOMPtr<nsIChannel> channel;
rv = protocolHandler->NewChannel2(dataURI, loadInfo, getter_AddRefs(channel));

View File

@ -33,7 +33,7 @@ function test() {
NetUtil.asyncFetch({
uri: favIconLocation,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
}, function(inputStream, status) {
if (!Components.isSuccessCode(status)) {
ok(false, "Could not get the icon file");

View File

@ -62,7 +62,7 @@ function run_test()
let channel = NetUtil.newChannel({
uri: fs.defaultFavicon,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
});
channel.asyncOpen2(new streamListener("image/png"));
do_test_pending();
@ -72,7 +72,7 @@ function run_test()
channel = NetUtil.newChannel({
uri: moz_anno_favicon_prefix + "http://mozilla.org",
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
});
channel.asyncOpen2(new streamListener("image/png"));
do_test_pending();
@ -88,7 +88,7 @@ function run_test()
channel = NetUtil.newChannel({
uri: moz_anno_favicon_prefix + testURI.spec,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
});
channel.asyncOpen2(new streamListener("image/png"));
do_test_pending();

View File

@ -7,7 +7,7 @@ function fetchIconForSpec(spec) {
NetUtil.asyncFetch({
uri: NetUtil.newURI("page-icon:" + TEST_URI.spec),
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
}, (input, status, request) => {
if (!Components.isSuccessCode(status)) {
reject(new Error("unable to load icon"));