diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/originattributes/test/browser/browser_cookieIsolation.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/originattributes/test/browser/browser_cookieIsolation.js')
-rw-r--r-- | browser/components/originattributes/test/browser/browser_cookieIsolation.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/browser/components/originattributes/test/browser/browser_cookieIsolation.js b/browser/components/originattributes/test/browser/browser_cookieIsolation.js new file mode 100644 index 0000000000..e10943e588 --- /dev/null +++ b/browser/components/originattributes/test/browser/browser_cookieIsolation.js @@ -0,0 +1,43 @@ +/** + * Bug 1312541 - A test case for document.cookie isolation. + */ + +const TEST_PAGE = + "https://example.net/browser/browser/components/" + + "originattributes/test/browser/file_firstPartyBasic.html"; + +// Use a random key so we don't access it in later tests. +const key = "key" + Math.random().toString(); +const re = new RegExp(key + "=([0-9.]+)"); + +// Define the testing function +function doTest(aBrowser) { + return SpecialPowers.spawn( + aBrowser, + [key, re], + function (contentKey, contentRe) { + let result = contentRe.exec(content.document.cookie); + if (result) { + return result[1]; + } + // No value is found, so we create one. + let value = Math.random().toString(); + content.document.cookie = + contentKey + "=" + value + "; SameSite=None; Secure;"; + return value; + } + ); +} + +registerCleanupFunction(() => { + Services.cookies.removeAll(); +}); + +IsolationTestTools.runTests( + TEST_PAGE, + doTest, + null, + null, + false, + true /* aUseHttps */ +); |