Diff
Modified: trunk/LayoutTests/ChangeLog (86958 => 86959)
--- trunk/LayoutTests/ChangeLog 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/LayoutTests/ChangeLog 2011-05-20 16:15:08 UTC (rev 86959)
@@ -1,3 +1,28 @@
+2011-05-19 Sergey Vorobyev <sergeyvorob...@google.com>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: Background network events collection - add GUI to Inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=58652
+
+ Move reopenFrontend() to inspector-test.js
+ Add first test for background events collection.
+
+ * http/tests/inspector/inspector-test.js:
+ ():
+ * http/tests/inspector/network-test.js: Added.
+ (initialize_NetworkTest.InspectorTest.enableBackgroundEventCollection):
+ (initialize_NetworkTest.InspectorTest.disableBackgroundEventCollection):
+ * http/tests/inspector/network/network-clear-after-disabled-expected.txt: Added.
+ * http/tests/inspector/network/network-clear-after-disabled.html: Added.
+ * http/tests/inspector/network/network-close-load-open-expected.txt: Added.
+ * http/tests/inspector/network/network-close-load-open.html: Added.
+ * http/tests/inspector/network/network-open-load-reopen-expected.txt: Added.
+ * http/tests/inspector/network/network-open-load-reopen.html: Added.
+ * inspector/debugger/open-close-open-expected.txt:
+ * inspector/debugger/open-close-open.html:
+ * platform/qt/Skipped:
+
2011-05-20 Csaba Osztrogonác <o...@webkit.org>
[Qt] Skip failing tests.
Modified: trunk/LayoutTests/http/tests/inspector/inspector-test.js (86958 => 86959)
--- trunk/LayoutTests/http/tests/inspector/inspector-test.js 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/LayoutTests/http/tests/inspector/inspector-test.js 2011-05-20 16:15:08 UTC (rev 86959)
@@ -324,7 +324,30 @@
var runTestCallId = 0;
var completeTestCallId = 1;
+var frontendReopeningCount = 0;
+function reopenFrontend()
+{
+ closeFrontend(openFrontendAndIncrement);
+}
+
+function closeFrontend(callback)
+{
+ // Do this asynchronously to allow InspectorBackendDispatcher to send response
+ // back to the frontend before it's destroyed.
+ setTimeout(function() {
+ layoutTestController.closeWebInspector();
+ callback();
+ }, 0);
+}
+
+function openFrontendAndIncrement()
+{
+ frontendReopeningCount++;
+ layoutTestController.showWebInspector();
+ runTest();
+}
+
function runAfterIframeIsLoaded()
{
if (window.layoutTestController)
Added: trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled-expected.txt (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled-expected.txt 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,6 @@
+Test that reopening clears network panel in background events collection disabled mode. Bug 58064 Bug 58652
+
+
+Reopened frontend 2 times
+resources count = 0
+
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled.html (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled.html 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function loadImagesAndReopenFrontend(size)
+{
+ var image = document.createElement("img");
+ image.setAttribute("src", "resources/resource.php?type=image&size=" + size);
+ image._onload_ = resourceLoaded;
+ document.body.appendChild(image);
+
+ var image2 = document.createElement("img");
+ image2._onload_ = resourceLoaded;
+ image2.setAttribute("src", "resources/resource.php?type=image&size=" + size + "&gzip=true");
+ document.body.appendChild(image2);
+}
+
+var loadedResourceCount = 0;
+function resourceLoaded()
+{
+ loadedResourceCount++;
+ if (loadedResourceCount % 2 === 0)
+ reopenFrontend();
+}
+
+function test()
+{
+ try {
+ InspectorTest.evaluateInPage("frontendReopeningCount", frontendReopeningCountReceiver);
+ } catch (e) {
+ InspectorTest.disableBackgroundEventCollection();
+ throw e;
+ }
+
+ function frontendReopeningCountReceiver(stepNumber) {
+ if (stepNumber.description === "0") {
+ InspectorTest.enableBackgroundEventCollection();
+ InspectorTest.evaluateInPage("loadImagesAndReopenFrontend(400)");
+ } else if (stepNumber._description === "1") {
+ InspectorTest.disableBackgroundEventCollection();
+ InspectorTest.evaluateInPage("loadImagesAndReopenFrontend(600)");
+ } else {
+ InspectorTest.addResult("Reopened frontend " + stepNumber._description + " times");
+ InspectorTest.dumpNetworkResources();
+ InspectorTest.completeTest();
+ }
+ }
+}
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test that reopening clears network panel in background events collection disabled mode.
+<a href="" 58064</a>
+<a href="" 58652</a>
+</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-clear-after-disabled.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network/network-close-load-open-expected.txt (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-close-load-open-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-close-load-open-expected.txt 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,7 @@
+Test that when background event collection is enabled network panel correctly collects events with closed frontend. Bug 58064 Bug 58652
+
+
+resources count = 2
+http://127.0.0.1:8000/inspector/network/resources/resource.php?type=image&size=400
+http://127.0.0.1:8000/inspector/network/resources/resource.php?type=image&size=400&gzip=true
+
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-close-load-open-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network/network-close-load-open.html (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-close-load-open.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-close-load-open.html 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,61 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function loadImagesAndOpenFrontend()
+{
+ var image = document.createElement("img");
+ image.setAttribute("src", "resources/resource.php?type=image&size=400");
+ image._onload_ = resourceLoaded;
+ document.body.appendChild(image);
+
+ var image2 = document.createElement("img");
+ image2._onload_ = resourceLoaded;
+ image2.setAttribute("src", "resources/resource.php?type=image&size=400&gzip=true");
+ document.body.appendChild(image2);
+}
+
+var loadedResourceCount = 0;
+function resourceLoaded()
+{
+ loadedResourceCount++;
+ if (loadedResourceCount === 2)
+ openFrontendAndIncrement();
+}
+
+function test()
+{
+ try {
+ InspectorTest.evaluateInPage("frontendReopeningCount", frontendReopeningCountReceiver);
+ } catch (e) {
+ InspectorTest.disableBackgroundEventCollection();
+ throw e;
+ }
+
+ function frontendReopeningCountReceiver(stepNumber) {
+ if (stepNumber._description === "0") {
+ InspectorTest.enableBackgroundEventCollection();
+ InspectorTest.evaluateInPage("closeFrontend(loadImagesAndOpenFrontend)");
+ } else {
+ InspectorTest.dumpNetworkResources();
+ // Switch off before completeTest.
+ InspectorTest.disableBackgroundEventCollection();
+ InspectorTest.completeTest();
+ }
+ }
+}
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test that when background event collection is enabled network panel correctly collects events with closed frontend.
+<a href="" 58064</a>
+<a href="" 58652</a>
+</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-close-load-open.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen-expected.txt (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen-expected.txt 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,8 @@
+Test that when background event collection is enabled network panel correctly restores network log after the frontend reopening. Bug 58064 Bug 58652
+
+
+Reopened frontend 1 times
+resources count = 2
+http://127.0.0.1:8000/inspector/network/resources/resource.php?type=image&size=500
+http://127.0.0.1:8000/inspector/network/resources/resource.php?type=image&size=500&gzip=true
+
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen.html (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen.html 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,61 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function loadImagesAndReopenFrontend()
+{
+ var image = document.createElement("img");
+ image.setAttribute("src", "resources/resource.php?type=image&size=500");
+ image._onload_ = resourceLoaded;
+ document.body.appendChild(image);
+
+ var image2 = document.createElement("img");
+ image2._onload_ = resourceLoaded;
+ image2.setAttribute("src", "resources/resource.php?type=image&size=500&gzip=true");
+ document.body.appendChild(image2);
+}
+
+var loadedResourceCount = 0;
+function resourceLoaded()
+{
+ if (++loadedResourceCount === 2)
+ reopenFrontend();
+}
+
+function test()
+{
+ try {
+ InspectorTest.evaluateInPage("frontendReopeningCount", frontendReopeningCountReceiver);
+ } catch (e) {
+ InspectorTest.disableBackgroundEventCollection();
+ throw e;
+ }
+
+ function frontendReopeningCountReceiver(stepNumber) {
+ if (stepNumber._description === "0") {
+ InspectorTest.enableBackgroundEventCollection();
+ InspectorTest.evaluateInPage("loadImagesAndReopenFrontend()");
+ } else {
+ InspectorTest.addResult("Reopened frontend " + stepNumber._description + " times");
+ InspectorTest.dumpNetworkResources();
+ // Switch off before completeTest.
+ InspectorTest.disableBackgroundEventCollection();
+ InspectorTest.completeTest();
+ }
+ }
+}
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test that when background event collection is enabled network panel correctly restores network log after the frontend reopening.
+<a href="" 58064</a>
+<a href="" 58652</a>
+</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/network/network-open-load-reopen.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/network-test.js (0 => 86959)
--- trunk/LayoutTests/http/tests/inspector/network-test.js (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network-test.js 2011-05-20 16:15:08 UTC (rev 86959)
@@ -0,0 +1,26 @@
+var initialize_NetworkTest = function() {
+
+InspectorTest.enableBackgroundEventCollection = function()
+{
+ if (!WebInspector.panels.network._backgroundCollectionEnabled)
+ WebInspector.panels.network._toggleBackgroundEventsCollection();
+ else
+ throw "BackgroundEventCollection already enabled.";
+}
+
+InspectorTest.disableBackgroundEventCollection = function ()
+{
+ if (WebInspector.panels.network._backgroundCollectionEnabled)
+ WebInspector.panels.network._toggleBackgroundEventsCollection();
+}
+
+InspectorTest.dumpNetworkResources = function()
+{
+ var resources = WebInspector.panels.network.resources.slice();
+ resources.sort(function(a, b) {return a.url.localeCompare(b.url);});
+ InspectorTest.addResult("resources count = " + resources.length);
+ for (i = 0; i < resources.length; i++)
+ InspectorTest.addResult(resources[i].url);
+}
+
+};
Property changes on: trunk/LayoutTests/http/tests/inspector/network-test.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/inspector/debugger/open-close-open-expected.txt (86958 => 86959)
--- trunk/LayoutTests/inspector/debugger/open-close-open-expected.txt 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/LayoutTests/inspector/debugger/open-close-open-expected.txt 2011-05-20 16:15:08 UTC (rev 86959)
@@ -10,21 +10,10 @@
<script src=""
<script>
-function reopenFrontend() {
- // Do this asynchronously to allow InspectorBackendDispatcher to send response
- // back to the frontend before it's destroyed.
- setTimeout(function() {
- window._frontendReopened = true;
- layoutTestController.closeWebInspector();
- layoutTestController.showWebInspector();
- runTest();
- }, 0);
-}
-
function test()
{
- InspectorTest.evaluateInPage("window._frontendReopened", function(result) {
- if (result._description === "undefined")
+ InspectorTest.evaluateInPage("frontendReopeningCount", function(result) {
+ if (result._description === "0")
InspectorTest.evaluateInPage("reopenFrontend()")
else {
InspectorTest.runDebuggerTestSuite([
Modified: trunk/LayoutTests/inspector/debugger/open-close-open.html (86958 => 86959)
--- trunk/LayoutTests/inspector/debugger/open-close-open.html 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/LayoutTests/inspector/debugger/open-close-open.html 2011-05-20 16:15:08 UTC (rev 86959)
@@ -4,21 +4,10 @@
<script src=""
<script>
-function reopenFrontend() {
- // Do this asynchronously to allow InspectorBackendDispatcher to send response
- // back to the frontend before it's destroyed.
- setTimeout(function() {
- window._frontendReopened = true;
- layoutTestController.closeWebInspector();
- layoutTestController.showWebInspector();
- runTest();
- }, 0);
-}
-
function test()
{
- InspectorTest.evaluateInPage("window._frontendReopened", function(result) {
- if (result._description === "undefined")
+ InspectorTest.evaluateInPage("frontendReopeningCount", function(result) {
+ if (result._description === "0")
InspectorTest.evaluateInPage("reopenFrontend()")
else {
InspectorTest.runDebuggerTestSuite([
Modified: trunk/LayoutTests/platform/qt/Skipped (86958 => 86959)
--- trunk/LayoutTests/platform/qt/Skipped 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/LayoutTests/platform/qt/Skipped 2011-05-20 16:15:08 UTC (rev 86959)
@@ -450,6 +450,11 @@
http/tests/inspector/change-iframe-src.html
inspector/debugger/open-close-open.html
+# [Qt] This tests' fails probably has same reason as test inspector/debugger/open-close-open.html.
+http/tests/inspector/network/network-open-load-reopen.html
+http/tests/inspector/network/network-close-load-open.html
+http/tests/inspector/network/network-clear-after-disabled.html
+
# [Qt] fast/frames/flattening/frameset-flattening-subframesets.html fails intermittently on Qt bot
# Fails caused by layoutTestController.display() in fast/frames/flattening/frameset-flattening-subframe-resize.html
# https://bugs.webkit.org/show_bug.cgi?id=37334
Modified: trunk/Source/WebCore/ChangeLog (86958 => 86959)
--- trunk/Source/WebCore/ChangeLog 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/ChangeLog 2011-05-20 16:15:08 UTC (rev 86959)
@@ -1,3 +1,40 @@
+2011-05-19 Sergey Vorobyev <sergeyvorob...@google.com>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: Background network events collection - add GUI to Inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=58652
+
+ Now in WebInspector Network panel avalaible new checkbox item in context menu:
+ "Background events collection". It allows to save all network events when inspector
+ frontend closed. Events that occur before collection enabling are not preserved after
+ frontend reopening. Property unique for each page. Disabled by default.
+
+
+ Tests: http/tests/inspector/network/network-clear-after-disabled.html
+ http/tests/inspector/network/network-close-load-open.html
+ http/tests/inspector/network/network-open-load-reopen.html
+
+ * inspector/EventsCollector.cpp:
+ (WebCore::EventsCollector::clear):
+ * inspector/EventsCollector.h:
+ * inspector/Inspector.json:
+ * inspector/InspectorFrontendProxy.cpp:
+ (WebCore::InspectorFrontendProxy::inspectorFrontendChannel):
+ * inspector/InspectorFrontendProxy.h:
+ * inspector/InspectorResourceAgent.cpp:
+ (WebCore::InspectorResourceAgent::setFrontend):
+ (WebCore::InspectorResourceAgent::clearFrontend):
+ (WebCore::InspectorResourceAgent::isBackgroundEventsCollectionEnabled):
+ (WebCore::InspectorResourceAgent::setBackgroundEventsCollectionEnabled):
+ (WebCore::InspectorResourceAgent::initializeBackgroundCollection):
+ (WebCore::InspectorResourceAgent::InspectorResourceAgent):
+ * inspector/InspectorResourceAgent.h:
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkPanel):
+ (WebInspector.NetworkPanel.prototype._contextMenu):
+ (WebInspector.NetworkPanel.prototype._toggleBackgroundEventsCollection):
+
2011-05-20 Pavel Podivilov <podivi...@chromium.org>
Reviewed by Pavel Feldman.
Modified: trunk/Source/WebCore/inspector/EventsCollector.cpp (86958 => 86959)
--- trunk/Source/WebCore/inspector/EventsCollector.cpp 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/EventsCollector.cpp 2011-05-20 16:15:08 UTC (rev 86959)
@@ -48,6 +48,11 @@
}
}
+void EventsCollector::clear()
+{
+ m_events.clear();
+}
+
void EventsCollector::sendCollectedEvents(InspectorFrontendChannel* receiver)
{
for (Vector<String>::iterator it = m_events.begin(); it != m_events.end(); ++it)
Modified: trunk/Source/WebCore/inspector/EventsCollector.h (86958 => 86959)
--- trunk/Source/WebCore/inspector/EventsCollector.h 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/EventsCollector.h 2011-05-20 16:15:08 UTC (rev 86959)
@@ -40,6 +40,7 @@
EventsCollector();
~EventsCollector() { }
void addEvent(const String& message);
+ void clear();
void sendCollectedEvents(InspectorFrontendChannel*);
private:
static const size_t maxCapacity = 1024*1024; // 1 Mb
Modified: trunk/Source/WebCore/inspector/Inspector.json (86958 => 86959)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-05-20 16:15:08 UTC (rev 86959)
@@ -472,6 +472,19 @@
"parameters": [
{ "name": "headers", "type": "object", "description": "Map with extra HTTP headers." }
]
+ },
+ {
+ "name": "setBackgroundEventsCollectionEnabled",
+ "description": "Toggles background network event collection.",
+ "parameters": [
+ { "name": "enabled", "type": "boolean", "description": "true - enable collection, false - disable" }
+ ]
+ },
+ {
+ "name": "isBackgroundEventsCollectionEnabled",
+ "returns": [
+ { "name": "enabled", "type": "boolean" }
+ ]
}
],
"events": [
Modified: trunk/Source/WebCore/inspector/InspectorFrontendProxy.cpp (86958 => 86959)
--- trunk/Source/WebCore/inspector/InspectorFrontendProxy.cpp 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/InspectorFrontendProxy.cpp 2011-05-20 16:15:08 UTC (rev 86959)
@@ -55,6 +55,11 @@
m_receiver = receiver;
}
+InspectorFrontendChannel* InspectorFrontendProxy::inspectorFrontendChannel()
+{
+ return m_receiver;
+}
+
void InspectorFrontendProxy::setEventsCollector(EventsCollector* collector)
{
m_collector = collector;
Modified: trunk/Source/WebCore/inspector/InspectorFrontendProxy.h (86958 => 86959)
--- trunk/Source/WebCore/inspector/InspectorFrontendProxy.h 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/InspectorFrontendProxy.h 2011-05-20 16:15:08 UTC (rev 86959)
@@ -42,6 +42,7 @@
virtual ~InspectorFrontendProxy() { }
void setInspectorFrontendChannel(InspectorFrontendChannel*);
+ InspectorFrontendChannel* inspectorFrontendChannel();
void setEventsCollector(EventsCollector*);
virtual bool sendMessageToFrontend(const String& message);
Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (86958 => 86959)
--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2011-05-20 16:15:08 UTC (rev 86959)
@@ -68,12 +68,13 @@
namespace ResourceAgentState {
static const char resourceAgentEnabled[] = "resourceAgentEnabled";
static const char extraRequestHeaders[] = "extraRequestHeaders";
+static const char backgroundEventsCollectionEnabled[] = "backgroundEventsCollectionEnabled";
}
void InspectorResourceAgent::setFrontend(InspectorFrontend* frontend)
{
m_frontend = frontend->network();
- if (backgroundEventsCollectionEnabled()) {
+ if (isBackgroundEventsCollectionEnabled()) {
// Insert Message Proxy in receiver chain.
InspectorFrontendChannel* client = m_frontend->getInspectorFrontendChannel();
m_inspectorFrontendProxy->setInspectorFrontendChannel(client);
@@ -84,14 +85,16 @@
void InspectorResourceAgent::clearFrontend()
{
- if (backgroundEventsCollectionEnabled()) {
+ if (isBackgroundEventsCollectionEnabled()) {
+ m_frontend = m_mockFrontend.get();
m_inspectorFrontendProxy->setInspectorFrontendChannel(0);
- m_frontend = m_mockFrontend.get();
- } else
+ m_frontend->setInspectorFrontendChannel(m_inspectorFrontendProxy.get());
+ } else {
m_frontend = 0;
-
+ ErrorString error;
+ disable(&error);
+ }
m_userAgentOverride = "";
- disable(0);
}
void InspectorResourceAgent::restore()
@@ -331,14 +334,37 @@
}
#endif // ENABLE(WEB_SOCKETS)
-bool InspectorResourceAgent::backgroundEventsCollectionEnabled()
+void InspectorResourceAgent::isBackgroundEventsCollectionEnabled(ErrorString*, bool* enabled)
{
- // FIXME (https://bugs.webkit.org/show_bug.cgi?id=58652)
- // Add here condition to enable background events collection.
- // Now this function is disable.
- return false;
+ (*enabled) = isBackgroundEventsCollectionEnabled();
}
+bool InspectorResourceAgent::isBackgroundEventsCollectionEnabled()
+{
+ return m_state->getBoolean(ResourceAgentState::backgroundEventsCollectionEnabled);
+}
+
+void InspectorResourceAgent::setBackgroundEventsCollectionEnabled(ErrorString*, bool enabled)
+{
+ if (enabled == isBackgroundEventsCollectionEnabled())
+ return;
+ if (enabled) {
+ if (!m_eventsCollector)
+ initializeBackgroundCollection();
+ // Insert Message Proxy in receiver chain.
+ ASSERT(m_frontend);
+ InspectorFrontendChannel* client = m_frontend->getInspectorFrontendChannel();
+ m_inspectorFrontendProxy->setInspectorFrontendChannel(client);
+ m_frontend->setInspectorFrontendChannel(m_inspectorFrontendProxy.get());
+ } else {
+ // Take out Message Proxy from receiver chain.
+ m_frontend->setInspectorFrontendChannel(m_inspectorFrontendProxy->inspectorFrontendChannel());
+ m_inspectorFrontendProxy->setInspectorFrontendChannel(0);
+ m_eventsCollector->clear();
+ }
+ return m_state->setBoolean(ResourceAgentState::backgroundEventsCollectionEnabled, enabled);
+}
+
void InspectorResourceAgent::enable(ErrorString*)
{
enable();
@@ -368,16 +394,22 @@
m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
}
+void InspectorResourceAgent::initializeBackgroundCollection()
+{
+ m_eventsCollector = adoptPtr(new EventsCollector());
+ m_inspectorFrontendProxy = adoptPtr(new InspectorFrontendProxy(m_eventsCollector.get()));
+ // Create mock frontend, so we can collect network events.
+ m_mockFrontend = adoptPtr(new InspectorFrontend::Network(m_inspectorFrontendProxy.get()));
+}
+
InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* state)
: m_instrumentingAgents(instrumentingAgents)
, m_pageAgent(pageAgent)
, m_state(state)
{
- if (backgroundEventsCollectionEnabled()) {
- m_eventsCollector = adoptPtr(new EventsCollector);
- m_inspectorFrontendProxy = adoptPtr(new InspectorFrontendProxy(m_eventsCollector.get()));
+ if (isBackgroundEventsCollectionEnabled()) {
+ initializeBackgroundCollection();
// Create mock frontend, so we can collect network events.
- m_mockFrontend = adoptPtr(new InspectorFrontend::Network(m_inspectorFrontendProxy.get()));
m_frontend = m_mockFrontend.get();
enable();
} else
Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.h (86958 => 86959)
--- trunk/Source/WebCore/inspector/InspectorResourceAgent.h 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.h 2011-05-20 16:15:08 UTC (rev 86959)
@@ -105,9 +105,10 @@
void didCloseWebSocket(unsigned long identifier);
#endif
- bool backgroundEventsCollectionEnabled();
+ void isBackgroundEventsCollectionEnabled(ErrorString*, bool* enabled);
+ void setBackgroundEventsCollectionEnabled(ErrorString*, bool enabled);
- // Called from frontend
+ // Called from frontend
void enable(ErrorString*);
void disable(ErrorString*);
void setUserAgentOverride(ErrorString*, const String& userAgent);
@@ -117,15 +118,17 @@
private:
InspectorResourceAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*);
+ bool isBackgroundEventsCollectionEnabled();
void enable();
+ void initializeBackgroundCollection();
InstrumentingAgents* m_instrumentingAgents;
InspectorPageAgent* m_pageAgent;
InspectorState* m_state;
+ InspectorFrontend::Network* m_frontend;
OwnPtr<EventsCollector> m_eventsCollector;
- InspectorFrontend::Network* m_frontend;
+ OwnPtr<InspectorFrontendProxy> m_inspectorFrontendProxy;
OwnPtr<InspectorFrontend::Network> m_mockFrontend;
- OwnPtr<InspectorFrontendProxy> m_inspectorFrontendProxy;
String m_userAgentOverride;
};
Modified: trunk/Source/WebCore/inspector/front-end/NetworkPanel.js (86958 => 86959)
--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2011-05-20 16:11:42 UTC (rev 86958)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2011-05-20 16:15:08 UTC (rev 86959)
@@ -30,6 +30,12 @@
WebInspector.NetworkPanel = function()
{
+ function eventsCollectionEnabled(error, enabled)
+ {
+ this._backgroundCollectionEnabled = enabled;
+ }
+ NetworkAgent.isBackgroundEventsCollectionEnabled(eventsCollectionEnabled.bind(this));
+
WebInspector.Panel.call(this, "network");
this.createSidebar();
@@ -1020,6 +1026,9 @@
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Save all as HAR" : "Save All as HAR"), this._exportAll.bind(this));
}
+ contextMenu.appendSeparator();
+ contextMenu.appendCheckboxItem(WebInspector.UIString("Enabled background events collection"), this._toggleBackgroundEventsCollection.bind(this), this._backgroundCollectionEnabled);
+
contextMenu.show(event);
},
@@ -1066,6 +1075,12 @@
InspectorFrontendHost.saveAs(resource.displayName + ".har", JSON.stringify(har));
},
+ _toggleBackgroundEventsCollection: function(resource)
+ {
+ this._backgroundCollectionEnabled = !this._backgroundCollectionEnabled;
+ NetworkAgent.setBackgroundEventsCollectionEnabled(this._backgroundCollectionEnabled);
+ },
+
_updateOffscreenRows: function(e)
{
var dataTableBody = this._dataGrid.dataTableBody;