forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add web platform tests about what credentials mode is used for ES6 mo…
…dule fetching for various configurations Bug: 717525 Change-Id: I4f399ae51e8211274485e3d29dbf8f48ddf18dc4 Reviewed-on: https://chromium-review.googlesource.com/551519 Commit-Queue: Takeshi Yoshino <tyoshino@chromium.org> Commit-Queue: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#483296} WPT-Export-Revision: fb069ad6d9390222d62a18e051e045d82ccea447
- Loading branch information
1 parent
9765793
commit 9f47f81
Showing
3 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
html/semantics/scripting-1/the-script-element/module/credentials.sub.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,71 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
|
||
<script type="text/javascript"> | ||
host_info = get_host_info(); | ||
|
||
document.cookie = 'same=1'; | ||
|
||
const setCookiePromise = fetch( | ||
'http://{{domains[www2]}}:{{ports[http][0]}}/cookies/resources/set-cookie.py?name=cross&path=/html/semantics/scripting-1/the-script-element/module/', | ||
{ | ||
mode: 'no-cors', | ||
credentials: 'include', | ||
}); | ||
|
||
const windowLoadPromise = new Promise(resolve => { | ||
window.addEventListener('load', () => { | ||
resolve(); | ||
}); | ||
}); | ||
|
||
promise_test(t => { | ||
const iframe = document.createElement('iframe'); | ||
|
||
return Promise.all([setCookiePromise, windowLoadPromise]).then(() => { | ||
const messagePromise = new Promise(resolve => { | ||
window.addEventListener('message', event => { | ||
resolve(); | ||
}); | ||
}); | ||
|
||
iframe.src = 'resources/credentials-iframe.sub.html'; | ||
document.body.appendChild(iframe); | ||
|
||
return messagePromise; | ||
}).then(() => { | ||
const w = iframe.contentWindow; | ||
|
||
assert_equals(w.sameOriginNone, 'not found', | ||
'Modules should be loaded without the credentials when the crossOrigin attribute is not specified and the target is same-origin'); | ||
assert_equals(w.sameOriginAnonymous, 'found', | ||
'Modules should be loaded with the credentials when the crossOrigin attribute is specified with "anonymous" as its value and the target is same-origin'); | ||
assert_equals(w.sameOriginUseCredentials, 'found', | ||
'Modules should be loaded with the credentials when the crossOrigin attribute is specified with "use-credentials" as its value and the target is same-origin'); | ||
assert_equals(w.crossOriginNone, 'not found', | ||
'Modules should be loaded without the credentials when the crossOrigin attribute is not specified and the target is cross-origin'); | ||
assert_equals(w.crossOriginAnonymous, 'not found', | ||
'Modules should be loaded without the credentials when the crossOrigin attribute is specified with "anonymous" as its value and the target is cross-origin'); | ||
assert_equals(w.crossOriginUseCredentials, 'found', | ||
'Modules should be loaded with the credentials when the crossOrigin attribute is specified with "use-credentials" as its value and the target is cross-origin'); | ||
|
||
assert_equals(w.sameOriginNoneDecendent, 'not found', | ||
'Decendent modules should be loaded without the credentials when the crossOrigin attribute is not specified and the target is same-origin'); | ||
assert_equals(w.sameOriginAnonymousDecendent, 'found', | ||
'Decendent modules should be loaded with the credentials when the crossOrigin attribute is specified with "anonymous" as its value and the target is same-origin'); | ||
assert_equals(w.sameOriginUseCredentialsDecendent, 'found', | ||
'Decendent modules should be loaded with the credentials when the crossOrigin attribute is specified with "use-credentials" as its value and the target is same-origin'); | ||
assert_equals(w.crossOriginNoneDecendent, 'not found', | ||
'Decendent modules should be loaded without the credentials when the crossOrigin attribute is not specified and the target is cross-origin'); | ||
assert_equals(w.crossOriginAnonymousDecendent, 'not found', | ||
'Decendent modules should be loaded without the credentials when the crossOrigin attribute is specified with "anonymous" as its value and the target is cross-origin'); | ||
assert_equals(w.crossOriginUseCredentialsDecendent, 'found', | ||
'Decendent modules should be loaded with the credentials when the crossOrigin attribute is specified with "use-credentials" as its value and the target is cross-origin'); | ||
}); | ||
}, 'Modules should be loaded with or without the credentials based on the same-origin-ness and the crossOrigin attribute'); | ||
</script> | ||
<body> | ||
</body> |
20 changes: 20 additions & 0 deletions
20
html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py
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,20 @@ | ||
def main(request, response): | ||
headers = [ | ||
("Content-Type", "text/javascript"), | ||
("Access-Control-Allow-Origin", request.headers.get("Origin")), | ||
("Access-Control-Allow-Credentials", "true") | ||
] | ||
identifier = request.GET.first("id") | ||
cookie_name = request.GET.first("cookieName") | ||
cookie = request.cookies.first(cookie_name, None) | ||
if identifier is None or cookie_name is None: | ||
return headers, "" | ||
|
||
if cookie is None: | ||
result = "not found" | ||
elif cookie.value == "1": | ||
result = "found" | ||
else: | ||
result = "different value: " + cookie.value | ||
|
||
return headers, "window." + identifier + " = '" + result + "';" |
50 changes: 50 additions & 0 deletions
50
html/semantics/scripting-1/the-script-element/module/resources/credentials-iframe.sub.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,50 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
|
||
<script type="module" | ||
src="check-cookie.py?id=sameOriginNone&cookieName=same"> | ||
</script> | ||
<script type="module" | ||
src="check-cookie.py?id=sameOriginAnonymous&cookieName=same" | ||
crossOrigin="anonymous"> | ||
</script> | ||
<script type="module" | ||
src="check-cookie.py?id=sameOriginUseCredentials&cookieName=same" | ||
crossOrigin="use-credentials"> | ||
</script> | ||
<script type="module" | ||
src="http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginNone&cookieName=cross"> | ||
</script> | ||
<script type="module" | ||
src="http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginAnonymous&cookieName=cross" | ||
crossOrigin="anonymous"> | ||
</script> | ||
<script type="module" | ||
src="http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginUseCredentials&cookieName=cross" | ||
crossOrigin="use-credentials"> | ||
</script> | ||
|
||
<script type="module"> | ||
import "./check-cookie.py?id=sameOriginNoneDecendent&cookieName=same"; | ||
</script> | ||
<script type="module" crossOrigin="anonymous"> | ||
import "./check-cookie.py?id=sameOriginAnonymousDecendent&cookieName=same"; | ||
</script> | ||
<script type="module" crossOrigin="use-credentials"> | ||
import "./check-cookie.py?id=sameOriginUseCredentialsDecendent&cookieName=same"; | ||
</script> | ||
<script type="module"> | ||
import "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginNoneDecendent&cookieName=cross"; | ||
</script> | ||
<script type="module" crossOrigin="anonymous"> | ||
import "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginAnonymousDecendent&cookieName=cross"; | ||
</script> | ||
<script type="module" crossOrigin="use-credentials"> | ||
import "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py?id=crossOriginUseCredentialsDecendent&cookieName=cross"; | ||
</script> | ||
|
||
<script type="text/javascript"> | ||
window.addEventListener('load', event => { | ||
window.parent.postMessage({}, '*'); | ||
}); | ||
</script> |