Bug 1915383 - Fix browser_storage_dfpi.js for third-party cookie blocking. r=bvandersloot,devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D220665
This commit is contained in:
Tim Huang 2024-09-10 09:07:41 +00:00
Родитель a9d1f17489
Коммит 52e9793cdc
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -69,13 +69,21 @@ async function setPartitionedStorage(browser, type, key) {
content.localStorage.setItem(storageKey, storageValue);
};
const thirdPartyHandler = async (storageType, storageKey, storageValue) => {
if (storageType == "cookie") {
content.document.cookie = `${storageKey}=${storageValue}; SameSite=None; Secure; Partitioned;`;
return;
}
content.localStorage.setItem(storageKey, storageValue);
};
// Set first party storage.
await SpecialPowers.spawn(browser, [type, key, "first"], handler);
// Set third-party (partitioned) storage in the iframe.
await SpecialPowers.spawn(
browser.browsingContext.children[0],
[type, key, "third"],
handler
thirdPartyHandler
);
}