-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
part 11 - CookieStore API - Extra tests for document URLs with fragments
Differential Revision: https://phabricator.services.mozilla.com/D221412 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1475599 gecko-commit: 8283b857e25f518b2a372ea2242c08d7c9df9800 gecko-reviewers: smaug
- Loading branch information
1 parent
cc35f23
commit 6159022
Showing
4 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
cookie-store/cookieStore_get_set_creation_url.sub.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<!doctype html> | ||
<meta charset='utf-8'> | ||
<title>Async Cookies: cookieStore basic API on creation URL with fragments</title> | ||
<link rel='help' href='https://github.com/WICG/cookie-store'> | ||
<link rel='author' href='[email protected]' title='Andrea Marchesini'> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src='resources/helpers.js'></script> | ||
<style>iframe { display: none; }</style> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
const kUrl = '/cookie-store/resources/helper_iframe.sub.html'; | ||
|
||
promise_test(async t => { | ||
const url = new URL(kUrl, location); | ||
|
||
const iframe = await createIframe(url + "#fragment", t); | ||
assert_true(iframe != null); | ||
|
||
iframe.contentWindow.postMessage({ | ||
opname: 'set-cookie', | ||
name: 'cookie-name', | ||
value: 'cookie-value', | ||
}, '*'); | ||
|
||
t.add_cleanup(async () => { | ||
await cookieStore.delete({ name: 'cookie-name', domain: '{{host}}' }); | ||
}); | ||
|
||
await waitForMessage(); | ||
|
||
iframe.contentWindow.postMessage({ | ||
opname: 'get-cookie', | ||
name: 'cookie-name', | ||
options: { url: url.href } | ||
}, '*'); | ||
|
||
const message = await waitForMessage(); | ||
|
||
const { frameCookie } = message; | ||
assert_not_equals(frameCookie, null); | ||
assert_equals(frameCookie.name, 'cookie-name'); | ||
assert_equals(frameCookie.value, 'cookie-value'); | ||
}, 'cookieStore.get() option url ignores fragments'); | ||
|
||
promise_test(async t => { | ||
const url = new URL(kUrl, location); | ||
|
||
const iframe = await createIframe(url + "#fragment", t); | ||
assert_true(iframe != null); | ||
|
||
iframe.contentWindow.postMessage({ | ||
opname: 'set-cookie', | ||
name: 'cookie-name', | ||
value: 'cookie-value', | ||
}, '*'); | ||
|
||
t.add_cleanup(async () => { | ||
await cookieStore.delete({ name: 'cookie-name', domain: '{{host}}' }); | ||
}); | ||
|
||
await waitForMessage(); | ||
|
||
iframe.contentWindow.postMessage({ | ||
opname: 'push-state', | ||
}, '*'); | ||
|
||
await waitForMessage(); | ||
|
||
iframe.contentWindow.postMessage({ | ||
opname: 'get-cookie', | ||
name: 'cookie-name', | ||
options: { url: url.href } | ||
}, '*'); | ||
|
||
const message = await waitForMessage(); | ||
|
||
const { frameCookie } = message; | ||
assert_not_equals(frameCookie, null); | ||
assert_equals(frameCookie.name, 'cookie-name'); | ||
assert_equals(frameCookie.value, 'cookie-value'); | ||
}, 'cookieStore.get() option url + pushState()'); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters