Bug 1762462 - Make tests in devtools/client/storage/test/ reflect Always Partitioning Storage; r=jdescottes

Depends on D148042

Differential Revision: https://phabricator.services.mozilla.com/D148043
This commit is contained in:
Thomas Wisniewski 2022-07-14 19:26:26 +00:00
Родитель da0244fbda
Коммит 657bf013fa
4 изменённых файлов: 85 добавлений и 1 удалений

Просмотреть файл

@ -69,6 +69,7 @@ skip-if = true # Bug 1448484 - sameSite1 is "Unset" - Got undefined, expected Un
[browser_storage_delete_usercontextid.js]
tags = usercontextid
[browser_storage_dfpi.js]
[browser_storage_dfpi_always_partition_storage.js]
[browser_storage_dom_cache_disabled.js]
[browser_storage_dynamic_updates_cookies.js]
[browser_storage_dynamic_updates_localStorage.js]

Просмотреть файл

@ -33,6 +33,11 @@ add_task(async function() {
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
await pushPref(
"privacy.partition.always_partition_third_party_non_cookie_storage",
false
);
registerCleanupFunction(SiteDataTestUtils.clear);
// `Services.qms.listOrigins()` may or contain results created by other tests.

Просмотреть файл

@ -0,0 +1,72 @@
/* 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/. */
/* import-globals-from head.js */
// Basic test to assert that the storage tree and table corresponding to each
// item in the storage tree is correctly displayed, bearing in mind the origin
// is partitioned when always_partition_third_party_non_cookie_storage is true.
"use strict";
const { SiteDataTestUtils } = ChromeUtils.import(
"resource://testing-common/SiteDataTestUtils.jsm"
);
// Ensure iframe.src in storage-dfpi.html starts with PREFIX.
const PREFIX = "https://sub1.test1.example";
const ORIGIN = `${PREFIX}.org`;
const ORIGIN_PARTITIONED = `${PREFIX}.com^partitionKey=%28https%2Cexample.org%29`;
const TEST_URL = `${ORIGIN}/document-builder.sjs?html=
<iframe src="${PREFIX}.com/browser/devtools/client/storage/test/storage-blank.html"></iframe>
`;
function listOrigins() {
return new Promise(resolve => {
SpecialPowers.Services.qms.listOrigins().callback = req => {
resolve(req.result);
};
});
}
add_task(async function() {
await pushPref(
"network.cookie.cookieBehavior",
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
await pushPref(
"privacy.partition.always_partition_third_party_non_cookie_storage",
true
);
registerCleanupFunction(SiteDataTestUtils.clear);
const expectedOrigins = [ORIGIN, ORIGIN_PARTITIONED];
// `Services.qms.listOrigins()` may or contain results created by other tests.
// And it's unsafe to clear existing origins by `Services.qms.clear()`.
// In order to obtain correct results, we need to compare the results before
// and after `openTabAndSetupStorage` is called.
// To ensure more accurate results, try choosing a uncommon origin for PREFIX.
const EXISTING_ORIGINS = await listOrigins();
expectedOrigins.forEach(expected => {
ok(!EXISTING_ORIGINS.includes(expected), `${expected} doesn't exist`);
});
await openTabAndSetupStorage(TEST_URL);
const origins = await listOrigins();
for (const origin of origins) {
ok(
EXISTING_ORIGINS.includes(origin) || expectedOrigins.includes(origin),
`check origin: ${origin}`
);
}
expectedOrigins.forEach(expected => {
ok(origins.includes(expected), `${expected} is added`);
});
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

Просмотреть файл

@ -9,7 +9,13 @@
add_task(async function() {
await SpecialPowers.pushPrefEnv({
// Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default"
set: [["network.cookie.sameSite.laxByDefault", false]],
set: [
["network.cookie.sameSite.laxByDefault", false],
[
"privacy.partition.always_partition_third_party_non_cookie_storage",
false,
],
],
});
const URL_IFRAME = buildURLWithContent(