Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / inspector / extensions-useragent.html
blob8928679246aaa8537916d42f6fe9793b96d264c4
1 <html>
2 <head>
3 <script src="inspector-test.js"></script>
4 <script src="extensions-test.js"></script>
5 <script type="text/javascript">
7 function extension_testUserAgent(nextTest)
9 const requestsToCheck = [
10 "extensions-useragent.html",
11 "xhr-exists.html"
13 var requestCount = 0;
14 var queuedOutput = [];
16 function onRequestFinished(request)
18 var url = request.request.url.replace(/^.*[/]/, "");
19 if (requestsToCheck.indexOf(url) < 0)
20 return;
22 queuedOutput.push("user-agent header for " + url + ": " + getHeader(request.request.headers, "user-agent"));
23 if (++requestCount < requestsToCheck.length)
24 return;
25 webInspector.network.onRequestFinished.removeListener(onRequestFinished);
26 webInspector.inspectedWindow.eval("navigator.userAgent", onEval);
28 function getHeader(headers, name)
30 for (var i = 0; i < headers.length; ++i) {
31 if (headers[i].name.toLowerCase() === name)
32 return headers[i].value;
35 function onEval(result)
37 queuedOutput.push("navigator.userAgent: " + result);
38 webInspector.inspectedWindow.eval("", cleanUp);
40 function cleanUp()
42 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageLoaded);
43 webInspector.inspectedWindow.reload("");
45 function onPageLoaded()
47 for (var i = 0; i < queuedOutput.length; ++i)
48 output(queuedOutput[i]);
49 nextTest();
52 webInspector.network.onRequestFinished.addListener(onRequestFinished);
53 webInspector.inspectedWindow.reload("Mozilla/4.0 (compatible; WebInspector Extension User-Agent override; RSX-11M)");
56 (function()
58 var xhr = new XMLHttpRequest();
59 xhr.open("GET", "resources/xhr-exists.html", false);
60 xhr.send(null);
61 })();
63 </script>
64 </head>
65 <body onload="runTest()">
66 <p>Tests overriding user agent via WebInspector extension API</p>
67 </body>
68 </html>