Skip to content

Commit cc8d11f

Browse files
committed
Resync web-platform-tests/beacon tests from upstream
https://bugs.webkit.org/show_bug.cgi?id=219123 Reviewed by Sam Weinig. Resync web-platform-tests/beacon tests from upstream dd35c2b. * web-platform-tests/beacon/headers/header-content-type-and-body-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt. * web-platform-tests/beacon/headers/header-content-type-and-body.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html. * web-platform-tests/beacon/headers/w3c-import.log: * web-platform-tests/beacon/resources/content-type-and-body.py: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/resources/content-type.py. (main): * web-platform-tests/beacon/resources/w3c-import.log: Canonical link: https://commits.webkit.org/231773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270032 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent cabc933 commit cc8d11f

12 files changed

Lines changed: 43 additions & 23 deletions

LayoutTests/http/wpt/beacon/keepalive-after-navigation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const RESOURCES_DIR = "/beacon/resources/";
1414

1515
function pollResult(test, id) {
16-
var checkUrl = RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
16+
var checkUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=get&id=" + id;
1717

1818
return new Promise(resolve => {
1919
step_timeout(test.step_func(() => {
@@ -33,7 +33,7 @@
3333
testFrame.remove();
3434

3535
return pollResult(test, id).then(result => {
36-
assert_equals(result, "text/plain;charset=UTF-8", "Correct content-type header result");
36+
assert_equals(result, "text/plain;charset=UTF-8: test", "Correct content-type header result");
3737
});
3838
}, "Test that beacon sent from unload event handler is properly received");
3939
}

LayoutTests/http/wpt/beacon/sendBeacon-in-pagehide.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const RESOURCES_DIR = "/beacon/resources/";
1414

1515
function pollResult(test, id) {
16-
var checkUrl = RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
16+
var checkUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=get&id=" + id;
1717

1818
return new Promise(resolve => {
1919
step_timeout(test.step_func(() => {
@@ -36,7 +36,7 @@
3636
}, 0);
3737

3838
return pollResult(test, id).then(result => {
39-
assert_equals(result, "text/plain;charset=UTF-8", "Correct content-type header result");
39+
assert_equals(result, "text/plain;charset=UTF-8: test", "Correct content-type header result");
4040
});
4141
}, "Test that beacon sent from pagehide event handler is properly received");
4242
}

LayoutTests/http/wpt/beacon/support/sendBeacon-onpagehide-window.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<body>
1313
<script>
1414
onpagehide = function() {
15-
const testUrl = RESOURCES_DIR + "content-type.py?cmd=put&id=" + id;
15+
const testUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=put&id=" + id;
1616
navigator.sendBeacon(testUrl, "test");
1717
}
1818
</script>

LayoutTests/http/wpt/beacon/support/sendBeacon-onunload-iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
var id = self.token();
1010

1111
function unload() {
12-
var testUrl = RESOURCES_DIR + "content-type.py?cmd=put&id=" + id;
12+
var testUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=put&id=" + id;
1313
navigator.sendBeacon(testUrl, "test");
1414
}
1515
</script>

LayoutTests/http/wpt/fetch/fetch-in-pagehide.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
function checkUrl(id)
1616
{
17-
return RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
17+
return RESOURCES_DIR + "content-type-and-body.py?cmd=get&id=" + id;
1818
}
1919

2020
promise_test(async (test) => {
@@ -31,7 +31,7 @@
3131
const response = await fetch(checkUrl(id));
3232
assert_equals(response.status, 200);
3333
const result = await response.text();
34-
assert_equals(result, "text/plain;charset=UTF-8", "Correct content-type header result");
34+
assert_equals(result, "text/plain;charset=UTF-8: test", "Correct content-type header result");
3535
}, "Test that fetch sent from pagehide event handler is properly received with keepalive");
3636

3737
promise_test(async (test) => {

LayoutTests/http/wpt/fetch/resources/fetch-in-pagehide-window.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<body>
1313
<script>
1414
onpagehide = function() {
15-
const testUrl = RESOURCES_DIR + "content-type.py?cmd=put&id=" + id;
15+
const testUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=put&id=" + id;
1616
fetch(testUrl, { method : 'POST', headers : [["Content-Type", "text/plain;charset=UTF-8"]], body: 'test', keepalive : location.hash === "#keepalive" });
1717
}
1818
</script>

LayoutTests/imported/w3c/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2020-11-19 Chris Dumez <cdumez@apple.com>
2+
3+
Resync web-platform-tests/beacon tests from upstream
4+
https://bugs.webkit.org/show_bug.cgi?id=219123
5+
6+
Reviewed by Sam Weinig.
7+
8+
Resync web-platform-tests/beacon tests from upstream dd35c2b21b76772123f7.
9+
10+
* web-platform-tests/beacon/headers/header-content-type-and-body-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt.
11+
* web-platform-tests/beacon/headers/header-content-type-and-body.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html.
12+
* web-platform-tests/beacon/headers/w3c-import.log:
13+
* web-platform-tests/beacon/resources/content-type-and-body.py: Renamed from LayoutTests/imported/w3c/web-platform-tests/beacon/resources/content-type.py.
14+
(main):
15+
* web-platform-tests/beacon/resources/w3c-import.log:
16+
117
2020-11-19 Commit Queue <commit-queue@webkit.org>
218

319
Unreviewed, reverting r270009.

LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt renamed to LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-and-body-expected.txt

File renamed without changes.

LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html renamed to LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-and-body.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,31 @@
1212
<script>
1313
const RESOURCES_DIR = "/beacon/resources/";
1414

15-
function testContentTypeHeader(what, contentType, title) {
15+
function testContentTypeAndBody(what, expected, title) {
1616
function wait(ms) {
1717
return new Promise(resolve => step_timeout(resolve, ms));
1818
}
1919
promise_test(async t => {
2020
const id = self.token();
21-
const testUrl = new Request(RESOURCES_DIR + "content-type.py?cmd=put&id=" + id).url;
21+
const testUrl = new Request(RESOURCES_DIR + "content-type-and-body.py?cmd=put&id=" + id).url;
2222
assert_equals(performance.getEntriesByName(testUrl).length, 0);
2323
assert_true(navigator.sendBeacon(testUrl, what), "SendBeacon Succeeded");
2424

2525
do {
2626
await wait(50);
2727
} while (performance.getEntriesByName(testUrl).length === 0);
2828
assert_equals(performance.getEntriesByName(testUrl).length, 1);
29-
const checkUrl = RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
29+
const checkUrl = RESOURCES_DIR + "content-type-and-body.py?cmd=get&id=" + id;
3030
const response = await fetch(checkUrl);
3131
const text = await response.text();
32-
if (contentType === "multipart/form-data") {
32+
if (expected.startsWith("multipart/form-data")) {
33+
const split = expected.split(":");
34+
const contentType = split[0];
35+
const contentDisposition = "Content-Disposition: form-data; name=\"" + split[1] + "\"; filename=\"blob\"";
3336
assert_true(text.startsWith(contentType), "Correct Content-Type header result");
37+
assert_true(text.includes(contentDisposition), "Body included value");
3438
} else {
35-
assert_equals(text, contentType, "Correct Content-Type header result");
39+
assert_equals(text, expected, "Correct Content-Type header result");
3640
}
3741
}, "Test content-type header for a body " + title);
3842
}
@@ -74,12 +78,12 @@
7478
return new URLSearchParams(input);
7579
}
7680

77-
testContentTypeHeader("hi!", "text/plain;charset=UTF-8", "string");
78-
testContentTypeHeader(stringToArrayBufferView("123"), "", "ArrayBufferView");
79-
testContentTypeHeader(stringToArrayBuffer("123"), "", "ArrayBuffer");
80-
testContentTypeHeader(stringToBlob("123"), "text/plain", "Blob");
81-
testContentTypeHeader(stringToFormData("qwerty"), "multipart/form-data", "FormData");
82-
testContentTypeHeader(stringToURLSearchParams("key1=value1&key2=value2"), "application/x-www-form-urlencoded;charset=UTF-8", "URLSearchParams");
81+
testContentTypeAndBody("hi!", "text/plain;charset=UTF-8: hi!", "string");
82+
testContentTypeAndBody(stringToArrayBufferView("123"), ": 1\0" + "2\0" + "3\0", "ArrayBufferView");
83+
testContentTypeAndBody(stringToArrayBuffer("123"), ": 1\0" + "2\0" + "3\0", "ArrayBuffer");
84+
testContentTypeAndBody(stringToBlob("123"), "text/plain: 123", "Blob");
85+
testContentTypeAndBody(stringToFormData("qwerty"), "multipart/form-data:qwerty", "FormData");
86+
testContentTypeAndBody(stringToURLSearchParams("key1=value1&key2=value2"), "application/x-www-form-urlencoded;charset=UTF-8: key1=value1&key2=value2", "URLSearchParams");
8387
</script>
8488
</body>
8589
</html>

LayoutTests/imported/w3c/web-platform-tests/beacon/headers/w3c-import.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Property values requiring vendor prefixes:
1414
None
1515
------------------------------------------------------------------------
1616
List of files:
17-
/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html
17+
/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-and-body.html
1818
/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-referrer-no-referrer-when-downgrade.https.html
1919
/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-referrer-no-referrer.html
2020
/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-referrer-origin-when-cross-origin.html

0 commit comments

Comments
 (0)