[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
caseq at chromium.org
caseq at chromium.org
Wed Dec 22 18:44:58 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit eb1e75f4ee54674f2585a7029ed0749c0436e445
Author: caseq at chromium.org <caseq at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 17 08:22:16 2010 +0000
2010-12-15 Andrey Kosyakov <caseq at chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: [Extension API] add support for adding/overriding HTTP request headers
https://bugs.webkit.org/show_bug.cgi?id=50493
Test: http/tests/inspector/extensions-headers.html
* inspector/Inspector.idl:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::willSendRequest): Apply extra headers.
(WebCore::InspectorController::setExtraHeaders):
* inspector/InspectorController.h:
* inspector/front-end/ExtensionAPI.js:
(WebInspector.injectedExtensionAPI.Resources.prototype.getHAR):
(WebInspector.injectedExtensionAPI.Resources.prototype.addRequestHeaders):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer):
(WebInspector.ExtensionServer.prototype._onAddRequestHeaders):
2010-12-15 Andrey Kosyakov <caseq at chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: [Extension API] add support for adding/overriding HTTP request headers
Moved extensions test frameworks under http/tests/inspector, so HTTP tests may reuse it.
https://bugs.webkit.org/show_bug.cgi?id=50493
* http/tests/inspector/extensions-headers-expected.txt: Added.
* http/tests/inspector/extensions-headers.html: Added.
* http/tests/inspector/extensions-test.js: Renamed from LayoutTests/inspector/extensions-test.js.
(log):
(extensionFunctions):
(initialize_ExtensionsTest.InspectorTest.dispatchOnMessage):
(initialize_ExtensionsTest.InspectorTest.runExtensionTests):
(initialize_ExtensionsTest.extensionOutput):
(initialize_ExtensionsTest.dumpSidebarContent):
(initialize_ExtensionsTest.reloadPage):
(test):
* http/tests/inspector/resources/echo-headers.php: Added.
* http/tests/inspector/resources/extension-main.html: Renamed from LayoutTests/inspector/resources/extension-main.html.
* http/tests/inspector/resources/extension-main.js: Renamed from LayoutTests/inspector/resources/extension-main.js.
(fetchTests.callback):
(fetchTests):
(runTests):
(onTestsDone):
(dispatchOnFrontend.callbackWrapper):
(dispatchOnFrontend):
(callbackAndNextTest.callbackWrapper):
(callbackAndNextTest):
* http/tests/inspector/resources/extension-panel.html: Renamed from LayoutTests/inspector/resources/extension-panel.html.
* http/tests/inspector/resources/extension-sidebar.html: Renamed from LayoutTests/inspector/resources/extension-sidebar.html.
* inspector/extensions-api-expected.txt:
* inspector/extensions-api.html:
* inspector/extensions-audits-api.html:
* inspector/extensions-audits.html:
* inspector/extensions-eval.html:
* inspector/extensions-events.html:
* inspector/extensions-resources-expected.txt:
* inspector/extensions-resources.html:
* inspector/extensions.html:
* platform/chromium/test_expectations.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e8bae7f..60bc1cf 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,46 @@
+2010-12-15 Andrey Kosyakov <caseq at chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: [Extension API] add support for adding/overriding HTTP request headers
+ Moved extensions test frameworks under http/tests/inspector, so HTTP tests may reuse it.
+ https://bugs.webkit.org/show_bug.cgi?id=50493
+
+ * http/tests/inspector/extensions-headers-expected.txt: Added.
+ * http/tests/inspector/extensions-headers.html: Added.
+ * http/tests/inspector/extensions-test.js: Renamed from LayoutTests/inspector/extensions-test.js.
+ (log):
+ (extensionFunctions):
+ (initialize_ExtensionsTest.InspectorTest.dispatchOnMessage):
+ (initialize_ExtensionsTest.InspectorTest.runExtensionTests):
+ (initialize_ExtensionsTest.extensionOutput):
+ (initialize_ExtensionsTest.dumpSidebarContent):
+ (initialize_ExtensionsTest.reloadPage):
+ (test):
+ * http/tests/inspector/resources/echo-headers.php: Added.
+ * http/tests/inspector/resources/extension-main.html: Renamed from LayoutTests/inspector/resources/extension-main.html.
+ * http/tests/inspector/resources/extension-main.js: Renamed from LayoutTests/inspector/resources/extension-main.js.
+ (fetchTests.callback):
+ (fetchTests):
+ (runTests):
+ (onTestsDone):
+ (dispatchOnFrontend.callbackWrapper):
+ (dispatchOnFrontend):
+ (callbackAndNextTest.callbackWrapper):
+ (callbackAndNextTest):
+ * http/tests/inspector/resources/extension-panel.html: Renamed from LayoutTests/inspector/resources/extension-panel.html.
+ * http/tests/inspector/resources/extension-sidebar.html: Renamed from LayoutTests/inspector/resources/extension-sidebar.html.
+ * inspector/extensions-api-expected.txt:
+ * inspector/extensions-api.html:
+ * inspector/extensions-audits-api.html:
+ * inspector/extensions-audits.html:
+ * inspector/extensions-eval.html:
+ * inspector/extensions-events.html:
+ * inspector/extensions-resources-expected.txt:
+ * inspector/extensions-resources.html:
+ * inspector/extensions.html:
+ * platform/chromium/test_expectations.txt:
+
2010-12-16 Kent Tamura <tkent at chromium.org>
Unreviewed, test expectation update.
diff --git a/LayoutTests/http/tests/inspector/extensions-headers-expected.txt b/LayoutTests/http/tests/inspector/extensions-headers-expected.txt
new file mode 100644
index 0000000..3e67a16
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/extensions-headers-expected.txt
@@ -0,0 +1,9 @@
+Tests WebInspector extension API
+
+HTTP_X_WEBINSPECTOR_EXTENSION: test
+HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)
+Started extension.
+Running tests...
+RUNNING TEST: extension_testAddHeaders
+All tests done.
+
diff --git a/LayoutTests/http/tests/inspector/extensions-headers.html b/LayoutTests/http/tests/inspector/extensions-headers.html
new file mode 100644
index 0000000..8f106fd
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/extensions-headers.html
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script src="inspector-test2.js"></script>
+<script src="extensions-test.js"></script>
+<script type="text/javascript">
+
+function extension_testAddHeaders(nextTest)
+{
+ webInspector.resources.addRequestHeaders({
+ "x-webinspector-extension": "test",
+ "user-agent": "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"
+ });
+ webInspector.inspectedWindow.eval("doXHR()", nextTest);
+}
+
+function doXHR()
+{
+ var xhr = new XMLHttpRequest();
+ 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;
+}
+
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests WebInspector extension API</p>
+<div style="white-space: pre" id="headers"></div>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/inspector/extensions-test.js b/LayoutTests/http/tests/inspector/extensions-test.js
new file mode 100644
index 0000000..438b62b
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/extensions-test.js
@@ -0,0 +1,80 @@
+function log(message)
+{
+ output(message);
+}
+
+function extensionFunctions()
+{
+ var functions = "";
+
+ for (symbol in window) {
+ if (/^extension_/.exec(symbol) && typeof window[symbol] === "function")
+ functions += window[symbol].toString();
+ }
+ return functions;
+}
+
+var initialize_ExtensionsTest = function()
+{
+
+InspectorTest.dispatchOnMessage = function(messageId, callback, recurring)
+{
+ function onMessage(event)
+ {
+ if (typeof(event.data) !== "object" || event.data.command !== messageId)
+ return;
+ if (!recurring)
+ window.removeEventListener("message", onMessage, false);
+ var port = event.ports && event.ports[0];
+ if (callback(event.data, port) && port)
+ port.postMessage("");
+ }
+ window.addEventListener("message", onMessage, false);
+}
+
+InspectorTest.runExtensionTests = function()
+{
+ InjectedScriptAccess.getDefault().evaluate("location.href", "console", function(result) {
+ var pageURL = result.description;
+ var extensionURL = (/^https?:/.test(pageURL) ?
+ pageURL.replace(/^(https?:\/\/[^/]*\/).*$/,"$1") :
+ pageURL.replace(/\/inspector\/[^/]*$/, "/http/tests")) +
+ "/inspector/resources/extension-main.html";
+ WebInspector.addExtensions([{ startPage: extensionURL }]);
+ });
+}
+
+InspectorTest.dispatchOnMessage("extension-tests-done", InspectorTest.completeTest, true);
+
+function extensionOutput(message)
+{
+ InspectorTest.addResult(message.text);
+}
+InspectorTest.dispatchOnMessage("output", extensionOutput, true);
+
+function dumpSidebarContent(message, port)
+{
+ var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
+ // the sidebar of interest is presumed to always be last.
+ var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
+ InspectorTest.runAfterPendingDispatches(function() {
+ InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
+ port.postMessage("");
+ });
+}
+InspectorTest.dispatchOnMessage("dump-sidebar-content", dumpSidebarContent, true);
+
+function reloadPage(data, port)
+{
+ InspectorTest.reloadPage(function() {
+ port.postMessage("");
+ });
+}
+InspectorTest.dispatchOnMessage("reload", reloadPage, true);
+
+}
+
+var test = function()
+{
+ InspectorTest.runExtensionTests();
+}
diff --git a/LayoutTests/http/tests/inspector/resources/echo-headers.php b/LayoutTests/http/tests/inspector/resources/echo-headers.php
new file mode 100755
index 0000000..ae69597
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/resources/echo-headers.php
@@ -0,0 +1,9 @@
+<?php
+
+$headers = Array('HTTP_X_WEBINSPECTOR_EXTENSION', 'HTTP_USER_AGENT');
+
+foreach ($headers as $header) {
+ echo $header . ": " . $_SERVER[$header] . "\n";
+}
+
+?>
diff --git a/LayoutTests/http/tests/inspector/resources/extension-main.html b/LayoutTests/http/tests/inspector/resources/extension-main.html
new file mode 100644
index 0000000..a0c88f5
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/resources/extension-main.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<script src="../inspector-test.js"></script>
+<script type="text/javascript">
+function output(message)
+{
+ top.postMessage({ command: "output", text: message }, "*");
+}
+
+output("Started extension.");
+</script>
+<script src="extension-main.js"></script>
+</head>
+</html>
diff --git a/LayoutTests/inspector/resources/extension-main.js b/LayoutTests/http/tests/inspector/resources/extension-main.js
similarity index 100%
rename from LayoutTests/inspector/resources/extension-main.js
rename to LayoutTests/http/tests/inspector/resources/extension-main.js
diff --git a/LayoutTests/inspector/resources/extension-panel.html b/LayoutTests/http/tests/inspector/resources/extension-panel.html
similarity index 100%
rename from LayoutTests/inspector/resources/extension-panel.html
rename to LayoutTests/http/tests/inspector/resources/extension-panel.html
diff --git a/LayoutTests/inspector/resources/extension-sidebar.html b/LayoutTests/http/tests/inspector/resources/extension-sidebar.html
similarity index 100%
rename from LayoutTests/inspector/resources/extension-sidebar.html
rename to LayoutTests/http/tests/inspector/resources/extension-sidebar.html
diff --git a/LayoutTests/inspector/extensions-api-expected.txt b/LayoutTests/inspector/extensions-api-expected.txt
index c941f63..038db59 100644
--- a/LayoutTests/inspector/extensions-api-expected.txt
+++ b/LayoutTests/inspector/extensions-api-expected.txt
@@ -51,6 +51,7 @@ RUNNING TEST: extension_testAPI
Other : "other"
}
getHAR : <function>
+ addRequestHeaders : <function>
}
onReset : {
addListener : <function>
diff --git a/LayoutTests/inspector/extensions-api.html b/LayoutTests/inspector/extensions-api.html
index fc9da0f..ad1109f 100644
--- a/LayoutTests/inspector/extensions-api.html
+++ b/LayoutTests/inspector/extensions-api.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script type="text/javascript">
function extension_testAPI(nextTest)
diff --git a/LayoutTests/inspector/extensions-audits-api.html b/LayoutTests/inspector/extensions-audits-api.html
index 118fe0d..0d4b0b2 100755
--- a/LayoutTests/inspector/extensions-audits-api.html
+++ b/LayoutTests/inspector/extensions-audits-api.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script src="audits-tests2.js"></script>
<script src="extensions-audits-tests.js"></script>
diff --git a/LayoutTests/inspector/extensions-audits.html b/LayoutTests/inspector/extensions-audits.html
index ef65d51..c715d36 100755
--- a/LayoutTests/inspector/extensions-audits.html
+++ b/LayoutTests/inspector/extensions-audits.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script src="audits-tests2.js"></script>
<script src="extensions-audits-tests.js"></script>
diff --git a/LayoutTests/inspector/extensions-eval.html b/LayoutTests/inspector/extensions-eval.html
index 4fd3f9c..887e31a 100755
--- a/LayoutTests/inspector/extensions-eval.html
+++ b/LayoutTests/inspector/extensions-eval.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script type="text/javascript">
window.inspectedValue = { str: "foo", num: 42 };
diff --git a/LayoutTests/inspector/extensions-events.html b/LayoutTests/inspector/extensions-events.html
index 3d61701..5ffc2f6 100755
--- a/LayoutTests/inspector/extensions-events.html
+++ b/LayoutTests/inspector/extensions-events.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script type="text/javascript">
diff --git a/LayoutTests/inspector/extensions-resources-expected.txt b/LayoutTests/inspector/extensions-resources-expected.txt
index b1e3b9a..adb4b30 100644
--- a/LayoutTests/inspector/extensions-resources-expected.txt
+++ b/LayoutTests/inspector/extensions-resources-expected.txt
@@ -5,10 +5,10 @@ Page reloaded.
Started extension.
Running tests...
RUNNING TEST: extension_testGetHAR
+resource: .../tests/inspector/extensions-test.js
resource: .../tests/inspector/inspector-test2.js
resource: .../LayoutTests/inspector/extensions-resources.html
resource: .../LayoutTests/inspector/extensions-resources.html
-resource: .../LayoutTests/inspector/extensions-test.js
resource: .../inspector/resources/abe.png
resource: .../inspector/resources/Ahem.ttf
resource: .../inspector/resources/audits-style1.css
diff --git a/LayoutTests/inspector/extensions-resources.html b/LayoutTests/inspector/extensions-resources.html
index 046086f..bd208b9 100755
--- a/LayoutTests/inspector/extensions-resources.html
+++ b/LayoutTests/inspector/extensions-resources.html
@@ -11,7 +11,7 @@ p { font-family: 'test'; }
</style>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script type="text/javascript">
function extension_testGetHAR(nextTest)
diff --git a/LayoutTests/inspector/extensions-test.js b/LayoutTests/inspector/extensions-test.js
deleted file mode 100644
index ae5f9fa..0000000
--- a/LayoutTests/inspector/extensions-test.js
+++ /dev/null
@@ -1,76 +0,0 @@
-function log(message)
-{
- output(message);
-}
-
-function extensionFunctions()
-{
- var functions = "";
-
- for (symbol in window) {
- if (/^extension_/.exec(symbol) && typeof window[symbol] === "function")
- functions += window[symbol].toString();
- }
- return functions;
-}
-
-var initialize_ExtensionsTest = function()
-{
-
-InspectorTest.dispatchOnMessage = function(messageId, callback, recurring)
-{
- function onMessage(event)
- {
- if (typeof(event.data) !== "object" || event.data.command !== messageId)
- return;
- if (!recurring)
- window.removeEventListener("message", onMessage, false);
- var port = event.ports && event.ports[0];
- if (callback(event.data, port) && port)
- port.postMessage("");
- }
- window.addEventListener("message", onMessage, false);
-}
-
-InspectorTest.runExtensionTests = function()
-{
- InjectedScriptAccess.getDefault().evaluate("location.href", "console", function(result) {
- var extensionURL = result.description.replace(/\/[^/]*$/, "/resources/extension-main.html");
- WebInspector.addExtensions([{ startPage: extensionURL }]);
- });
-}
-
-InspectorTest.dispatchOnMessage("extension-tests-done", InspectorTest.completeTest, true);
-
-function extensionOutput(message)
-{
- InspectorTest.addResult(message.text);
-}
-InspectorTest.dispatchOnMessage("output", extensionOutput, true);
-
-function dumpSidebarContent(message, port)
-{
- var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
- // the sidebar of interest is presumed to always be last.
- var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
- InspectorTest.runAfterPendingDispatches(function() {
- InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
- port.postMessage("");
- });
-}
-InspectorTest.dispatchOnMessage("dump-sidebar-content", dumpSidebarContent, true);
-
-function reloadPage(data, port)
-{
- InspectorTest.reloadPage(function() {
- port.postMessage("");
- });
-}
-InspectorTest.dispatchOnMessage("reload", reloadPage, true);
-
-}
-
-var test = function()
-{
- InspectorTest.runExtensionTests();
-}
diff --git a/LayoutTests/inspector/extensions.html b/LayoutTests/inspector/extensions.html
index 0ee2919..c2f7b7a 100644
--- a/LayoutTests/inspector/extensions.html
+++ b/LayoutTests/inspector/extensions.html
@@ -1,7 +1,7 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="extensions-test.js"></script>
+<script src="../http/tests/inspector/extensions-test.js"></script>
<script type="text/javascript">
function extension_testCreatePanel(nextTest)
diff --git a/LayoutTests/inspector/resources/extension-main.html b/LayoutTests/inspector/resources/extension-main.html
deleted file mode 100644
index 1d0b54e..0000000
--- a/LayoutTests/inspector/resources/extension-main.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-<script type="text/javascript">
-function output(message)
-{
- top.postMessage({ command: "output", text: message }, "*");
-}
-
-output("Started extension.");
-</script>
-<script src="extension-main.js"></script>
-</head>
-</html>
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index 570fda5..f803586 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -623,6 +623,7 @@ WONTFIX SKIP : inspector/extensions-audits-api.html = FAIL
WONTFIX SKIP : inspector/extensions-events.html = FAIL
WONTFIX SKIP : inspector/extensions-eval.html = FAIL
WONTFIX SKIP : inspector/extensions-resources.html = TIMEOUT CRASH
+WONTFIX SKIP : inspector/tests/inspector/extensions-headers.html = FAIL
// Inspector tests in Debug build are very slow. If we remove SLOW, we'll see
// random TIMEOUTs. Is this issue DRT-specific?
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1744ea5..f34b2d9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-15 Andrey Kosyakov <caseq at chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: [Extension API] add support for adding/overriding HTTP request headers
+ https://bugs.webkit.org/show_bug.cgi?id=50493
+
+ Test: http/tests/inspector/extensions-headers.html
+
+ * inspector/Inspector.idl:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::willSendRequest): Apply extra headers.
+ (WebCore::InspectorController::setExtraHeaders):
+ * inspector/InspectorController.h:
+ * inspector/front-end/ExtensionAPI.js:
+ (WebInspector.injectedExtensionAPI.Resources.prototype.getHAR):
+ (WebInspector.injectedExtensionAPI.Resources.prototype.addRequestHeaders):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer):
+ (WebInspector.ExtensionServer.prototype._onAddRequestHeaders):
+
2010-12-16 Koan-Sin Tan <koansin.tan at gmail.com>
Reviewed by Kent Tamura.
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index c956613..12e723d 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -95,6 +95,8 @@ module core {
[notify, domain=Resources] void didCommitLoadForFrame(out Object frame, out Object loader);
[notify, domain=Resources] void frameDetachedFromParent(out unsigned long frameId);
+ [domain=Inspector] void setExtraHeaders(in Object headers);
+
[domain=Resources] void cachedResources(out Object resources);
[domain=Resources] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content);
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 39c8207..173a73b 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -53,6 +53,7 @@
#include "FrameView.h"
#include "GraphicsContext.h"
#include "HTMLFrameOwnerElement.h"
+#include "HTTPHeaderMap.h"
#include "HitTestResult.h"
#include "InjectedScript.h"
#include "InjectedScriptHost.h"
@@ -829,6 +830,12 @@ void InspectorController::willSendRequest(unsigned long identifier, ResourceRequ
if (m_frontend)
request.setReportRawHeaders(true);
+ if (m_extraHeaders) {
+ HTTPHeaderMap::const_iterator end = m_extraHeaders->end();
+ for (HTTPHeaderMap::const_iterator it = m_extraHeaders->begin(); it != end; ++it)
+ request.setHTTPHeaderField(it->first, it->second);
+ }
+
bool isMainResource = m_mainResourceIdentifier == identifier;
if (m_timelineAgent)
@@ -1862,6 +1869,18 @@ void InspectorController::reloadPage()
m_inspectedPage->mainFrame()->navigationScheduler()->scheduleRefresh();
}
+void InspectorController::setExtraHeaders(PassRefPtr<InspectorObject> headers)
+{
+ m_extraHeaders = adoptPtr(new HTTPHeaderMap());
+ InspectorObject::const_iterator end = headers->end();
+ for (InspectorObject::const_iterator it = headers->begin(); it != end; ++it) {
+ String value;
+ if (!it->second->asString(&value))
+ continue;
+ m_extraHeaders->add(it->first, value);
+ }
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index e4db9c6..aaaf53c 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -51,6 +51,7 @@ class Document;
class DocumentLoader;
class FloatRect;
class GraphicsContext;
+class HTTPHeaderMap;
class HitTestResult;
class InjectedScript;
class InjectedScriptHost;
@@ -173,6 +174,8 @@ public:
void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
void scriptImported(unsigned long identifier, const String& sourceString);
+ void setExtraHeaders(PassRefPtr<InspectorObject>);
+
void ensureSettingsLoaded();
void startTimelineProfiler();
@@ -395,6 +398,7 @@ private:
bool m_stickyBreakpointsRestored;
OwnPtr<InspectorProfilerAgent> m_profilerAgent;
+ OwnPtr<HTTPHeaderMap> m_extraHeaders;
#endif
#if ENABLE(WORKERS)
typedef HashMap<intptr_t, RefPtr<InspectorWorkerResource> > WorkersMap;
diff --git a/WebCore/inspector/front-end/ExtensionAPI.js b/WebCore/inspector/front-end/ExtensionAPI.js
index 0234994..a9a2423 100644
--- a/WebCore/inspector/front-end/ExtensionAPI.js
+++ b/WebCore/inspector/front-end/ExtensionAPI.js
@@ -126,6 +126,11 @@ Resources.prototype = {
callback(result);
}
return extensionServer.sendRequest({ command: "getHAR" }, callback && callbackWrapper);
+ },
+
+ addRequestHeaders: function(headers)
+ {
+ return extensionServer.sendRequest({ command: "addRequestHeaders", headers: headers, extensionId: location.hostname });
}
}
diff --git a/WebCore/inspector/front-end/ExtensionServer.js b/WebCore/inspector/front-end/ExtensionServer.js
index 1050c6f..373c855 100644
--- a/WebCore/inspector/front-end/ExtensionServer.js
+++ b/WebCore/inspector/front-end/ExtensionServer.js
@@ -33,8 +33,10 @@ WebInspector.ExtensionServer = function()
this._clientObjects = {};
this._handlers = {};
this._subscribers = {};
+ this._extraHeaders = {};
this._status = new WebInspector.ExtensionStatus();
+ this._registerHandler("addRequestHeaders", this._onAddRequestHeaders.bind(this));
this._registerHandler("addAuditCategory", this._onAddAuditCategory.bind(this));
this._registerHandler("addAuditResult", this._onAddAuditResult.bind(this));
this._registerHandler("createPanel", this._onCreatePanel.bind(this));
@@ -144,6 +146,29 @@ WebInspector.ExtensionServer.prototype = {
delete this._subscribers[message.type];
},
+ _onAddRequestHeaders: function(message)
+ {
+ var id = message.extensionId;
+ if (typeof id !== "string")
+ return this._status.E_BADARGTYPE("extensionId", typeof id, "string");
+ var extensionHeaders = this._extraHeaders[id];
+ if (!extensionHeaders) {
+ extensionHeaders = {};
+ this._extraHeaders[id] = extensionHeaders;
+ }
+ for (name in message.headers)
+ extensionHeaders[name] = message.headers[name];
+ var allHeaders = {};
+ for (extension in this._extraHeaders) {
+ var headers = this._extraHeaders[extension];
+ for (name in headers) {
+ if (typeof headers[name] === "string")
+ allHeaders[name] = headers[name];
+ }
+ }
+ InspectorBackend.setExtraHeaders(allHeaders);
+ },
+
_onCreatePanel: function(message, port)
{
var id = message.id;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list