Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html

Issue 2254693002: Delay generation of User-Agent header to URLRequestHttpJob and accept custom User-Agent from XHR/Fe… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <script src = "/resources/testharness.js"></script>
3 <script src = "/resources/testharnessreport.js"></script>
4 <script>
5 promise_test(() => {
6 return fetch('/resources/echo-headers.php')
7 .then(response => {
8 return response.text();
9 }).then(body => {
10 const lines = body.split('\n');
11 for (let line of lines) {
12 if (line.length == 0) {
13 continue;
14 }
15 const parts = line.split(': ', 2);
16 if (parts.length < 2) {
17 assert_unreached('Invalid line in response: ' + line);
18 }
19 if (parts[0] == 'HTTP_USER_AGENT') {
20 assert_true(parts[1].length > 0);
21 return;
22 }
23 }
24 assert_unreached('User-Agent header not found');
25 });
26 }, 'fetch() should send a non-empty User-Agent header');
27
28 promise_test(() => {
29 return fetch('/resources/echo-headers.php', {headers: {'user-agent': 'foobar'} })
30 .then(response => {
31 return response.text();
32 }).then(body => {
33 const lines = body.split('\n');
34 for (let line of lines) {
35 if (line.length == 0) {
36 continue;
37 }
38 const parts = line.split(': ', 2);
39 if (parts.length < 2) {
40 assert_unreached('Invalid line in response: ' + line);
41 }
42 if (parts[0] == 'HTTP_USER_AGENT') {
43 assert_equals(parts[1], 'foobar');
44 return;
45 }
46 }
47 assert_unreached('User-Agent header not found');
48 });
49 }, 'fetch() should send an author provided User-Agent header');
50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698