fix(webkit): keep developer extras enabled when changing page preferences (#229)

* fix(webkit): keep developer extras enabled when changing page preferences

* incorporate Pavel's changes to enable inspector eval when js is disabled
This commit is contained in:
Yury Semikhatsky 2019-12-12 13:01:22 -07:00 коммит произвёл Pavel Feldman
Родитель ad067261fc
Коммит af94e7a8c9
2 изменённых файлов: 50 добавлений и 13 удалений

Просмотреть файл

@ -1 +1 @@
1030
1032

Просмотреть файл

@ -2255,7 +2255,7 @@ 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 8c4a104da04..be7c4c35b70 100644
index 8c4a104da04..0481143531b 100644
--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
@@ -40,6 +40,7 @@
@ -2302,10 +2302,13 @@ index 8c4a104da04..be7c4c35b70 100644
}
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
@@ -135,33 +140,38 @@ void PageRuntimeAgent::reportExecutionContextCreation()
if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
continue;
@@ -132,36 +137,38 @@ void PageRuntimeAgent::reportExecutionContextCreation()
Vector<std::pair<JSC::JSGlobalObject*, SecurityOrigin*>> isolatedContexts;
for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
- continue;
-
- String frameId = pageAgent->frameId(frame);
-
JSC::JSGlobalObject* scriptState = mainWorldExecState(frame);
@ -2351,7 +2354,7 @@ index 8c4a104da04..be7c4c35b70 100644
.setFrameId(frameId)
.release());
}
@@ -178,4 +188,13 @@ void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& ob
@@ -178,4 +185,13 @@ void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& ob
InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
}
@ -2390,7 +2393,7 @@ index f38828044b3..3ab4c8cd00a 100644
Page& m_inspectedPage;
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index e105be0ba92..2557eacc4b7 100644
index e105be0ba92..03a5969987d 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -1179,6 +1179,7 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat
@ -2401,6 +2404,35 @@ index e105be0ba92..2557eacc4b7 100644
m_frame.document()->statePopped(stateObject ? Ref<SerializedScriptValue> { *stateObject } : SerializedScriptValue::nullValue());
m_client.dispatchDidPopStateWithinPage();
@@ -3945,9 +3946,6 @@ String FrameLoader::referrer() const
void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
{
- if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript))
- return;
-
Vector<Ref<DOMWrapperWorld>> worlds;
ScriptController::getAllWorlds(worlds);
for (auto& world : worlds)
@@ -3956,13 +3954,12 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
{
- if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame.windowProxy().existingJSWindowProxy(world))
- return;
+ 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())
+ page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
+ }
InspectorInstrumentation::didClearWindowObjectInWorld(m_frame, world);
}
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
index 22cc1fd15bc..4b0e232a19c 100644
--- a/Source/WebCore/page/Frame.cpp
@ -5247,7 +5279,7 @@ index 2c4f9ddabf0..ae9e0b80708 100644
} // namespace WebKit
diff --git a/Source/WebKit/UIProcess/WebPageInspectorController.cpp b/Source/WebKit/UIProcess/WebPageInspectorController.cpp
index 1ee28bf7163..6ac7ab2efd9 100644
index 1ee28bf7163..c1c918d6e2a 100644
--- a/Source/WebKit/UIProcess/WebPageInspectorController.cpp
+++ b/Source/WebKit/UIProcess/WebPageInspectorController.cpp
@@ -26,10 +26,13 @@
@ -5327,7 +5359,7 @@ index 1ee28bf7163..6ac7ab2efd9 100644
bool connectingFirstFrontend = !m_frontendRouter->hasFrontends();
+ if (connectingFirstFrontend)
+ disableBackForwardCache();
+ adjustPageSettings();
+
m_frontendRouter->connectFrontend(frontendChannel);
@ -5372,7 +5404,7 @@ index 1ee28bf7163..6ac7ab2efd9 100644
}
void WebPageInspectorController::willDestroyProvisionalPage(const ProvisionalPageProxy& provisionalPage)
@@ -214,8 +265,17 @@ void WebPageInspectorController::didCommitProvisionalPage(WebCore::PageIdentifie
@@ -214,8 +265,22 @@ void WebPageInspectorController::didCommitProvisionalPage(WebCore::PageIdentifie
void WebPageInspectorController::addTarget(std::unique_ptr<InspectorTargetProxy>&& target)
{
@ -5382,8 +5414,13 @@ index 1ee28bf7163..6ac7ab2efd9 100644
m_targets.set(target->identifier(), WTFMove(target));
}
+void WebPageInspectorController::disableBackForwardCache()
+void WebPageInspectorController::adjustPageSettings()
+{
+ // Set this to true as otherwise updating any preferences will override its
+ // value in the Web Process to false (and InspectorController sets it locally
+ // to true when frontend is connected).
+ m_page.preferences().setDeveloperExtrasEnabled(true);
+
+ // Navigation to cached pages doesn't fire some of the events (e.g. execution context created)
+ // that inspector depends on. So we disable the cache when front-end connects.
+ m_page.preferences().setUsesBackForwardCache(false);
@ -5391,7 +5428,7 @@ index 1ee28bf7163..6ac7ab2efd9 100644
+
} // namespace WebKit
diff --git a/Source/WebKit/UIProcess/WebPageInspectorController.h b/Source/WebKit/UIProcess/WebPageInspectorController.h
index 78caedf0c0c..be5db786c07 100644
index 78caedf0c0c..a380d778c36 100644
--- a/Source/WebKit/UIProcess/WebPageInspectorController.h
+++ b/Source/WebKit/UIProcess/WebPageInspectorController.h
@@ -37,10 +37,22 @@ namespace Inspector {
@ -5443,7 +5480,7 @@ index 78caedf0c0c..be5db786c07 100644
private:
void addTarget(std::unique_ptr<InspectorTargetProxy>&&);
+ void disableBackForwardCache();
+ void adjustPageSettings();
WebPageProxy& m_page;
Ref<Inspector::FrontendRouter> m_frontendRouter;