Backed out changeset 2cc907d4c59c (bug 1570802) for assertion failures on /base/Document.cpp. CLOSED TREE

--HG--
extra : rebase_source : 525e61d8018ea5938e35091d361dae1d7b0611e3
This commit is contained in:
Cosmin Sabou 2019-08-07 18:24:07 +03:00
Родитель 84734704ab
Коммит e405a1c250
17 изменённых файлов: 81 добавлений и 148 удалений

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

@ -15511,6 +15511,13 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
// user settings, anti-clickjacking heuristics, or prompting the
// user for explicit permission. Reject if some rule is not fulfilled.
if (nsContentUtils::IsInPrivateBrowsing(this)) {
// If the document is in PB mode, it doesn't have access to its persistent
// cookie jar, so reject the promise here.
promise->MaybeRejectWithUndefined();
return promise.forget();
}
if (CookieSettings()->GetRejectThirdPartyTrackers() && inner) {
// Only do something special for third-party tracking content.
if (StorageDisabledByAntiTracking(this, nullptr)) {

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

@ -91,6 +91,8 @@ support-files = tracker.js
[browser_userInteraction.js]
[browser_storageAccessDoorHanger.js]
skip-if = fission
[browser_storageAccessPrivateWindow.js]
skip-if = fission || serviceworker_e10s
[browser_storageAccessPromiseRejectHandlerUserInteraction.js]
skip-if = fission
[browser_storageAccessPromiseResolveHandlerUserInteraction.js]

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

@ -56,7 +56,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"Cookies and Storage Access API",
// Blocking callback
async _ => {

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

@ -27,7 +27,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"IndexedDB and Storage Access API",
// blocking callback
async _ => {

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

@ -73,7 +73,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"IndexedDB in workers and Storage Access API",
async _ => {
function blockCode() {

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

@ -25,7 +25,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"localStorage and Storage Access API",
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */

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

@ -97,7 +97,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"BroadcastChannel and Storage Access API",
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */
@ -160,7 +160,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
false
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"BroadcastChannel in workers and Storage Access API",
async _ => {
function blockingCode() {

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

@ -40,7 +40,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
0
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"sessionStorage and Storage Access API",
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */

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

@ -26,7 +26,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
}
);
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"SharedWorkers and Storage Access API",
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */

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

@ -1,6 +1,6 @@
/* import-globals-from partitionedstorage_head.js */
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
PartitionedStorageHelper.runTest(
"HTTP Cookies",
async (win3rdParty, win1stParty, allowed) => {
await win3rdParty.fetch("cookies.sjs?3rd").then(r => r.text());
@ -48,7 +48,7 @@ PartitionedStorageHelper.runTestInNormalAndPrivateMode(
}
);
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
PartitionedStorageHelper.runTest(
"DOM Cookies",
async (win3rdParty, win1stParty, allowed) => {
win3rdParty.document.cookie = "foo=3rd";
@ -81,7 +81,7 @@ PartitionedStorageHelper.runTestInNormalAndPrivateMode(
}
);
PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
PartitionedStorageHelper.runPartitioningTest(
"Partitioned tabs - DOM Cookies",
// getDataCallback
@ -105,7 +105,7 @@ PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
}
);
PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
PartitionedStorageHelper.runPartitioningTest(
"Partitioned tabs - Network Cookies",
// getDataCallback

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

@ -1,7 +1,7 @@
/* import-globals-from antitracking_head.js */
/* import-globals-from partitionedstorage_head.js */
AntiTracking.runTestInNormalAndPrivateMode(
AntiTracking.runTest(
"localStorage and Storage Access API",
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */
@ -93,7 +93,7 @@ AntiTracking.runTestInNormalAndPrivateMode(
false
);
PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
PartitionedStorageHelper.runPartitioningTest(
"Partitioned tabs - localStorage",
// getDataCallback

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

@ -1,6 +1,6 @@
/* import-globals-from partitionedstorage_head.js */
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
PartitionedStorageHelper.runTest(
"BroadcastChannel",
async (win3rdParty, win1stParty, allowed) => {
let a = new win3rdParty.BroadcastChannel("hello");

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

@ -1,6 +1,6 @@
/* import-globals-from partitionedstorage_head.js */
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
PartitionedStorageHelper.runTest(
"SharedWorkers",
async (win3rdParty, win1stParty, allowed) => {
// This test fails if run with an HTTPS 3rd-party URL because the shared worker
@ -53,7 +53,7 @@ PartitionedStorageHelper.runTestInNormalAndPrivateMode(
}
);
PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
PartitionedStorageHelper.runPartitioningTest(
"Partitioned tabs - SharedWorker",
// getDataCallback

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

@ -0,0 +1,28 @@
/* import-globals-from antitracking_head.js */
AntiTracking.runTest(
"Storage Access API called in a private window",
// blocking callback
async _ => {
/* import-globals-from storageAccessAPIHelpers.js */
let [threw, rejected] = await callRequestStorageAccess();
ok(!threw, "requestStorageAccess should not throw");
ok(rejected, "requestStorageAccess shouldn't be available");
},
null, // non-blocking callback
// cleanup function
async _ => {
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
resolve()
);
});
},
[["dom.storage_access.enabled", true]], // extra prefs
false, // no window open test
false, // no user-interaction test
0, // no blocking notifications
true, // run in private window
null // iframe sandbox
);

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

@ -8,15 +8,9 @@
"use strict";
this.DynamicFPIHelper = {
runTest(name, callback, cleanupFunction, extraPrefs, runInPrivateWindow) {
runTest(name, callback, cleanupFunction, extraPrefs) {
add_task(async _ => {
info(
"Starting test `" +
name +
"' with dynamic FPI running in a " +
(runInPrivateWindow ? "private" : "normal") +
" window..."
);
info("Starting test `" + name + "' with dynamic FPI...");
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({
@ -41,17 +35,11 @@ this.DynamicFPIHelper = {
await SpecialPowers.pushPrefEnv({ set: extraPrefs });
}
let win = window;
if (runInPrivateWindow) {
win = OpenBrowserWindow({ private: true });
await TestUtils.topicObserved("browser-delayed-startup-finished");
}
info("Creating a new tab");
let tab = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
win.gBrowser.selectedTab = tab;
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
gBrowser.selectedTab = tab;
let browser = win.gBrowser.getBrowserForTab(tab);
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
info("Creating a 3rd party content");
@ -109,10 +97,6 @@ this.DynamicFPIHelper = {
info("Removing the tab");
BrowserTestUtils.removeTab(tab);
if (runInPrivateWindow) {
win.close();
}
});
add_task(async _ => {

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

@ -20,84 +20,25 @@ Services.scriptloader.loadSubScript(
);
this.PartitionedStorageHelper = {
runTestInNormalAndPrivateMode(name, callback, cleanupFunction, extraPrefs) {
// Normal mode
this.runTest(name, callback, cleanupFunction, extraPrefs, false);
// Private mode
this.runTest(name, callback, cleanupFunction, extraPrefs, true);
runTest(name, callback, cleanupFunction, extraPrefs) {
DynamicFPIHelper.runTest(name, callback, cleanupFunction, extraPrefs);
StoragePrincipalHelper.runTest(name, callback, cleanupFunction, extraPrefs);
},
runTest(
name,
callback,
cleanupFunction,
extraPrefs,
runInPrivateWindow = false
) {
DynamicFPIHelper.runTest(
name,
callback,
cleanupFunction,
extraPrefs,
runInPrivateWindow
);
StoragePrincipalHelper.runTest(
name,
callback,
cleanupFunction,
extraPrefs,
runInPrivateWindow
);
},
runPartitioningTestInNormalAndPrivateMode(
name,
getDataCallback,
addDataCallback,
cleanupFunction
) {
// Normal mode
this.runPartitioningTest(
name,
getDataCallback,
addDataCallback,
cleanupFunction,
false
);
// Private mode
this.runPartitioningTest(
name,
getDataCallback,
addDataCallback,
cleanupFunction,
true
);
},
runPartitioningTest(
name,
getDataCallback,
addDataCallback,
cleanupFunction,
runInPrivateWindow = false
) {
runPartitioningTest(name, getDataCallback, addDataCallback, cleanupFunction) {
this.runPartitioningTestInner(
name,
getDataCallback,
addDataCallback,
cleanupFunction,
"normal",
runInPrivateWindow
"normal"
);
this.runPartitioningTestInner(
name,
getDataCallback,
addDataCallback,
cleanupFunction,
"initial-aboutblank",
runInPrivateWindow
"initial-aboutblank"
);
},
@ -106,8 +47,7 @@ this.PartitionedStorageHelper = {
getDataCallback,
addDataCallback,
cleanupFunction,
variant,
runInPrivateWindow
variant
) {
add_task(async _ => {
info(
@ -115,9 +55,7 @@ this.PartitionedStorageHelper = {
name +
"' variant `" +
variant +
"' in a " +
(runInPrivateWindow ? "private" : "normal") +
" window to check that 2 tabs are correctly partititioned"
"' to check that 2 tabs are correctly partititioned"
);
await SpecialPowers.flushPrefEnv();
@ -139,34 +77,28 @@ this.PartitionedStorageHelper = {
],
});
let win = window;
if (runInPrivateWindow) {
win = OpenBrowserWindow({ private: true });
await TestUtils.topicObserved("browser-delayed-startup-finished");
}
info("Creating the first tab");
let tab1 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
win.gBrowser.selectedTab = tab1;
let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
gBrowser.selectedTab = tab1;
let browser1 = win.gBrowser.getBrowserForTab(tab1);
let browser1 = gBrowser.getBrowserForTab(tab1);
await BrowserTestUtils.browserLoaded(browser1);
info("Creating the second tab");
let tab2 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE_6);
win.gBrowser.selectedTab = tab2;
let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE_6);
gBrowser.selectedTab = tab2;
let browser2 = win.gBrowser.getBrowserForTab(tab2);
let browser2 = gBrowser.getBrowserForTab(tab2);
await BrowserTestUtils.browserLoaded(browser2);
info("Creating the third tab");
let tab3 = BrowserTestUtils.addTab(
win.gBrowser,
gBrowser,
TEST_4TH_PARTY_PARTITIONED_PAGE
);
win.gBrowser.selectedTab = tab3;
gBrowser.selectedTab = tab3;
let browser3 = win.gBrowser.getBrowserForTab(tab3);
let browser3 = gBrowser.getBrowserForTab(tab3);
await BrowserTestUtils.browserLoaded(browser3);
async function getDataFromThirdParty(browser, result) {
@ -324,10 +256,6 @@ this.PartitionedStorageHelper = {
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
BrowserTestUtils.removeTab(tab3);
if (runInPrivateWindow) {
win.close();
}
});
add_task(async _ => {

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

@ -8,15 +8,9 @@
"use strict";
this.StoragePrincipalHelper = {
runTest(name, callback, cleanupFunction, extraPrefs, runInPrivateWindow) {
runTest(name, callback, cleanupFunction, extraPrefs) {
add_task(async _ => {
info(
"Starting test `" +
name +
"' with storage principal running in a " +
(runInPrivateWindow ? "private" : "normal") +
" window..."
);
info("Starting test `" + name + "' with storage principal...");
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({
@ -43,17 +37,11 @@ this.StoragePrincipalHelper = {
await UrlClassifierTestUtils.addTestTrackers();
let win = window;
if (runInPrivateWindow) {
win = OpenBrowserWindow({ private: true });
await TestUtils.topicObserved("browser-delayed-startup-finished");
}
info("Creating a new tab");
let tab = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
win.gBrowser.selectedTab = tab;
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
gBrowser.selectedTab = tab;
let browser = win.gBrowser.getBrowserForTab(tab);
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
info("Creating a 3rd party content");
@ -111,10 +99,6 @@ this.StoragePrincipalHelper = {
info("Removing the tab");
BrowserTestUtils.removeTab(tab);
if (runInPrivateWindow) {
win.close();
}
});
add_task(async _ => {