зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1589074 - Fix sessionrestore mochitest failures after changing default referrer policy to strict-origin-when-cross-origin. r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D88553
This commit is contained in:
Родитель
bb3515bdb9
Коммит
578376fc76
|
@ -5,6 +5,20 @@ const REFERRER2 = "http://example.org/?" + Math.random();
|
|||
const REFERRER3 = "http://example.org/?" + Math.random();
|
||||
|
||||
add_task(async function() {
|
||||
function getExpectedReferrer(referrer) {
|
||||
let defaultPolicy = Services.prefs.getIntPref(
|
||||
"network.http.referer.defaultPolicy"
|
||||
);
|
||||
ok(
|
||||
[2, 3].indexOf(defaultPolicy) > -1,
|
||||
"default referrer policy should be either strict-origin-when-cross-origin(2) or no-referrer-when-downgrade(3)"
|
||||
);
|
||||
if (defaultPolicy == 2) {
|
||||
return referrer.match(/https?:\/\/[^\/]+\/?/i)[0];
|
||||
}
|
||||
return referrer;
|
||||
}
|
||||
|
||||
async function checkDocumentReferrer(referrer, msg) {
|
||||
await SpecialPowers.spawn(
|
||||
gBrowser.selectedBrowser,
|
||||
|
@ -63,7 +77,7 @@ add_task(async function() {
|
|||
await promiseTabState(tab, tabState);
|
||||
|
||||
await checkDocumentReferrer(
|
||||
REFERRER2,
|
||||
getExpectedReferrer(REFERRER2),
|
||||
"document.referrer matches referrer set via setTabState using referrerInfo."
|
||||
);
|
||||
gBrowser.removeCurrentTab();
|
||||
|
@ -73,7 +87,7 @@ add_task(async function() {
|
|||
await promiseTabRestored(tab);
|
||||
|
||||
await checkDocumentReferrer(
|
||||
REFERRER2,
|
||||
getExpectedReferrer(REFERRER2),
|
||||
"document.referrer is still correct after closing and reopening the tab."
|
||||
);
|
||||
|
||||
|
@ -82,7 +96,7 @@ add_task(async function() {
|
|||
await promiseTabState(tab, tabState);
|
||||
|
||||
await checkDocumentReferrer(
|
||||
REFERRER3,
|
||||
getExpectedReferrer(REFERRER3),
|
||||
"document.referrer matches referrer set via setTabState using referrer."
|
||||
);
|
||||
gBrowser.removeCurrentTab();
|
||||
|
@ -92,7 +106,7 @@ add_task(async function() {
|
|||
await promiseTabRestored(tab);
|
||||
|
||||
await checkDocumentReferrer(
|
||||
REFERRER3,
|
||||
getExpectedReferrer(REFERRER3),
|
||||
"document.referrer is still correct after closing and reopening the tab."
|
||||
);
|
||||
gBrowser.removeCurrentTab();
|
||||
|
|
|
@ -38,8 +38,26 @@ add_task(async function test_referrer() {
|
|||
dummy1,
|
||||
dummy2,
|
||||
]) {
|
||||
function getExpectedReferrer(referrer) {
|
||||
let defaultPolicy = Services.prefs.getIntPref(
|
||||
"network.http.referer.defaultPolicy"
|
||||
);
|
||||
ok(
|
||||
[2, 3].indexOf(defaultPolicy) > -1,
|
||||
"default referrer policy should be either strict-origin-when-cross-origin(2) or no-referrer-when-downgrade(3)"
|
||||
);
|
||||
if (defaultPolicy == 2) {
|
||||
return referrer.match(/https?:\/\/[^\/]+\/?/i)[0];
|
||||
}
|
||||
return referrer;
|
||||
}
|
||||
|
||||
is(content.location.href, dummy1, "Should have loaded the right URL");
|
||||
is(content.document.referrer, dummy2, "Should have the right referrer");
|
||||
is(
|
||||
content.document.referrer,
|
||||
getExpectedReferrer(dummy2),
|
||||
"Should have the right referrer"
|
||||
);
|
||||
});
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
|
Загрузка…
Ссылка в новой задаче