@@ -2507,7 +2507,7 @@ index a68f84520736977c8b9216616c5a178fbf5275d6..8d6ed7188bca75fb46d1a5963983f088
2507
2507
2508
2508
} // namespace WebCore
2509
2509
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
2510
- index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eeaafa37089 100644
2510
+ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..5809b8726af46cf93007b15cad6904506352b26d 100644
2511
2511
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
2512
2512
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
2513
2513
@@ -32,6 +32,8 @@
@@ -2535,7 +2535,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2535
2535
#include "HTMLNames.h"
2536
2536
#include "ImageBuffer.h"
2537
2537
#include "InspectorClient.h"
2538
- @@ -56,18 +61,24 @@
2538
+ @@ -56,19 +61,28 @@
2539
2539
#include "MIMETypeRegistry.h"
2540
2540
#include "MemoryCache.h"
2541
2541
#include "Page.h"
@@ -2558,17 +2558,53 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2558
2558
#include <JavaScriptCore/RegularExpression.h>
2559
2559
+#include <platform/ProcessIdentifier.h>
2560
2560
#include <wtf/ListHashSet.h>
2561
+ +#include <wtf/NeverDestroyed.h>
2562
+ +#include <wtf/Ref.h>
2563
+ +#include <wtf/RefPtr.h>
2561
2564
#include <wtf/Stopwatch.h>
2562
2565
#include <wtf/text/Base64.h>
2563
- @@ -340,6 +351,7 @@ InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClien
2566
+ #include <wtf/text/StringBuilder.h>
2567
+ @@ -81,7 +95,6 @@
2568
+ #include "LegacyWebArchive.h"
2569
+ #endif
2570
+
2571
+ -
2572
+ namespace WebCore {
2573
+
2574
+ using namespace Inspector;
2575
+ @@ -100,6 +113,11 @@ using namespace Inspector;
2576
+ macro(WebRTCEncryptionEnabled) \
2577
+ macro(WebSecurityEnabled)
2578
+
2579
+ +HashMap<String, Ref<DOMWrapperWorld>>& createdUserWorlds() {
2580
+ + static NeverDestroyed<HashMap<String, Ref<DOMWrapperWorld>>> nameToWorld;
2581
+ + return nameToWorld;
2582
+ +}
2583
+ +
2584
+ static bool decodeBuffer(const char* buffer, unsigned size, const String& textEncodingName, String* result)
2585
+ {
2586
+ if (buffer) {
2587
+ @@ -340,6 +358,7 @@ InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClien
2564
2588
, m_frontendDispatcher(makeUnique<Inspector::PageFrontendDispatcher>(context.frontendRouter))
2565
2589
, m_backendDispatcher(Inspector::PageBackendDispatcher::create(context.backendDispatcher, this))
2566
2590
, m_inspectedPage(context.inspectedPage)
2567
2591
+ , m_injectedScriptManager(context.injectedScriptManager)
2568
2592
, m_client(client)
2569
2593
, m_overlay(overlay)
2570
2594
{
2571
- @@ -378,6 +390,8 @@ void InspectorPageAgent::enable(ErrorString& errorString)
2595
+ @@ -373,11 +392,20 @@ void InspectorPageAgent::enable(ErrorString& errorString)
2596
+ #if HAVE(OS_DARK_MODE_SUPPORT)
2597
+ defaultAppearanceDidChange(m_inspectedPage.defaultUseDarkAppearance());
2598
+ #endif
2599
+ +
2600
+ + if (!createdUserWorlds().isEmpty()) {
2601
+ + Vector<DOMWrapperWorld*> worlds;
2602
+ + for (const auto& world : createdUserWorlds().values())
2603
+ + worlds.append(world.ptr());
2604
+ + ensureUserWorldsExistInAllFrames(worlds);
2605
+ + }
2606
+ }
2607
+
2572
2608
void InspectorPageAgent::disable(ErrorString&)
2573
2609
{
2574
2610
m_instrumentingAgents.setInspectorPageAgent(nullptr);
@@ -2577,7 +2613,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2577
2613
2578
2614
ErrorString unused;
2579
2615
setShowPaintRects(unused, false);
2580
- @@ -415,14 +429 ,36 @@ void InspectorPageAgent::reload(ErrorString&, const bool* optionalReloadFromOrig
2616
+ @@ -415,14 +443 ,36 @@ void InspectorPageAgent::reload(ErrorString&, const bool* optionalReloadFromOrig
2581
2617
m_inspectedPage.mainFrame().loader().reload(reloadOptions);
2582
2618
}
2583
2619
@@ -2603,23 +2639,23 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2603
2639
+ return;
2604
2640
+
2605
2641
+ ResourceRequest resourceRequest { frame->document()->completeURL(url) };
2606
- +
2607
- + if (!resourceRequest.url().isValid()) {
2608
- + errorString = "Cannot navigate to invalid URL"_s;
2609
- + return;
2610
- + }
2611
2642
2612
2643
- ResourceRequest resourceRequest { frame.document()->completeURL(url) };
2613
2644
- FrameLoadRequest frameLoadRequest { *frame.document(), frame.document()->securityOrigin(), resourceRequest, "_self"_s, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::No, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow, InitiatedByMainFrame::Unknown };
2614
2645
- frame.loader().changeLocation(WTFMove(frameLoadRequest));
2646
+ + if (!resourceRequest.url().isValid()) {
2647
+ + errorString = "Cannot navigate to invalid URL"_s;
2648
+ + return;
2649
+ + }
2650
+ +
2615
2651
+ if (referrer)
2616
2652
+ resourceRequest.setInitiatorIdentifier(InspectorNetworkAgent::createInitiatorIdentifierForInspectorNavigation(*referrer));
2617
2653
+ FrameLoadRequest frameLoadRequest { *frame->document(), frame->document()->securityOrigin(), resourceRequest, "_self"_s, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::No, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow, InitiatedByMainFrame::Unknown };
2618
2654
+ frame->loader().changeLocation(WTFMove(frameLoadRequest));
2619
2655
}
2620
2656
2621
2657
void InspectorPageAgent::overrideUserAgent(ErrorString&, const String* value)
2622
- @@ -683,15 +719 ,16 @@ void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)
2658
+ @@ -683,15 +733 ,16 @@ void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)
2623
2659
m_overlay->setShowPaintRects(show);
2624
2660
}
2625
2661
@@ -2641,7 +2677,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2641
2677
}
2642
2678
2643
2679
void InspectorPageAgent::frameNavigated(Frame& frame)
2644
- @@ -699,13 +736 ,18 @@ void InspectorPageAgent::frameNavigated(Frame& frame)
2680
+ @@ -699,13 +750 ,18 @@ void InspectorPageAgent::frameNavigated(Frame& frame)
2645
2681
m_frontendDispatcher->frameNavigated(buildObjectForFrame(&frame));
2646
2682
}
2647
2683
@@ -2663,7 +2699,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2663
2699
}
2664
2700
2665
2701
Frame* InspectorPageAgent::frameForId(const String& frameId)
2666
- @@ -717,20 +759 ,18 @@ String InspectorPageAgent::frameId(Frame* frame)
2702
+ @@ -717,20 +773 ,18 @@ String InspectorPageAgent::frameId(Frame* frame)
2667
2703
{
2668
2704
if (!frame)
2669
2705
return emptyString();
@@ -2690,7 +2726,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2690
2726
}
2691
2727
2692
2728
Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& frameId)
2693
- @@ -741,11 +781 ,6 @@ Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& f
2729
+ @@ -741,11 +795 ,6 @@ Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& f
2694
2730
return frame;
2695
2731
}
2696
2732
@@ -2702,7 +2738,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2702
2738
void InspectorPageAgent::frameStartedLoading(Frame& frame)
2703
2739
{
2704
2740
m_frontendDispatcher->frameStartedLoading(frameId(&frame));
2705
- @@ -766,6 +801 ,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)
2741
+ @@ -766,6 +815 ,12 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame& frame)
2706
2742
m_frontendDispatcher->frameClearedScheduledNavigation(frameId(&frame));
2707
2743
}
2708
2744
@@ -2715,7 +2751,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2715
2751
void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance)
2716
2752
{
2717
2753
m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);
2718
- @@ -823,6 +864 ,38 @@ void InspectorPageAgent::didRecalculateStyle()
2754
+ @@ -823,6 +878 ,38 @@ void InspectorPageAgent::didRecalculateStyle()
2719
2755
m_overlay->update();
2720
2756
}
2721
2757
@@ -2754,7 +2790,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2754
2790
Ref<Inspector::Protocol::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
2755
2791
{
2756
2792
ASSERT_ARG(frame, frame);
2757
- @@ -966,6 +1039 ,18 @@ void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, in
2793
+ @@ -966,6 +1053 ,18 @@ void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, in
2758
2794
*outDataURL = snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
2759
2795
}
2760
2796
@@ -2773,7 +2809,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
2773
2809
void InspectorPageAgent::archive(ErrorString& errorString, String* data)
2774
2810
{
2775
2811
#if ENABLE(WEB_ARCHIVE) && USE(CF)
2776
- @@ -983,4 +1068,514 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
2812
+ @@ -983,4 +1082,520 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
2777
2813
#endif
2778
2814
}
2779
2815
@@ -3265,16 +3301,22 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
3265
3301
+
3266
3302
+void InspectorPageAgent::createUserWorld(ErrorString& errorString, const String& name)
3267
3303
+{
3268
- + static NeverDestroyed<HashSet<String>> createdUserWorlds;
3269
- + if (createdUserWorlds->contains(name)) {
3304
+ + if (createdUserWorlds().contains(name)) {
3270
3305
+ errorString = "World with the given name already exists"_s;
3271
3306
+ return;
3272
3307
+ }
3273
- + createdUserWorlds->add(name);
3274
3308
+
3275
3309
+ Ref<DOMWrapperWorld> world = ScriptController::createWorld(name, ScriptController::WorldType::User);
3276
- + for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext())
3277
- + frame->windowProxy().jsWindowProxy(world)->window();
3310
+ + ensureUserWorldsExistInAllFrames({world.ptr()});
3311
+ + createdUserWorlds().set(name, WTFMove(world));
3312
+ +}
3313
+ +
3314
+ +void InspectorPageAgent::ensureUserWorldsExistInAllFrames(const Vector<DOMWrapperWorld*>& worlds)
3315
+ +{
3316
+ + for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
3317
+ + for (auto* world : worlds)
3318
+ + frame->windowProxy().jsWindowProxy(*world)->window();
3319
+ + }
3278
3320
+}
3279
3321
+
3280
3322
+void InspectorPageAgent::setBypassCSP(ErrorString&, bool enabled)
@@ -3289,7 +3331,7 @@ index d678cddbd20a1a2b410a8ebbb17f5f63f0fc620d..4732b818204dc5a7e00d38b6635d9eea
3289
3331
+
3290
3332
} // namespace WebCore
3291
3333
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h
3292
- index 110173dbbfe819226b6c4caa0f65a5dee8c39f2b..8cbb35194cfd408e934400ed1e3abd7b1dcd3949 100644
3334
+ index 110173dbbfe819226b6c4caa0f65a5dee8c39f2b..cba0b43011a390c305aef7c01cc95e5350766283 100644
3293
3335
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h
3294
3336
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h
3295
3337
@@ -40,11 +40,16 @@
@@ -3363,7 +3405,15 @@ index 110173dbbfe819226b6c4caa0f65a5dee8c39f2b..8cbb35194cfd408e934400ed1e3abd7b
3363
3405
3364
3406
Frame* frameForId(const String& frameId);
3365
3407
WEBCORE_EXPORT String frameId(Frame*);
3366
- @@ -152,18 +170,19 @@ private:
3408
+ @@ -141,6 +159,7 @@ public:
3409
+
3410
+ private:
3411
+ double timestamp();
3412
+ + void ensureUserWorldsExistInAllFrames(const Vector<DOMWrapperWorld*>&);
3413
+
3414
+ static bool mainResourceContent(Frame*, bool withBase64Encode, String* result);
3415
+ static bool dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result);
3416
+ @@ -152,18 +171,19 @@ private:
3367
3417
RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher;
3368
3418
3369
3419
Page& m_inspectedPage;
0 commit comments