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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.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: Changed Android test 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
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="inspector-test.js"></script> 3 <script src="inspector-test.js"></script>
4 <script src="extensions-test.js"></script> 4 <script src="extensions-test.js"></script>
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 6
7 function extension_testAddHeaders(nextTest) 7 function extension_testAddHeaders(nextTest)
8 { 8 {
9 webInspector.network.addRequestHeaders({ 9 webInspector.network.addRequestHeaders({
10 "x-webinspector-extension": "test", 10 "x-webinspector-extension": "test",
11 "user-agent": "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)" 11 "user-agent": "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"
12 }); 12 });
13 function cleanUpHeaders() 13 function cleanUpHeaders()
14 { 14 {
15 webInspector.network.addRequestHeaders({ 15 webInspector.network.addRequestHeaders({
16 "x-webinspector-extension": null, 16 "x-webinspector-extension": null,
17 "user-agent": null 17 "user-agent": null
18 }); 18 });
19 } 19 }
20 webInspector.inspectedWindow.eval("doXHR()", callbackAndNextTest(cleanUpHead ers, nextTest)); 20 webInspector.inspectedWindow.eval("doXHR()", callbackAndNextTest(cleanUpHead ers, nextTest));
21 } 21 }
22 22
23 function doXHR() 23 function doXHR()
24 { 24 {
25 var xhr = new XMLHttpRequest(); 25 var xhr = new XMLHttpRequest();
26 xhr.open("GET", "resources/echo-headers.php", false); 26 xhr.open("GET", "/resources/echo-headers.php", false);
27 xhr.send(null); 27 xhr.send(null);
28 // Can't use output() here due to output order instability: this is invoked by inspectedWindow.eval(), 28 // Can't use output() here due to output order instability: this is invoked by inspectedWindow.eval(),
29 // which is not serialized against output from extension, as the latter is p osted asynchronously via 29 // which is not serialized against output from extension, as the latter is p osted asynchronously via
30 // postMessage to front-end window. 30 // postMessage to front-end window.
31 document.getElementById("headers").textContent += xhr.responseText; 31 let xWebInspectorExtensionHeaderValue;
32 let httpUserAgentHeaderValue;
33 const lines = xhr.responseText.split('\n');
34 for (let line of lines) {
35 const parts = line.split(': ', 2);
36 if (parts.length < 2) {
37 continue;
38 }
39 const name = parts[0];
40 const value = parts[1];
41 if (name == "HTTP_X_WEBINSPECTOR_EXTENSION") {
42 xWebInspectorExtensionHeaderValue = value;
43 }
44 if (name == "HTTP_USER_AGENT") {
45 httpUserAgentHeaderValue = value;
46 }
47 }
48
49 let result = '';
50 if (xWebInspectorExtensionHeaderValue !== undefined) {
51 result += xWebInspectorExtensionHeaderValue + '\n';
52 }
53 if (httpUserAgentHeaderValue !== undefined) {
54 result += httpUserAgentHeaderValue + '\n';
55 }
56 document.getElementById("headers").textContent += result;
32 } 57 }
33 58
34 </script> 59 </script>
35 </head> 60 </head>
36 <body onload="runTest()"> 61 <body onload="runTest()">
37 <p>Tests WebInspector extension API</p> 62 <p>Tests WebInspector extension API</p>
38 <div style="white-space: pre" id="headers"></div> 63 <div style="white-space: pre" id="headers"></div>
39 </body> 64 </body>
40 </html> 65 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698