2017-02-02 18:40:03 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a dummy page, then open about:cache and verify the opened page shows up in the cache.
|
|
|
|
*/
|
|
|
|
add_task(async function() {
|
2020-05-21 08:41:50 +03:00
|
|
|
await SpecialPowers.pushPrefEnv({
|
|
|
|
set: [["privacy.partition.network_state", false]],
|
|
|
|
});
|
|
|
|
|
2017-02-02 18:40:03 +03:00
|
|
|
const kRoot = getRootDirectory(gTestPath).replace(
|
|
|
|
"chrome://mochitests/content/",
|
|
|
|
"https://example.com/"
|
|
|
|
);
|
|
|
|
const kTestPage = kRoot + "dummy.html";
|
|
|
|
// Open the dummy page to get it cached.
|
|
|
|
let tab = await BrowserTestUtils.openNewForegroundTab(
|
|
|
|
gBrowser,
|
|
|
|
kTestPage,
|
|
|
|
true
|
|
|
|
);
|
2018-03-19 05:16:45 +03:00
|
|
|
BrowserTestUtils.removeTab(tab);
|
2017-02-02 18:40:03 +03:00
|
|
|
|
|
|
|
tab = await BrowserTestUtils.openNewForegroundTab(
|
|
|
|
gBrowser,
|
|
|
|
"about:cache",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
let expectedPageCheck = function(uri) {
|
|
|
|
info("Saw load for " + uri);
|
|
|
|
// Can't easily use searchParms and new URL() because it's an about: URI...
|
|
|
|
return uri.startsWith("about:cache?") && uri.includes("storage=disk");
|
|
|
|
};
|
|
|
|
let diskPageLoaded = BrowserTestUtils.browserLoaded(
|
|
|
|
tab.linkedBrowser,
|
|
|
|
false,
|
|
|
|
expectedPageCheck
|
|
|
|
);
|
2019-12-13 23:36:16 +03:00
|
|
|
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
|
2017-02-02 18:40:03 +03:00
|
|
|
ok(
|
|
|
|
!content.document.nodePrincipal.isSystemPrincipal,
|
|
|
|
"about:cache should not have system principal"
|
|
|
|
);
|
2020-08-04 14:10:41 +03:00
|
|
|
let principal = content.document.nodePrincipal;
|
2018-05-22 02:58:23 +03:00
|
|
|
let channel = content.docShell.currentDocumentChannel;
|
2017-02-02 18:40:03 +03:00
|
|
|
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
|
|
|
|
is(
|
2020-08-04 14:10:41 +03:00
|
|
|
principal.spec,
|
2017-02-02 18:40:03 +03:00
|
|
|
content.document.location.href,
|
|
|
|
"Principal matches location"
|
|
|
|
);
|
|
|
|
let links = [...content.document.querySelectorAll("a[href*=disk]")];
|
|
|
|
is(links.length, 1, "Should have 1 link to the disk entries");
|
|
|
|
links[0].click();
|
|
|
|
});
|
|
|
|
await diskPageLoaded;
|
|
|
|
info("about:cache disk subpage loaded");
|
|
|
|
|
|
|
|
expectedPageCheck = function(uri) {
|
|
|
|
info("Saw load for " + uri);
|
|
|
|
return uri.startsWith("about:cache-entry") && uri.includes("dummy.html");
|
|
|
|
};
|
|
|
|
let triggeringURISpec = tab.linkedBrowser.currentURI.spec;
|
|
|
|
let entryLoaded = BrowserTestUtils.browserLoaded(
|
|
|
|
tab.linkedBrowser,
|
|
|
|
false,
|
|
|
|
expectedPageCheck
|
|
|
|
);
|
2019-12-13 23:36:24 +03:00
|
|
|
await SpecialPowers.spawn(tab.linkedBrowser, [kTestPage], function(
|
|
|
|
kTestPage
|
|
|
|
) {
|
2017-02-02 18:40:03 +03:00
|
|
|
ok(
|
|
|
|
!content.document.nodePrincipal.isSystemPrincipal,
|
|
|
|
"about:cache with query params should still not have system principal"
|
|
|
|
);
|
2020-08-04 14:10:41 +03:00
|
|
|
let principal = content.document.nodePrincipal;
|
2017-02-02 18:40:03 +03:00
|
|
|
is(
|
2020-08-04 14:10:41 +03:00
|
|
|
principal.spec,
|
2017-02-02 18:40:03 +03:00
|
|
|
content.document.location.href,
|
|
|
|
"Principal matches location"
|
|
|
|
);
|
2018-05-22 02:58:23 +03:00
|
|
|
let channel = content.docShell.currentDocumentChannel;
|
2020-08-04 14:10:41 +03:00
|
|
|
principal = channel.loadInfo.triggeringPrincipal;
|
2017-02-02 18:40:03 +03:00
|
|
|
is(
|
2020-08-04 14:10:41 +03:00
|
|
|
principal.spec,
|
2017-02-02 18:40:03 +03:00
|
|
|
"about:cache",
|
|
|
|
"Triggering principal matches previous location"
|
|
|
|
);
|
|
|
|
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
|
|
|
|
let links = [
|
|
|
|
...content.document.querySelectorAll("a[href*='" + kTestPage + "']"),
|
|
|
|
];
|
|
|
|
is(links.length, 1, "Should have 1 link to the entry for " + kTestPage);
|
|
|
|
links[0].click();
|
|
|
|
});
|
|
|
|
await entryLoaded;
|
|
|
|
info("about:cache entry loaded");
|
|
|
|
|
2019-12-13 23:36:16 +03:00
|
|
|
await SpecialPowers.spawn(tab.linkedBrowser, [triggeringURISpec], function(
|
2017-02-02 18:40:03 +03:00
|
|
|
triggeringURISpec
|
|
|
|
) {
|
|
|
|
ok(
|
|
|
|
!content.document.nodePrincipal.isSystemPrincipal,
|
|
|
|
"about:cache-entry should also not have system principal"
|
|
|
|
);
|
2020-08-04 14:10:41 +03:00
|
|
|
let principal = content.document.nodePrincipal;
|
2017-02-02 18:40:03 +03:00
|
|
|
is(
|
2020-08-04 14:10:41 +03:00
|
|
|
principal.spec,
|
2017-02-02 18:40:03 +03:00
|
|
|
content.document.location.href,
|
|
|
|
"Principal matches location"
|
|
|
|
);
|
2018-05-22 02:58:23 +03:00
|
|
|
let channel = content.docShell.currentDocumentChannel;
|
2020-08-04 14:10:41 +03:00
|
|
|
principal = channel.loadInfo.triggeringPrincipal;
|
2017-02-02 18:40:03 +03:00
|
|
|
is(
|
2020-08-04 14:10:41 +03:00
|
|
|
principal.spec,
|
2017-02-02 18:40:03 +03:00
|
|
|
triggeringURISpec,
|
|
|
|
"Triggering principal matches previous location"
|
|
|
|
);
|
|
|
|
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
|
|
|
|
ok(
|
|
|
|
content.document.querySelectorAll("th").length,
|
|
|
|
"Should have several table headers with data."
|
|
|
|
);
|
|
|
|
});
|
2018-03-19 05:16:45 +03:00
|
|
|
BrowserTestUtils.removeTab(tab);
|
2017-02-02 18:40:03 +03:00
|
|
|
});
|