summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/favicons/test_page-icon_protocol.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/places/tests/favicons/test_page-icon_protocol.js')
-rw-r--r--toolkit/components/places/tests/favicons/test_page-icon_protocol.js62
1 files changed, 58 insertions, 4 deletions
diff --git a/toolkit/components/places/tests/favicons/test_page-icon_protocol.js b/toolkit/components/places/tests/favicons/test_page-icon_protocol.js
index 932040bafb..287484868f 100644
--- a/toolkit/components/places/tests/favicons/test_page-icon_protocol.js
+++ b/toolkit/components/places/tests/favicons/test_page-icon_protocol.js
@@ -185,11 +185,11 @@ add_task(async function page_content_process() {
let img = content.document.createElement("img");
img.src = url;
let imgPromise = new Promise((resolve, reject) => {
- img.addEventListener("error", e => {
+ img.addEventListener("error", () => {
Assert.ok(true, "Got expected load error.");
resolve();
});
- img.addEventListener("load", e => {
+ img.addEventListener("load", () => {
Assert.ok(false, "Did not expect a successful load.");
reject();
});
@@ -225,11 +225,11 @@ add_task(async function page_privileged_about_content_process() {
let img = content.document.createElement("img");
img.src = url;
let imgPromise = new Promise((resolve, reject) => {
- img.addEventListener("error", e => {
+ img.addEventListener("error", () => {
Assert.ok(false, "Did not expect an error. ");
reject();
});
- img.addEventListener("load", e => {
+ img.addEventListener("load", () => {
Assert.ok(true, "Got expected load event.");
resolve();
});
@@ -241,3 +241,57 @@ add_task(async function page_privileged_about_content_process() {
await contentPage.close();
});
+
+add_task(async function test_with_user_pass() {
+ info("Test whether can get favicon content regardless of user pass");
+ await PlacesUtils.history.clear();
+
+ const PAGE_NORMAL = uri("http://mozilla.org/");
+ const PAGE_USERPASS = uri("http://user:pass@mozilla.org/");
+ const ICON_NORMAL = uri("http://mozilla.org/favicon.png");
+ const ICON_USERPASS = uri("http://user:pass@mozilla.org/favicon.png");
+ const PAGE_ICON_NORMAL = "page-icon:http://mozilla.org/";
+ const PAGE_ICON_USERPASS = "page-icon:http://user:pass@mozilla.org/";
+
+ const testData = [
+ {
+ pageURI: PAGE_USERPASS,
+ iconURI: ICON_NORMAL,
+ },
+ {
+ pageURI: PAGE_NORMAL,
+ iconURI: ICON_USERPASS,
+ },
+ {
+ pageURI: PAGE_USERPASS,
+ iconURI: ICON_USERPASS,
+ },
+ ];
+
+ for (const { pageURI, iconURI } of testData) {
+ for (const loadingIconURISpec of [PAGE_ICON_NORMAL, PAGE_ICON_USERPASS]) {
+ PlacesUtils.favicons.replaceFaviconDataFromDataURL(
+ iconURI,
+ ICON_DATAURL,
+ 0,
+ systemPrincipal
+ );
+ await PlacesTestUtils.addVisits(pageURI);
+ await new Promise(resolve => {
+ PlacesUtils.favicons.setAndFetchFaviconForPage(
+ pageURI,
+ iconURI,
+ false,
+ PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
+ resolve,
+ Services.scriptSecurityManager.getSystemPrincipal()
+ );
+ });
+
+ let { data, contentType } = await fetchIconForSpec(loadingIconURISpec);
+ Assert.equal(contentType, gFavicon.contentType);
+ Assert.deepEqual(data, gFavicon.data, "Got the favicon data");
+ await PlacesUtils.history.clear();
+ }
+ }
+});