Bug 1835907, part 7 - Update DOM Cache API tests to remove most TCP-specific code, disable in xorigin - r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D184827
This commit is contained in:
Benjamin VanderSloot 2023-08-15 13:04:05 +00:00
parent 19d759b0f0
commit bdbf9706a8
8 changed files with 25 additions and 67 deletions

View File

@ -20,23 +20,12 @@ function runTests(testFile, order) {
async function setupPrefs() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission(
"storageAccessAPI",
true,
window.location.href
);
await SpecialPowers.wrap(document).requestStorageAccess();
return SpecialPowers.pushPrefEnv({
set: [
["dom.caches.testing.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],
[
"privacy.partition.always_partition_third_party_non_cookie_storage",
false,
],
],
});
}

View File

@ -27,6 +27,12 @@ support-files =
empty.html
idle_worker.js
# Disabled on xorigin because xorigin mode causes the tests to run in what
# amounts to third-party iframes. We have separate tests for our behaviors
# in that case (usually as "browser" tests) and do not want to complicate
# these normal functionality tests.
skip-if = xorigin
[test_cache.html]
[test_cache_add.html]
[test_cache_match_request.html]

View File

@ -89,15 +89,8 @@ SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["dom.storageManager.enabled", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
}, async function() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
["dom.storageManager.enabled", true]]
}, function() {
var name = "orphanedBodyOwner";
var cache = null;
var response = null;

View File

@ -61,16 +61,10 @@ function gc() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
}, async function() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true]],
}, function() {
var name = "toBeOrphaned";
var cache = null;
var initialUsage = 0;

View File

@ -85,9 +85,9 @@ function fetchOpaqueResponse(url) {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true]],
}, async function() {
// This test is mainly to verify we only generate different padding size for
// the opaque response which is comming from netwrok.
@ -100,12 +100,6 @@ SpecialPowers.pushPrefEnv({
// Note: For the cloned and cached opaque response, the padding size shouldn't
// be changed. Thus, it makes the attacker harder to get the padding size.
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
const name = "cachePadding";
const other_name = "cachePaddingOther";
const cors_base = "https://example.com/tests/dom/cache/test/mochitest/";

View File

@ -61,16 +61,10 @@ function gc() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
}, async function() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],],
}, function() {
var name = "foo";
var cache = null;
var initialUsage = 0;

View File

@ -87,16 +87,10 @@ async function testCreateTonsOfFD() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true]],
}, async function() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
await setupTestIframe();
info("Stage 1: Clean storage.");

View File

@ -81,16 +81,10 @@ async function waitForIOToComplete(cache, request) {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true],
["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true]],
}, async function() {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the Cache API is avaialable
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission("storageAccessAPI", true, window.location.href);
await SpecialPowers.wrap(document).requestStorageAccess();
const name = "cacheUpdateUsage";
const url = "test_cache_add.js";
const other_url = "test_cache_put.js";