browser(webkit): bootstrap script in utility world (#6591)
This commit is contained in:
parent
5e84eade85
commit
ffa83f1f17
|
|
@ -1,2 +1,2 @@
|
|||
1479
|
||||
Changed: yurys@chromium.org Fri 14 May 2021 12:49:43 PM PDT
|
||||
1480
|
||||
Changed: yurys@chromium.org Fri 14 May 2021 04:54:36 PM PDT
|
||||
|
|
|
|||
|
|
@ -745,7 +745,7 @@ index 65ab2092b0ffd0ead3da1ddccd398d4f4179f51a..2d9ef40a20df819193c9a5867fbf6f8f
|
|||
],
|
||||
"events": [
|
||||
diff --git a/Source/JavaScriptCore/inspector/protocol/Page.json b/Source/JavaScriptCore/inspector/protocol/Page.json
|
||||
index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060a57af1c9 100644
|
||||
index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..fcb70d73c8a8cb2c543936ac7fe1e7454c2268f3 100644
|
||||
--- a/Source/JavaScriptCore/inspector/protocol/Page.json
|
||||
+++ b/Source/JavaScriptCore/inspector/protocol/Page.json
|
||||
@@ -27,7 +27,7 @@
|
||||
|
|
@ -824,7 +824,17 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
{
|
||||
"name": "navigate",
|
||||
"description": "Navigates current page to the given URL.",
|
||||
@@ -270,6 +323,20 @@
|
||||
@@ -204,7 +257,8 @@
|
||||
"name": "setBootstrapScript",
|
||||
"targetTypes": ["page"],
|
||||
"parameters": [
|
||||
- { "name": "source", "type": "string", "optional": true, "description": "If `source` is provided (and not empty), it will be injected into all future global objects as soon as they're created. Omitting `source` will stop this from happening." }
|
||||
+ { "name": "source", "type": "string", "optional": true, "description": "If `source` is provided (and not empty), it will be injected into all future global objects as soon as they're created. Omitting `source` will stop this from happening." },
|
||||
+ { "name": "worldName", "type": "string", "optional": true, "description": "Isolated world name to evaluate the script in. If not specified main world will be used." }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -270,6 +324,20 @@
|
||||
{ "name": "appearance", "$ref": "Appearance", "optional": true }
|
||||
]
|
||||
},
|
||||
|
|
@ -845,7 +855,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
{
|
||||
"name": "snapshotNode",
|
||||
"description": "Capture a snapshot of the specified node that does not include unrelated layers.",
|
||||
@@ -290,7 +357,8 @@
|
||||
@@ -290,7 +358,8 @@
|
||||
{ "name": "y", "type": "integer", "description": "Y coordinate" },
|
||||
{ "name": "width", "type": "integer", "description": "Rectangle width" },
|
||||
{ "name": "height", "type": "integer", "description": "Rectangle height" },
|
||||
|
|
@ -855,7 +865,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
],
|
||||
"returns": [
|
||||
{ "name": "dataURL", "type": "string", "description": "Base64-encoded image data (PNG)." }
|
||||
@@ -308,12 +376,77 @@
|
||||
@@ -308,12 +377,77 @@
|
||||
{
|
||||
"name": "setScreenSizeOverride",
|
||||
"description": "Overrides screen size exposed to DOM and used in media queries for testing with provided values.",
|
||||
|
|
@ -934,7 +944,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
}
|
||||
],
|
||||
"events": [
|
||||
@@ -321,14 +454,16 @@
|
||||
@@ -321,14 +455,16 @@
|
||||
"name": "domContentEventFired",
|
||||
"targetTypes": ["page"],
|
||||
"parameters": [
|
||||
|
|
@ -953,7 +963,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
]
|
||||
},
|
||||
{
|
||||
@@ -338,6 +473,14 @@
|
||||
@@ -338,6 +474,14 @@
|
||||
{ "name": "frame", "$ref": "Frame", "description": "Frame object." }
|
||||
]
|
||||
},
|
||||
|
|
@ -968,7 +978,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
{
|
||||
"name": "frameDetached",
|
||||
"description": "Fired when frame has been detached from its parent.",
|
||||
@@ -377,6 +520,22 @@
|
||||
@@ -377,6 +521,22 @@
|
||||
{ "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
|
||||
]
|
||||
},
|
||||
|
|
@ -991,7 +1001,7 @@ index db52479a72d459be23d4d8d080c0ed15ea9fc4c0..ecabf75f9a3a89194c033cf7cc3a4060
|
|||
{
|
||||
"name": "defaultAppearanceDidChange",
|
||||
"description": "Fired when page's default appearance changes, even if there is a forced appearance.",
|
||||
@@ -385,6 +544,28 @@
|
||||
@@ -385,6 +545,28 @@
|
||||
"parameters": [
|
||||
{ "name": "appearance", "$ref": "Appearance", "description": "Name of the appearance that is active (not considering any forced appearance.)" }
|
||||
]
|
||||
|
|
@ -3288,7 +3298,7 @@ index 933601761667417ebe5de301586869ccc64fc3da..f63a95c3c45980d5606971b83881e824
|
|||
// InspectorInstrumentation
|
||||
void willRecalculateStyle();
|
||||
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
|
||||
index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d719caf6a78 100644
|
||||
index af0a051bdae52b2daf70b1fee76eee0866b7b046..875becfd5de4581fe40394d98601cb7206af5be6 100644
|
||||
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
|
||||
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
|
||||
@@ -32,19 +32,25 @@
|
||||
|
|
@ -3424,7 +3434,23 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
Protocol::ErrorStringOr<void> InspectorPageAgent::navigate(const String& url)
|
||||
{
|
||||
UserGestureIndicator indicator { ProcessingUserGesture };
|
||||
@@ -801,15 +847,16 @@ Protocol::ErrorStringOr<void> InspectorPageAgent::setShowPaintRects(bool show)
|
||||
@@ -696,9 +742,13 @@ Protocol::ErrorStringOr<std::tuple<String, bool /* base64Encoded */>> InspectorP
|
||||
return { { content, base64Encoded } };
|
||||
}
|
||||
|
||||
-Protocol::ErrorStringOr<void> InspectorPageAgent::setBootstrapScript(const String& source)
|
||||
+Protocol::ErrorStringOr<void> InspectorPageAgent::setBootstrapScript(const String& source, const String& worldName)
|
||||
{
|
||||
- m_bootstrapScript = source;
|
||||
+ String key = worldName.isNull() ? emptyString() : worldName;
|
||||
+ if (source.isEmpty())
|
||||
+ m_worldNameToBootstrapScript.remove(key);
|
||||
+ else
|
||||
+ m_worldNameToBootstrapScript.set(key, source);
|
||||
|
||||
return { };
|
||||
}
|
||||
@@ -801,15 +851,16 @@ Protocol::ErrorStringOr<void> InspectorPageAgent::setShowPaintRects(bool show)
|
||||
return { };
|
||||
}
|
||||
|
||||
|
|
@ -3446,7 +3472,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
}
|
||||
|
||||
void InspectorPageAgent::frameNavigated(Frame& frame)
|
||||
@@ -817,13 +864,23 @@ void InspectorPageAgent::frameNavigated(Frame& frame)
|
||||
@@ -817,13 +868,23 @@ void InspectorPageAgent::frameNavigated(Frame& frame)
|
||||
m_frontendDispatcher->frameNavigated(buildObjectForFrame(&frame));
|
||||
}
|
||||
|
||||
|
|
@ -3473,7 +3499,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
}
|
||||
|
||||
Frame* InspectorPageAgent::frameForId(const Protocol::Network::FrameId& frameId)
|
||||
@@ -835,20 +892,18 @@ String InspectorPageAgent::frameId(Frame* frame)
|
||||
@@ -835,20 +896,18 @@ String InspectorPageAgent::frameId(Frame* frame)
|
||||
{
|
||||
if (!frame)
|
||||
return emptyString();
|
||||
|
|
@ -3500,7 +3526,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
}
|
||||
|
||||
Frame* InspectorPageAgent::assertFrame(Protocol::ErrorString& errorString, const Protocol::Network::FrameId& frameId)
|
||||
@@ -859,11 +914,6 @@ Frame* InspectorPageAgent::assertFrame(Protocol::ErrorString& errorString, const
|
||||
@@ -859,11 +918,6 @@ Frame* InspectorPageAgent::assertFrame(Protocol::ErrorString& errorString, const
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
|
@ -3512,7 +3538,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
void InspectorPageAgent::frameStartedLoading(Frame& frame)
|
||||
{
|
||||
m_frontendDispatcher->frameStartedLoading(frameId(&frame));
|
||||
@@ -884,6 +934,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)
|
||||
@@ -884,6 +938,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)
|
||||
m_frontendDispatcher->frameClearedScheduledNavigation(frameId(&frame));
|
||||
}
|
||||
|
||||
|
|
@ -3525,7 +3551,33 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
#if ENABLE(DARK_MODE_CSS) || HAVE(OS_DARK_MODE_SUPPORT)
|
||||
void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)
|
||||
{
|
||||
@@ -943,6 +999,52 @@ void InspectorPageAgent::didRecalculateStyle()
|
||||
@@ -893,13 +953,22 @@ void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)
|
||||
|
||||
void InspectorPageAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
|
||||
{
|
||||
- if (&world != &mainThreadNormalWorld())
|
||||
+ if (m_worldNameToBootstrapScript.isEmpty())
|
||||
return;
|
||||
|
||||
- if (m_bootstrapScript.isEmpty())
|
||||
+ if (world.name().isEmpty() && &world != &mainThreadNormalWorld())
|
||||
+ return;
|
||||
+
|
||||
+ String worldName = world.name();
|
||||
+ // Null string cannot be used as a key.
|
||||
+ if (worldName.isNull())
|
||||
+ worldName = emptyString();
|
||||
+
|
||||
+ if (!m_worldNameToBootstrapScript.contains(worldName))
|
||||
return;
|
||||
|
||||
- frame.script().evaluateIgnoringException(ScriptSourceCode(m_bootstrapScript, URL { URL(), "web-inspector://bootstrap.js"_s }));
|
||||
+ String bootstrapScript = m_worldNameToBootstrapScript.get(worldName);
|
||||
+ frame.script().evaluateInWorldIgnoringException(ScriptSourceCode(bootstrapScript, URL { URL(), "web-inspector://bootstrap.js"_s }), world);
|
||||
}
|
||||
|
||||
void InspectorPageAgent::didPaint(RenderObject& renderer, const LayoutRect& rect)
|
||||
@@ -943,6 +1012,52 @@ void InspectorPageAgent::didRecalculateStyle()
|
||||
m_overlay->update();
|
||||
}
|
||||
|
||||
|
|
@ -3578,7 +3630,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
Ref<Protocol::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
|
||||
{
|
||||
ASSERT_ARG(frame, frame);
|
||||
@@ -1079,11 +1181,13 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotNode(Protocol::DOM::
|
||||
@@ -1079,11 +1194,13 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotNode(Protocol::DOM::
|
||||
return snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
|
||||
}
|
||||
|
||||
|
|
@ -3593,7 +3645,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
|
||||
IntRect rectangle(x, y, width, height);
|
||||
auto snapshot = snapshotFrameRect(m_inspectedPage.mainFrame(), rectangle, options);
|
||||
@@ -1094,6 +1198,27 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotRect(int x, int y, i
|
||||
@@ -1094,6 +1211,27 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotRect(int x, int y, i
|
||||
return snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
|
||||
}
|
||||
|
||||
|
|
@ -3621,7 +3673,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
#if ENABLE(WEB_ARCHIVE) && USE(CF)
|
||||
Protocol::ErrorStringOr<String> InspectorPageAgent::archive()
|
||||
{
|
||||
@@ -1106,7 +1231,6 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::archive()
|
||||
@@ -1106,7 +1244,6 @@ Protocol::ErrorStringOr<String> InspectorPageAgent::archive()
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3629,7 +3681,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
Protocol::ErrorStringOr<void> InspectorPageAgent::setScreenSizeOverride(Optional<int>&& width, Optional<int>&& height)
|
||||
{
|
||||
if (width.hasValue() != height.hasValue())
|
||||
@@ -1121,6 +1245,595 @@ Protocol::ErrorStringOr<void> InspectorPageAgent::setScreenSizeOverride(Optional
|
||||
@@ -1121,6 +1258,595 @@ Protocol::ErrorStringOr<void> InspectorPageAgent::setScreenSizeOverride(Optional
|
||||
m_inspectedPage.mainFrame().setOverrideScreenSize(FloatSize(width.valueOr(0), height.valueOr(0)));
|
||||
return { };
|
||||
}
|
||||
|
|
@ -4226,7 +4278,7 @@ index af0a051bdae52b2daf70b1fee76eee0866b7b046..a51cb302362e011b6e6aac5273f15d71
|
|||
|
||||
} // namespace WebCore
|
||||
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h
|
||||
index 78a98224ab5450e0729751571fe1bb957d303301..b557b0fed3f61ce4d842e6a70dcabd7cffa993c2 100644
|
||||
index 78a98224ab5450e0729751571fe1bb957d303301..b60b69f2467526b73aad323c531055b4fec173eb 100644
|
||||
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h
|
||||
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h
|
||||
@@ -34,17 +34,23 @@
|
||||
|
|
@ -4277,6 +4329,15 @@ index 78a98224ab5450e0729751571fe1bb957d303301..b557b0fed3f61ce4d842e6a70dcabd7c
|
|||
Inspector::Protocol::ErrorStringOr<void> navigate(const String& url);
|
||||
Inspector::Protocol::ErrorStringOr<void> overrideUserAgent(const String&);
|
||||
Inspector::Protocol::ErrorStringOr<void> overrideSetting(Inspector::Protocol::Page::Setting, Optional<bool>&& value);
|
||||
@@ -103,7 +113,7 @@ public:
|
||||
Inspector::Protocol::ErrorStringOr<void> deleteCookie(const String& cookieName, const String& url);
|
||||
Inspector::Protocol::ErrorStringOr<Ref<Inspector::Protocol::Page::FrameResourceTree>> getResourceTree();
|
||||
Inspector::Protocol::ErrorStringOr<std::tuple<String, bool /* base64Encoded */>> getResourceContent(const Inspector::Protocol::Network::FrameId&, const String& url);
|
||||
- Inspector::Protocol::ErrorStringOr<void> setBootstrapScript(const String& source);
|
||||
+ Inspector::Protocol::ErrorStringOr<void> setBootstrapScript(const String& source, const String& worldName);
|
||||
Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>>> searchInResource(const Inspector::Protocol::Network::FrameId&, const String& url, const String& query, Optional<bool>&& caseSensitive, Optional<bool>&& isRegex, const Inspector::Protocol::Network::RequestId&);
|
||||
Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>>> searchInResources(const String&, Optional<bool>&& caseSensitive, Optional<bool>&& isRegex);
|
||||
#if !PLATFORM(IOS_FAMILY)
|
||||
@@ -114,25 +124,35 @@ public:
|
||||
#if ENABLE(DARK_MODE_CSS) || HAVE(OS_DARK_MODE_SUPPORT)
|
||||
Inspector::Protocol::ErrorStringOr<void> setForcedAppearance(Optional<Inspector::Protocol::Page::Appearance>&&);
|
||||
|
|
@ -4352,9 +4413,10 @@ index 78a98224ab5450e0729751571fe1bb957d303301..b557b0fed3f61ce4d842e6a70dcabd7c
|
|||
- HashMap<Frame*, String> m_frameToIdentifier;
|
||||
HashMap<String, WeakPtr<Frame>> m_identifierToFrame;
|
||||
- HashMap<DocumentLoader*, String> m_loaderToIdentifier;
|
||||
+ HashMap<String, String> m_worldNameToBootstrapScript;
|
||||
String m_userAgentOverride;
|
||||
String m_emulatedMedia;
|
||||
String m_bootstrapScript;
|
||||
- String m_bootstrapScript;
|
||||
bool m_isFirstLayoutAfterOnLoad { false };
|
||||
bool m_showPaintRects { false };
|
||||
+ bool m_interceptFileChooserDialog { false };
|
||||
|
|
|
|||
Loading…
Reference in a new issue