fix(webkit): report stopped loading in subframes, force context on failure (#259)

This commit is contained in:
Yury Semikhatsky 2019-12-16 15:22:45 -07:00 committed by GitHub
parent 67fc9aeff7
commit 6b9f475217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 119 additions and 27 deletions

View File

@ -1 +1 @@
1038
1039

View File

@ -999,7 +999,7 @@ index 4e41fd3f807..1f7be602cb2 100644
return;
diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp
index 4f18b58c6cd..66ce7d20b32 100644
index 4f18b58c6cd..9c018c1a51d 100644
--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp
+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp
@@ -121,7 +121,7 @@ static Frame* frameForScriptExecutionContext(ScriptExecutionContext& context)
@ -1011,7 +1011,20 @@ index 4f18b58c6cd..66ce7d20b32 100644
return;
if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
@@ -656,20 +656,17 @@ void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents&
@@ -624,6 +624,12 @@ void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents& instrumen
consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
}
+void InspectorInstrumentation::didReceiveMainResourceErrorImpl(InstrumentingAgents& instrumentingAgents, Frame& frame,const ResourceError& error)
+{
+ if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())
+ pageRuntimeAgent->didReceiveMainResourceError(frame);
+}
+
void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents& instrumentingAgents)
{
if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
@@ -656,20 +662,17 @@ void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents&
void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
{
@ -1035,7 +1048,7 @@ index 4f18b58c6cd..66ce7d20b32 100644
}
void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
@@ -786,6 +783,12 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(Instrumenting
@@ -786,6 +789,12 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(Instrumenting
inspectorPageAgent->frameClearedScheduledNavigation(frame);
}
@ -1048,7 +1061,7 @@ index 4f18b58c6cd..66ce7d20b32 100644
void InspectorInstrumentation::defaultAppearanceDidChangeImpl(InstrumentingAgents& instrumentingAgents, bool useDarkAppearance)
{
if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
@@ -1266,6 +1269,24 @@ void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents& ins
@@ -1266,6 +1275,24 @@ void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents& ins
layerTreeAgent->renderLayerDestroyed(renderLayer);
}
@ -1074,7 +1087,7 @@ index 4f18b58c6cd..66ce7d20b32 100644
{
return workerGlobalScope.inspectorController().m_instrumentingAgents;
diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h
index dbf82205db5..e11172818f1 100644
index dbf82205db5..b323d29ac8d 100644
--- a/Source/WebCore/inspector/InspectorInstrumentation.h
+++ b/Source/WebCore/inspector/InspectorInstrumentation.h
@@ -77,6 +77,7 @@ class DOMWrapperWorld;
@ -1085,7 +1098,15 @@ index dbf82205db5..e11172818f1 100644
class HTTPHeaderMap;
class InspectorTimelineAgent;
class InstrumentingAgents;
@@ -228,6 +229,7 @@ public:
@@ -197,6 +198,7 @@ public:
static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
+ static void didReceiveMainResourceError(Frame&, const ResourceError&);
static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
@@ -228,6 +230,7 @@ public:
static void frameStoppedLoading(Frame&);
static void frameScheduledNavigation(Frame&, Seconds delay);
static void frameClearedScheduledNavigation(Frame&);
@ -1093,7 +1114,7 @@ index dbf82205db5..e11172818f1 100644
static void defaultAppearanceDidChange(Page&, bool useDarkAppearance);
static void willDestroyCachedResource(CachedResource&);
@@ -314,6 +316,10 @@ public:
@@ -314,6 +317,10 @@ public:
static void layerTreeDidChange(Page*);
static void renderLayerDestroyed(Page*, const RenderLayer&);
@ -1104,7 +1125,15 @@ index dbf82205db5..e11172818f1 100644
static void frontendCreated();
static void frontendDeleted();
static bool hasFrontends() { return InspectorInstrumentationPublic::hasFrontends(); }
@@ -429,6 +435,7 @@ private:
@@ -414,6 +421,7 @@ private:
static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
+ static void didReceiveMainResourceErrorImpl(InstrumentingAgents&, Frame&, const ResourceError&);
static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
@@ -429,6 +437,7 @@ private:
static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
@ -1112,7 +1141,7 @@ index dbf82205db5..e11172818f1 100644
static void defaultAppearanceDidChangeImpl(InstrumentingAgents&, bool useDarkAppearance);
static void willDestroyCachedResourceImpl(CachedResource&);
@@ -511,6 +518,10 @@ private:
@@ -511,6 +520,10 @@ private:
static void layerTreeDidChangeImpl(InstrumentingAgents&);
static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
@ -1123,7 +1152,21 @@ index dbf82205db5..e11172818f1 100644
static InstrumentingAgents& instrumentingAgentsForPage(Page&);
static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
@@ -1221,6 +1232,13 @@ inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& fra
@@ -1091,6 +1104,13 @@ inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoade
didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
}
+inline void InspectorInstrumentation::didReceiveMainResourceError(Frame& frame, const ResourceError& error)
+{
+ FAST_RETURN_IF_NO_FRONTENDS(void());
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+ didReceiveMainResourceErrorImpl(*instrumentingAgents, frame, error);
+}
+
inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
{
didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
@@ -1221,6 +1241,13 @@ inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& fra
frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
}
@ -1137,7 +1180,7 @@ index dbf82205db5..e11172818f1 100644
inline void InspectorInstrumentation::defaultAppearanceDidChange(Page& page, bool useDarkAppearance)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
@@ -1650,6 +1668,28 @@ inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const Ren
@@ -1650,6 +1677,28 @@ inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const Ren
renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
}
@ -2259,10 +2302,17 @@ index 4fd8c0b1016..9954be9e35a 100644
} // namespace WebCore
diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
index b4b9d5cd9b1..e26ed4d2c23 100644
index b4b9d5cd9b1..0d52dc1d526 100644
--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
@@ -40,6 +40,7 @@
@@ -34,12 +34,14 @@
#include "Document.h"
#include "Frame.h"
+#include "FrameLoader.h"
#include "InspectorPageAgent.h"
#include "InstrumentingAgents.h"
#include "JSDOMWindowBase.h"
#include "Page.h"
#include "PageConsoleClient.h"
#include "ScriptController.h"
@ -2270,7 +2320,7 @@ index b4b9d5cd9b1..e26ed4d2c23 100644
#include "ScriptState.h"
#include "SecurityOrigin.h"
#include "UserGestureEmulationScope.h"
@@ -70,14 +71,12 @@ PageRuntimeAgent::~PageRuntimeAgent() = default;
@@ -70,14 +72,12 @@ PageRuntimeAgent::~PageRuntimeAgent() = default;
void PageRuntimeAgent::enable(ErrorString& errorString)
{
@ -2288,7 +2338,7 @@ index b4b9d5cd9b1..e26ed4d2c23 100644
}
void PageRuntimeAgent::disable(ErrorString& errorString)
@@ -99,9 +98,15 @@ void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame)
@@ -99,9 +99,24 @@ void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame)
if (!pageAgent)
return;
@ -2303,10 +2353,19 @@ index b4b9d5cd9b1..e26ed4d2c23 100644
+ // Create user worlds.
+ for (auto pair : pageAgent->isolatedWorldScripts())
+ createIsolatedWorld(frame, pair.key, pair.value);
+}
+
+void PageRuntimeAgent::didReceiveMainResourceError(Frame& frame)
+{
+ if (frame.loader().stateMachine().isDisplayingInitialEmptyDocument()) {
+ // Ensure execution context is created for the empty docment to make
+ // it usable in case loading failed.
+ mainWorldExecState(&frame);
+ }
}
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
@@ -138,36 +143,38 @@ void PageRuntimeAgent::reportExecutionContextCreation()
@@ -138,36 +153,38 @@ void PageRuntimeAgent::reportExecutionContextCreation()
Vector<std::pair<JSC::JSGlobalObject*, SecurityOrigin*>> isolatedContexts;
for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
@ -2358,7 +2417,7 @@ index b4b9d5cd9b1..e26ed4d2c23 100644
.setFrameId(frameId)
.release());
}
@@ -184,4 +191,13 @@ void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& ob
@@ -184,4 +201,13 @@ void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& ob
InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
}
@ -2373,15 +2432,17 @@ index b4b9d5cd9b1..e26ed4d2c23 100644
+
} // namespace WebCore
diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
index 54a00e05828..82189bf260d 100644
index 54a00e05828..df0aa6dbd78 100644
--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
@@ -63,16 +63,17 @@ public:
@@ -62,17 +62,19 @@ public:
// InspectorInstrumentation
void frameNavigated(Frame&);
void didClearWindowObjectInWorld(Frame&);
+ void createIsolatedWorld(Frame& frame, const String& name, const String& source);
+ void didReceiveMainResourceError(Frame&);
+
+ void createIsolatedWorld(Frame& frame, const String& name, const String& source);
private:
Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
void muteConsole() override;
@ -2397,7 +2458,7 @@ index 54a00e05828..82189bf260d 100644
Page& m_inspectedPage;
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 0f1f281a594..db269b0ad45 100644
index 0f1f281a594..d3d08f344a2 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -1203,6 +1203,7 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat
@ -2408,7 +2469,16 @@ index 0f1f281a594..db269b0ad45 100644
m_frame.document()->statePopped(stateObject ? Ref<SerializedScriptValue> { *stateObject } : SerializedScriptValue::nullValue());
m_client.dispatchDidPopStateWithinPage();
@@ -3971,9 +3972,6 @@ String FrameLoader::referrer() const
@@ -3205,6 +3206,8 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error)
checkCompleted();
if (m_frame.page())
checkLoadComplete();
+
+ InspectorInstrumentation::didReceiveMainResourceError(m_frame, error);
}
void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
@@ -3971,9 +3974,6 @@ String FrameLoader::referrer() const
void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
{
@ -2418,17 +2488,17 @@ index 0f1f281a594..db269b0ad45 100644
Vector<Ref<DOMWrapperWorld>> worlds;
ScriptController::getAllWorlds(worlds);
for (auto& world : worlds)
@@ -3982,13 +3980,12 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
@@ -3982,13 +3982,12 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
{
- if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame.windowProxy().existingJSWindowProxy(world))
- return;
-
- m_client.dispatchDidClearWindowObjectInWorld(world);
+ if (m_frame.script().canExecuteScripts(NotAboutToExecuteScript) && m_frame.windowProxy().existingJSWindowProxy(world)) {
+ m_client.dispatchDidClearWindowObjectInWorld(world);
- m_client.dispatchDidClearWindowObjectInWorld(world);
-
- if (Page* page = m_frame.page())
- page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
+ if (Page* page = m_frame.page())
@ -2437,6 +2507,28 @@ index 0f1f281a594..db269b0ad45 100644
InspectorInstrumentation::didClearWindowObjectInWorld(m_frame, world);
}
diff --git a/Source/WebCore/loader/ProgressTracker.cpp b/Source/WebCore/loader/ProgressTracker.cpp
index e24fded2225..30e4b7a9864 100644
--- a/Source/WebCore/loader/ProgressTracker.cpp
+++ b/Source/WebCore/loader/ProgressTracker.cpp
@@ -154,6 +154,8 @@ void ProgressTracker::progressCompleted(Frame& frame)
if (!m_numProgressTrackedFrames || m_originatingProgressFrame == &frame)
finalProgressComplete();
+ InspectorInstrumentation::frameStoppedLoading(frame);
+
m_client->didChangeEstimatedProgress();
}
@@ -179,8 +181,6 @@ void ProgressTracker::finalProgressComplete()
frame->loader().client().setMainFrameDocumentReady(true);
m_client->progressFinished(*frame);
frame->loader().loadProgressingStatusChanged();
-
- InspectorInstrumentation::frameStoppedLoading(*frame);
}
void ProgressTracker::incrementProgress(unsigned long identifier, const ResourceResponse& response)
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
index 22cc1fd15bc..4b0e232a19c 100644
--- a/Source/WebCore/page/Frame.cpp