зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1750006 - Make tests in dom/broadcastchannel/test/ dFPI compatible, r=smaug,anti-tracking-reviewers,timhuang
We are fixing mochitests that fail when network.cookie.cookieBehavior = 5, i.e. when we enable Total Cookie Protection. This is most often due to the test assuming that an origin will always have access to its storage state when embedded as a third party. In this case I had to request storage access to allow an embedded iframe to use a BroadcastChannel to communicate with top-level pages of the same origin. This was only a problem in the XOrigin case where the test html file is loaded in an embedded iframe and then can't communicate with the top-level window it created. Differential Revision: https://phabricator.services.mozilla.com/D136604
This commit is contained in:
Родитель
dfb65118c5
Коммит
17deea5325
|
@ -18,7 +18,12 @@
|
|||
* The page which is loaded from session history should be persisted if
|
||||
* expectedPersisted is true.
|
||||
*/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var testUrl1 = "testUrl1_bfcache.html";
|
||||
|
||||
|
||||
function executeTest() {
|
||||
var bc1 = new BroadcastChannel("testUrl1_bfcache");
|
||||
var bc2 = new BroadcastChannel("testUrl2_bfcache");
|
||||
bc1.onmessage = function(event) {
|
||||
|
@ -82,13 +87,30 @@
|
|||
window.open(testUrl1, "", "noopener");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// If Fission is disabled, the pref is no-op.
|
||||
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
|
||||
runTest();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (isXOrigin) {
|
||||
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
|
||||
// Acquire storage access permission here so that the BroadcastChannel used to
|
||||
// communicate with the opened windows works in xorigin tests. Otherwise,
|
||||
// the iframe containing this page is isolated from first-party storage access,
|
||||
// which isolates BroadcastChannel communication.
|
||||
SpecialPowers.wrap(document).notifyUserGestureActivation();
|
||||
SpecialPowers.addPermission("storageAccessAPI", true, window.location.href).then(() => {
|
||||
SpecialPowers.wrap(document).requestStorageAccess().then(() => {
|
||||
executeTest();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
executeTest();
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче