Files
tubestation/testing/web-platform/tests/eventsource/request-credentials.window.js
Jonathan Lee 08fb0435a1 Bug 1876458 [wpt PR 44186] - [wpt] Fix misnamed tests that get HTTP 404, a=testonly
Automatic update from web-platform-tests
[wpt] Fix misnamed tests that get HTTP 404

`x.any.window.js` isn't a valid suffix [0] because it generates URLs
`x.window.any.html` and `x.window.any.worker.html`. This confuses
wptserve's extension substitution [1], which look for a nonexistent
file `x.window.any.js` (note the reversed order of the `.any` and
`.window` flags).

According to the PR [2] that introduced these tests, these should just
be plain `.window.js` tests.

`wpt lint` should ban such invalid flags in a follow-up PR upstream.

[0]: https://web-platform-tests.org/writing-tests/testharness.html
[1]: https://github.com/web-platform-tests/wpt/blob/e7b773cb/tools/serve/serve.py#L320
[2]: https://github.com/web-platform-tests/wpt/pull/29765#discussion_r697208154

Bug: 1517496, 1499775
Change-Id: Ieac0c1e53a35d8f24df33bc44515af60bab210a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5236256
Reviewed-by: Weizhong Xia <weizhong@google.com>
Commit-Queue: Weizhong Xia <weizhong@google.com>
Auto-Submit: Jonathan Lee <jonathanjlee@google.com>
Cr-Commit-Position: refs/heads/main@{#1252164}

--

wpt-commits: 0b23955605ebd63ff9cfce3dc430174a4f9dc014
wpt-pr: 44186
2024-01-28 09:59:37 +00:00

38 lines
1.4 KiB
JavaScript

// META: title=EventSource: credentials
var crossdomain = location.href
.replace('://', '://www2.')
.replace(/\/[^\/]*$/, '/')
function testCookie(desc, success, props, id) {
var test = async_test(document.title + ': credentials ' + desc)
test.step(function() {
var source = new EventSource(crossdomain + "resources/cors-cookie.py?ident=" + id, props)
source.onmessage = test.step_func(function(e) {
if(e.data.indexOf("first") == 0) {
assert_equals(e.data, "first NO_COOKIE", "cookie status")
}
else if(e.data.indexOf("second") == 0) {
if (success)
assert_equals(e.data, "second COOKIE", "cookie status")
else
assert_equals(e.data, "second NO_COOKIE", "cookie status")
source.close()
test.done()
}
else {
assert_unreached("unrecognized data returned: " + e.data)
source.close()
test.done()
}
})
})
}
testCookie('enabled', true, { withCredentials: true }, '1_' + new Date().getTime())
testCookie('disabled', false, { withCredentials: false }, '2_' + new Date().getTime())
testCookie('default', false, { }, '3_' + new Date().getTime())