| Index: third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html b/third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..105902cb36df9310b48f04435254dae5d35129c2
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html
|
| @@ -0,0 +1,50 @@
|
| +<!doctype html>
|
| +<script src = "/resources/testharness.js"></script>
|
| +<script src = "/resources/testharnessreport.js"></script>
|
| +<script>
|
| +promise_test(() => {
|
| + return fetch('/resources/echo-headers.php')
|
| + .then(response => {
|
| + return response.text();
|
| + }).then(body => {
|
| + const lines = body.split('\n');
|
| + for (let line of lines) {
|
| + if (line.length == 0) {
|
| + continue;
|
| + }
|
| + const parts = line.split(': ', 2);
|
| + if (parts.length < 2) {
|
| + assert_unreached('Invalid line in response: ' + line);
|
| + }
|
| + if (parts[0] == 'HTTP_USER_AGENT') {
|
| + assert_true(parts[1].length > 0);
|
| + return;
|
| + }
|
| + }
|
| + assert_unreached('User-Agent header not found');
|
| + });
|
| +}, 'fetch() should send a non-empty User-Agent header');
|
| +
|
| +promise_test(() => {
|
| + return fetch('/resources/echo-headers.php', {headers: {'user-agent': 'foobar'}})
|
| + .then(response => {
|
| + return response.text();
|
| + }).then(body => {
|
| + const lines = body.split('\n');
|
| + for (let line of lines) {
|
| + if (line.length == 0) {
|
| + continue;
|
| + }
|
| + const parts = line.split(': ', 2);
|
| + if (parts.length < 2) {
|
| + assert_unreached('Invalid line in response: ' + line);
|
| + }
|
| + if (parts[0] == 'HTTP_USER_AGENT') {
|
| + assert_equals(parts[1], 'foobar');
|
| + return;
|
| + }
|
| + }
|
| + assert_unreached('User-Agent header not found');
|
| + });
|
| +}, 'fetch() should send an author provided User-Agent header');
|
| +</script>
|
|
|