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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html b/third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html
index fd2f123e376bb888eb363946f3db7790ca7086cd..bb4e730b81f2f55dee16f61de533648b3eb2fa7f 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html
@@ -23,12 +23,37 @@ function extension_testAddHeaders(nextTest)
function doXHR()
{
var xhr = new XMLHttpRequest();
- xhr.open("GET", "resources/echo-headers.php", false);
+ xhr.open("GET", "/resources/echo-headers.php", false);
xhr.send(null);
// Can't use output() here due to output order instability: this is invoked by inspectedWindow.eval(),
// which is not serialized against output from extension, as the latter is posted asynchronously via
// postMessage to front-end window.
- document.getElementById("headers").textContent += xhr.responseText;
+ let xWebInspectorExtensionHeaderValue;
+ let httpUserAgentHeaderValue;
+ const lines = xhr.responseText.split('\n');
+ for (let line of lines) {
+ const parts = line.split(': ', 2);
+ if (parts.length < 2) {
+ continue;
+ }
+ const name = parts[0];
+ const value = parts[1];
+ if (name == "HTTP_X_WEBINSPECTOR_EXTENSION") {
+ xWebInspectorExtensionHeaderValue = value;
+ }
+ if (name == "HTTP_USER_AGENT") {
+ httpUserAgentHeaderValue = value;
+ }
+ }
+
+ let result = '';
+ if (xWebInspectorExtensionHeaderValue !== undefined) {
+ result += xWebInspectorExtensionHeaderValue + '\n';
+ }
+ if (httpUserAgentHeaderValue !== undefined) {
+ result += httpUserAgentHeaderValue + '\n';
+ }
+ document.getElementById("headers").textContent += result;
}
</script>

Powered by Google App Engine
This is Rietveld 408576698