Diff
Modified: trunk/LayoutTests/ChangeLog (139852 => 139853)
--- trunk/LayoutTests/ChangeLog 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/LayoutTests/ChangeLog 2013-01-16 09:50:19 UTC (rev 139853)
@@ -1,3 +1,23 @@
+2013-01-16 Ken Kania <[email protected]>
+
+ [Inspector] Add events for tracking page loads and scheduled navigations.
+ https://bugs.webkit.org/show_bug.cgi?id=104168
+
+ Reviewed by Pavel Feldman.
+
+ These events are needed for clients who need to be aware of when a page is
+ navigating or about to navigate. Some clients may wish to prevent interaction
+ with the page during this time. Two of the new events track loading start and
+ stop, as measured by the ProgressTracker. The other two events track when a
+ page has a new scheduled navigation and when it no longer has a scheduled
+ navigation. These latter two events won't allow the client to determine if
+ a load is going to happen in all circumstances, but is sufficient for many cases.
+
+ * inspector-protocol/page/frameScheduledNavigation-expected.txt: Added.
+ * inspector-protocol/page/frameScheduledNavigation.html: Added.
+ * inspector-protocol/page/frameStartedLoading-expected.txt: Added.
+ * inspector-protocol/page/frameStartedLoading.html: Added.
+
2013-01-16 Zan Dobersek <[email protected]>
Unreviewed GTK gardening.
Added: trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation-expected.txt (0 => 139853)
--- trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation-expected.txt 2013-01-16 09:50:19 UTC (rev 139853)
@@ -0,0 +1,5 @@
+
+Scheduled navigation with delay 0
+Started loading
+Cleared scheduled navigation
+
Added: trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation.html (0 => 139853)
--- trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/frameScheduledNavigation.html 2013-01-16 09:50:19 UTC (rev 139853)
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+function load()
+{
+ document.querySelector("iframe").src = ""
+}
+
+function test()
+{
+ InspectorTest.eventHandler["Page.frameScheduledNavigation"] = onScheduled;
+ InspectorTest.eventHandler["Page.frameStartedLoading"] = onStarted;
+ InspectorTest.eventHandler["Page.frameClearedScheduledNavigation"] = onCleared;
+ InspectorTest.sendCommand("Page.enable", {});
+
+ function onScheduled(msg)
+ {
+ InspectorTest.log("Scheduled navigation with delay " + msg.params.delay);
+ }
+
+ function onStarted(msg)
+ {
+ // This event should be received before the scheduled navigation is cleared.
+ InspectorTest.log("Started loading");
+ }
+
+ function onCleared(msg)
+ {
+ InspectorTest.log("Cleared scheduled navigation");
+ InspectorTest.completeTest();
+ }
+
+ InspectorTest.sendCommand("Runtime.evaluate", { "_expression_": "load()" });
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<iframe>
+</body>
+</html>
Added: trunk/LayoutTests/inspector-protocol/page/frameStartedLoading-expected.txt (0 => 139853)
--- trunk/LayoutTests/inspector-protocol/page/frameStartedLoading-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/frameStartedLoading-expected.txt 2013-01-16 09:50:19 UTC (rev 139853)
@@ -0,0 +1,4 @@
+
+Started loading
+Stopped loading
+
Added: trunk/LayoutTests/inspector-protocol/page/frameStartedLoading.html (0 => 139853)
--- trunk/LayoutTests/inspector-protocol/page/frameStartedLoading.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/frameStartedLoading.html 2013-01-16 09:50:19 UTC (rev 139853)
@@ -0,0 +1,36 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+function load()
+{
+ var frame = document.createElement("iframe");
+ frame.src = ""
+ document.body.appendChild(frame);
+}
+
+function test()
+{
+ InspectorTest.eventHandler["Page.frameStartedLoading"] = onStart;
+ InspectorTest.eventHandler["Page.frameStoppedLoading"] = onStop;
+ InspectorTest.sendCommand("Page.enable", {});
+
+ function onStart()
+ {
+ InspectorTest.log("Started loading");
+ }
+ function onStop()
+ {
+ InspectorTest.log("Stopped loading");
+ InspectorTest.completeTest();
+ }
+
+ InspectorTest.sendCommand("Runtime.evaluate", { "_expression_": "load()" });
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (139852 => 139853)
--- trunk/Source/WebCore/ChangeLog 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/ChangeLog 2013-01-16 09:50:19 UTC (rev 139853)
@@ -1,3 +1,57 @@
+2013-01-16 Ken Kania <[email protected]>
+
+ [Inspector] Add events for tracking page loads and scheduled navigations.
+ https://bugs.webkit.org/show_bug.cgi?id=104168
+
+ Reviewed by Pavel Feldman.
+
+ These events are needed for clients who need to be aware of when a page is
+ navigating or about to navigate. Some clients may wish to prevent interaction
+ with the page during this time. Two of the new events track loading start and
+ stop, as measured by the ProgressTracker. The other two events track when a
+ page has a new scheduled navigation and when it no longer has a scheduled
+ navigation. These latter two events won't allow the client to determine if
+ a load is going to happen in all circumstances, but is sufficient for many cases.
+
+ Tests: inspector-protocol/page/frameScheduledNavigation.html
+ inspector-protocol/page/frameStartedLoading.html
+
+ * inspector/Inspector.json:
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore):
+ (WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
+ (WebCore::InspectorInstrumentation::frameStoppedLoadingImpl):
+ (WebCore::InspectorInstrumentation::frameScheduledNavigationImpl):
+ (WebCore::InspectorInstrumentation::frameClearedScheduledNavigationImpl):
+ * inspector/InspectorInstrumentation.h:
+ (InspectorInstrumentation):
+ (WebCore::InspectorInstrumentation::frameStartedLoading):
+ (WebCore):
+ (WebCore::InspectorInstrumentation::frameStoppedLoading):
+ (WebCore::InspectorInstrumentation::frameScheduledNavigation):
+ (WebCore::InspectorInstrumentation::frameClearedScheduledNavigation):
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::frameStartedLoading):
+ (WebCore):
+ (WebCore::InspectorPageAgent::frameStoppedLoading):
+ (WebCore::InspectorPageAgent::frameScheduledNavigation):
+ (WebCore::InspectorPageAgent::frameClearedScheduledNavigation):
+ * inspector/InspectorPageAgent.h:
+ * inspector/front-end/ResourceTreeModel.js:
+ (WebInspector.PageDispatcher.prototype.frameDetached):
+ (WebInspector.PageDispatcher.prototype.frameStartedLoading):
+ (WebInspector.PageDispatcher.prototype.frameStoppedLoading):
+ (WebInspector.PageDispatcher.prototype.frameScheduledNavigation):
+ (WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation):
+ * loader/NavigationScheduler.cpp:
+ (WebCore::NavigationScheduler::clear):
+ (WebCore::NavigationScheduler::timerFired):
+ (WebCore::NavigationScheduler::startTimer):
+ (WebCore::NavigationScheduler::cancel):
+ * loader/ProgressTracker.cpp:
+ (WebCore::ProgressTracker::progressStarted):
+ (WebCore::ProgressTracker::finalProgressComplete):
+
2013-01-16 Tommy Widenflycht <[email protected]>
MediaStream API: Update MediaStreamTrack::readyState to match specification
Modified: trunk/Source/WebCore/inspector/Inspector.json (139852 => 139853)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-01-16 09:50:19 UTC (rev 139853)
@@ -494,6 +494,39 @@
{ "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has been detached." }
],
"hidden": true
+ },
+ {
+ "name": "frameStartedLoading",
+ "description": "Fired when frame has started loading.",
+ "parameters": [
+ { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has started loading." }
+ ],
+ "hidden": true
+ },
+ {
+ "name": "frameStoppedLoading",
+ "description": "Fired when frame has stopped loading.",
+ "parameters": [
+ { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has stopped loading." }
+ ],
+ "hidden": true
+ },
+ {
+ "name": "frameScheduledNavigation",
+ "description": "Fired when frame schedules a potential navigation.",
+ "parameters": [
+ { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has scheduled a navigation." },
+ { "name": "delay", "type": "number", "description": "Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start." }
+ ],
+ "hidden": true
+ },
+ {
+ "name": "frameClearedScheduledNavigation",
+ "description": "Fired when frame no longer has a scheduled navigation.",
+ "parameters": [
+ { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
+ ],
+ "hidden": true
}
]
},
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (139852 => 139853)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-01-16 09:50:19 UTC (rev 139853)
@@ -927,6 +927,30 @@
inspectorPageAgent->loaderDetachedFromFrame(loader);
}
+void InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
+{
+ if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+ inspectorPageAgent->frameStartedLoading(frame);
+}
+
+void InspectorInstrumentation::frameStoppedLoadingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
+{
+ if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+ inspectorPageAgent->frameStoppedLoading(frame);
+}
+
+void InspectorInstrumentation::frameScheduledNavigationImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, double delay)
+{
+ if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+ inspectorPageAgent->frameScheduledNavigation(frame, delay);
+}
+
+void InspectorInstrumentation::frameClearedScheduledNavigationImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
+{
+ if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+ inspectorPageAgent->frameClearedScheduledNavigation(frame);
+}
+
void InspectorInstrumentation::willDestroyCachedResourceImpl(CachedResource* cachedResource)
{
if (!instrumentingAgentsSet)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (139852 => 139853)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2013-01-16 09:50:19 UTC (rev 139853)
@@ -191,6 +191,10 @@
static void frameDetachedFromParent(Frame*);
static void didCommitLoad(Frame*, DocumentLoader*);
static void loaderDetachedFromFrame(Frame*, DocumentLoader*);
+ static void frameStartedLoading(Frame*);
+ static void frameStoppedLoading(Frame*);
+ static void frameScheduledNavigation(Frame*, double delay);
+ static void frameClearedScheduledNavigation(Frame*);
static void willDestroyCachedResource(CachedResource*);
static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
@@ -390,6 +394,10 @@
static void frameDetachedFromParentImpl(InstrumentingAgents*, Frame*);
static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
static void loaderDetachedFromFrameImpl(InstrumentingAgents*, DocumentLoader*);
+ static void frameStartedLoadingImpl(InstrumentingAgents*, Frame*);
+ static void frameStoppedLoadingImpl(InstrumentingAgents*, Frame*);
+ static void frameScheduledNavigationImpl(InstrumentingAgents*, Frame*, double delay);
+ static void frameClearedScheduledNavigationImpl(InstrumentingAgents*, Frame*);
static void willDestroyCachedResourceImpl(CachedResource*);
static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine, Frame*);
@@ -1651,6 +1659,38 @@
#endif
}
+inline void InspectorInstrumentation::frameStartedLoading(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+ frameStartedLoadingImpl(instrumentingAgents, frame);
+#endif
+}
+
+inline void InspectorInstrumentation::frameStoppedLoading(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+ frameStoppedLoadingImpl(instrumentingAgents, frame);
+#endif
+}
+
+inline void InspectorInstrumentation::frameScheduledNavigation(Frame* frame, double delay)
+{
+#if ENABLE(INSPECTOR)
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+ frameScheduledNavigationImpl(instrumentingAgents, frame, delay);
+#endif
+}
+
+inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+ frameClearedScheduledNavigationImpl(instrumentingAgents, frame);
+#endif
+}
+
inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource* cachedResource)
{
#if ENABLE(INSPECTOR)
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (139852 => 139853)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-01-16 09:50:19 UTC (rev 139853)
@@ -900,6 +900,26 @@
m_loaderToIdentifier.remove(iterator);
}
+void InspectorPageAgent::frameStartedLoading(Frame* frame)
+{
+ m_frontend->frameStartedLoading(frameId(frame));
+}
+
+void InspectorPageAgent::frameStoppedLoading(Frame* frame)
+{
+ m_frontend->frameStoppedLoading(frameId(frame));
+}
+
+void InspectorPageAgent::frameScheduledNavigation(Frame* frame, double delay)
+{
+ m_frontend->frameScheduledNavigation(frameId(frame), delay);
+}
+
+void InspectorPageAgent::frameClearedScheduledNavigation(Frame* frame)
+{
+ m_frontend->frameClearedScheduledNavigation(frameId(frame));
+}
+
void InspectorPageAgent::applyScreenWidthOverride(long* width)
{
long widthOverride = m_state->getLong(PageAgentState::pageAgentScreenWidthOverride);
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (139852 => 139853)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-01-16 09:50:19 UTC (rev 139853)
@@ -138,6 +138,10 @@
void frameNavigated(DocumentLoader*);
void frameDetached(Frame*);
void loaderDetachedFromFrame(DocumentLoader*);
+ void frameStartedLoading(Frame*);
+ void frameStoppedLoading(Frame*);
+ void frameScheduledNavigation(Frame*, double delay);
+ void frameClearedScheduledNavigation(Frame*);
void applyScreenWidthOverride(long*);
void applyScreenHeightOverride(long*);
void applyEmulatedMedia(String*);
Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (139852 => 139853)
--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js 2013-01-16 09:50:19 UTC (rev 139853)
@@ -596,6 +596,18 @@
frameDetached: function(frameId)
{
this._resourceTreeModel._frameDetached(frameId);
+ },
+
+ frameStartedLoading: function(frameId) {
+ },
+
+ frameStoppedLoading: function(frameId) {
+ },
+
+ frameScheduledNavigation: function(frameId, delay) {
+ },
+
+ frameClearedScheduledNavigation: function(frameId) {
}
}
Modified: trunk/Source/WebCore/loader/NavigationScheduler.cpp (139852 => 139853)
--- trunk/Source/WebCore/loader/NavigationScheduler.cpp 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp 2013-01-16 09:50:19 UTC (rev 139853)
@@ -45,6 +45,7 @@
#include "HTMLFormElement.h"
#include "HTMLFrameOwnerElement.h"
#include "HistoryItem.h"
+#include "InspectorInstrumentation.h"
#include "Page.h"
#include "UserGestureIndicator.h"
#include <wtf/CurrentTime.h>
@@ -286,6 +287,8 @@
void NavigationScheduler::clear()
{
+ if (m_timer.isActive())
+ InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
m_timer.stop();
m_redirect.clear();
}
@@ -411,11 +414,14 @@
{
if (!m_frame->page())
return;
- if (m_frame->page()->defersLoading())
+ if (m_frame->page()->defersLoading()) {
+ InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
return;
+ }
OwnPtr<ScheduledNavigation> redirect(m_redirect.release());
redirect->fire(m_frame);
+ InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
}
void NavigationScheduler::schedule(PassOwnPtr<ScheduledNavigation> redirect)
@@ -458,10 +464,13 @@
m_timer.startOneShot(m_redirect->delay());
m_redirect->didStartTimer(m_frame, &m_timer);
+ InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->delay());
}
void NavigationScheduler::cancel(bool newLoadInProgress)
{
+ if (m_timer.isActive())
+ InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
m_timer.stop();
OwnPtr<ScheduledNavigation> redirect(m_redirect.release());
Modified: trunk/Source/WebCore/loader/ProgressTracker.cpp (139852 => 139853)
--- trunk/Source/WebCore/loader/ProgressTracker.cpp 2013-01-16 09:47:24 UTC (rev 139852)
+++ trunk/Source/WebCore/loader/ProgressTracker.cpp 2013-01-16 09:50:19 UTC (rev 139853)
@@ -31,6 +31,7 @@
#include "FrameLoader.h"
#include "FrameLoaderStateMachine.h"
#include "FrameLoaderClient.h"
+#include "InspectorInstrumentation.h"
#include "Logging.h"
#include "ResourceResponse.h"
#include <wtf/text/CString.h>
@@ -120,6 +121,7 @@
m_numProgressTrackedFrames++;
frame->loader()->client()->didChangeEstimatedProgress();
+ InspectorInstrumentation::frameStartedLoading(frame);
}
void ProgressTracker::progressCompleted(Frame* frame)
@@ -155,6 +157,7 @@
frame->loader()->client()->setMainFrameDocumentReady(true);
frame->loader()->client()->postProgressFinishedNotification();
+ InspectorInstrumentation::frameStoppedLoading(frame.get());
}
void ProgressTracker::incrementProgress(unsigned long identifier, const ResourceResponse& response)