| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +15 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * inspector/protocol/Runtime.json:
13
        Introduce an `ExecutionContextType` enum instead of `isPageContext` so the frontend can
14
        decide whether/how to show a picker for that execution context.
15
1
2020-01-26  Alexey Shvayka  <shvaikalesh@gmail.com>
16
2020-01-26  Alexey Shvayka  <shvaikalesh@gmail.com>
2
17
3
        Invalid ranges in character classes should be banned in unicode patterns
18
        Invalid ranges in character classes should be banned in unicode patterns
- a/Source/WebCore/ChangeLog +57 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        Test: inspector/runtime/executionContextCreated-isolated-world.html
13
14
        * bindings/js/DOMWrapperWorld.h:
15
        (WebCore::DOMWrapperWorld::create):
16
        (WebCore::DOMWrapperWorld::type const): Added.
17
        (WebCore::DOMWrapperWorld::isNormal const):
18
        (WebCore::DOMWrapperWorld::name const): Added.
19
        * bindings/js/DOMWrapperWorld.cpp:
20
        (WebCore::DOMWrapperWorld::DOMWrapperWorld):
21
        * bindings/js/ScriptController.h:
22
        * bindings/js/ScriptController.cpp:
23
        (WebCore::ScriptController::createWorld):
24
        * bindings/js/WebCoreJSClientData.cpp:
25
        (WebCore::JSVMClientData::initNormalWorld):
26
        Require that a name is specified when creating an isolated world (except the normal world)
27
        so that Web Inspector has something to show in the execution context picker.
28
29
        * inspector/InspectorInstrumentation.cpp:
30
        (WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
31
        * inspector/agents/InspectorPageAgent.h:
32
        * inspector/agents/InspectorPageAgent.cpp:
33
        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
34
        * inspector/agents/page/PageDebuggerAgent.h:
35
        * inspector/agents/page/PageDebuggerAgent.cpp:
36
        (WebCore::PageDebuggerAgent::didClearWindowObjectInWorld):
37
        * inspector/agents/page/PageRuntimeAgent.h:
38
        * inspector/agents/page/PageRuntimeAgent.cpp:
39
        (WebCore::PageRuntimeAgent::didClearWindowObjectInWorld):
40
        (WebCore::PageRuntimeAgent::reportExecutionContextCreation):
41
        (WebCore::toProtocol): Added.
42
        (WebCore::PageRuntimeAgent::notifyContextCreated):
43
        Allow this instrumentation call to pass through to the agents for non-`Normal` worlds.
44
45
        * html/HTMLMediaElement.cpp:
46
        (WebCore::HTMLMediaElement::ensureIsolatedWorld):
47
        * html/HTMLPlugInImageElement.cpp:
48
        (WebCore::plugInImageElementIsolatedWorld):
49
        * Modules/plugins/QuickTimePluginReplacement.mm:
50
        (WebCore::QuickTimePluginReplacement::isolatedWorld):
51
        Mark these worlds as `Internal`.
52
53
        * testing/Internals.idl:
54
        * testing/Internals.h:
55
        * testing/Internals.cpp:
56
        (WebCore::Internals::evaluateInWorldIgnoringException): Added.
57
1
2020-01-26  youenn fablet  <youenn@apple.com>
58
2020-01-26  youenn fablet  <youenn@apple.com>
2
59
3
        Use ObjectIdentifier for remote RealtimeMediaSource
60
        Use ObjectIdentifier for remote RealtimeMediaSource
- a/Source/WebInspectorUI/ChangeLog +143 lines
Lines 1-3 a/Source/WebInspectorUI/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * UserInterface/Models/ExecutionContext.js:
13
        (WI.ExecutionContext):
14
        (WI.ExecutionContext.typeFromPayload): Added.
15
        (WI.ExecutionContext.prototype.get type): Added.
16
        (WI.ExecutionContext.prototype.get isPageContext): Deleted.
17
18
        * UserInterface/Models/ExecutionContextList.js:
19
        (WI.ExecutionContextList.prototype.add):
20
        * UserInterface/Models/Frame.js:
21
        (WI.Frame.prototype.addExecutionContext):
22
        * UserInterface/Controllers/NetworkManager.js:
23
        (WI.NetworkManager.prototype.executionContextCreated):
24
        The `Normal` execution context (of which there should only be one) is considered the "page"
25
        execution context.
26
27
        * UserInterface/Protocol/DirectBackendTarget.js:
28
        (WI.DirectBackendTarget):
29
        * UserInterface/Protocol/PageTarget.js:
30
        (WI.PageTarget):
31
        * UserInterface/Protocol/WorkerTarget.js:
32
        (WI.WorkerTarget):
33
        Default to a `Normal` execution context.
34
35
        * UserInterface/Views/QuickConsole.js:
36
        (WI.QuickConsole):
37
        (WI.QuickConsole.prototype._displayNameForExecutionContext): Added.
38
        (WI.QuickConsole.prototype._resolveDesiredActiveExecutionContext): Added.
39
        (WI.QuickConsole.prototype._setActiveExecutionContext): Added.
40
        (WI.QuickConsole.prototype._updateActiveExecutionContextDisplay): Added.
41
        (WI.QuickConsole.prototype._populateActiveExecutionContextNavigationItemContextMenu): Added.
42
        (WI.QuickConsole.prototype._handleConsoleSavedResultAliasSettingChanged): Added.
43
        (WI.QuickConsole.prototype._handleEngineeringShowInternalExecutionContextsSettingChanged): Added.
44
        (WI.QuickConsole.prototype._handleFramePageExecutionContextChanged): Added.
45
        (WI.QuickConsole.prototype._handleFrameExecutionContextsCleared): Added.
46
        (WI.QuickConsole.prototype._handleDebuggerActiveCallFrameDidChange): Added.
47
        (WI.QuickConsole.prototype._handleActiveExecutionContextChanged): Added.
48
        (WI.QuickConsole.prototype._handleTransitionPageTarget): Added.
49
        (WI.QuickConsole.prototype._handleTargetRemoved): Added.
50
        (WI.QuickConsole.prototype._handleInspectedNodeChanged): Added.
51
        (WI.QuickConsole.prototype._updateStyles):
52
        (WI.QuickConsole.prototype.get navigationBar): Deleted.
53
        (WI.QuickConsole.prototype._pageTargetTransitioned): Deleted.
54
        (WI.QuickConsole.prototype._initializeMainExecutionContextPathComponent): Deleted.
55
        (WI.QuickConsole.prototype.layout): Deleted.
56
        (WI.QuickConsole.prototype._preferredNameForFrame): Deleted.
57
        (WI.QuickConsole.prototype._selectExecutionContext): Deleted.
58
        (WI.QuickConsole.prototype._updateAutomaticExecutionContextPathComponentTooltip): Deleted.
59
        (WI.QuickConsole.prototype._executionContextPathComponentsToDisplay): Deleted.
60
        (WI.QuickConsole.prototype._rebuildExecutionContextPathComponents): Deleted.
61
        (WI.QuickConsole.prototype._framePageExecutionContextsChanged): Deleted.
62
        (WI.QuickConsole.prototype._frameExecutionContextsCleared): Deleted.
63
        (WI.QuickConsole.prototype._activeExecutionContextChanged): Deleted.
64
        (WI.QuickConsole.prototype._createExecutionContextPathComponent): Deleted.
65
        (WI.QuickConsole.prototype._compareExecutionContextPathComponents): Deleted.
66
        (WI.QuickConsole.prototype._insertOtherExecutionContextPathComponent): Deleted.
67
        (WI.QuickConsole.prototype._removeOtherExecutionContextPathComponent): Deleted.
68
        (WI.QuickConsole.prototype._insertExecutionContextPathComponentForFrame): Deleted.
69
        (WI.QuickConsole.prototype._removeExecutionContextPathComponentForFrame): Deleted.
70
        (WI.QuickConsole.prototype._targetAdded): Deleted.
71
        (WI.QuickConsole.prototype._targetRemoved): Deleted.
72
        (WI.QuickConsole.prototype._pathComponentSelected): Deleted.
73
        (WI.QuickConsole.prototype._pathComponentClicked): Deleted.
74
        (WI.QuickConsole.prototype._debuggerActiveCallFrameDidChange): Deleted.
75
        * UserInterface/Views/QuickConsole.css:
76
        (.quick-console > .console-prompt):
77
        (.quick-console > .navigation-bar):
78
        (.quick-console > .navigation-bar .active-execution-context): Added.
79
        (.quick-console > .navigation-bar .active-execution-context > .selector-arrows): Added.
80
        (.quick-console > .navigation-bar .active-execution-context:not(.automatic)): Added.
81
        (.quick-console > .navigation-bar .active-execution-context:not(.automatic) > .selector-arrows): Added.
82
        (.quick-console .execution-context): Deleted.
83
        (.quick-console > .navigation-bar > .hierarchical-path .execution-context): Deleted.
84
        (.quick-console > .navigation-bar > .hierarchical-path .execution-context .separator): Deleted.
85
        (.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context)): Deleted.
86
        (.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context) .execution-context): Deleted.
87
        (.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context) .execution-context .selector-arrows): Deleted.
88
        Replace the `WI.HierarchicalPathNavigationItem` with a plain `WI.NavigationItem` that shows
89
        a `WI.ContextMenu` with all valid execution contexts organized as follows:
90
91
            Auto - <display name for execution context of inspected DOM node>
92
            ----------
93
            Main Frame Normal Execution Context
94
                All User Exection Contexts for the Main Frame
95
                All Internal Exection Contexts for the Main Frame (with the engineering setting)
96
            Frames
97
                Frame Normal Execution Context
98
                    All User Exection Contexts for the Frame
99
                    All Internal Exection Contexts for the Frame (with the engineering setting)
100
                ...
101
            Workers
102
                Worker Execution Context
103
                ...
104
105
        Everything is checkmark selectable other than the separator, "Frames", and "Workers".
106
107
        * UserInterface/Controllers/RuntimeManager.js:
108
        (WI.RuntimeManager):
109
        (WI.RuntimeManager.prototype._frameExecutionContextsCleared): Deleted.
110
        Let the UI (`WI.QuickConsole`) decide when to automatically update the active execution
111
        context when a frame is removed that owned the active execution context.
112
113
        * UserInterface/Controllers/TargetManager.js:
114
        (WI.TargetManager.prototype.get workerTargets): Added.
115
        (WI.TargetManager.prototype._terminatePageTarget):
116
        Convenience function for getting the list of worker targets.
117
118
        * UserInterface/Views/GroupNavigationItem.js:
119
        (WI.GroupNavigationItem.prototype.update):
120
        (WI.GroupNavigationItem.prototype.didAttach):
121
        Update the items whenever the group updates.
122
123
        * UserInterface/Main.html:
124
        * UserInterface/Views/SizesToFitNavigationBar.js: Renamed from Source/WebInspectorUI/UserInterface/Views/QuickConsoleNavigationBar.js.
125
        (WI.SizesToFitNavigationBar):
126
        (WI.SizesToFitNavigationBar.prototype.get sizesToFit):
127
        Rename to allow for other use cases.
128
129
        * UserInterface/Views/ContextMenu.js:
130
        (WI.ContextSubMenuItem.prototype.appendHeader): Added.
131
        Convenience method for creating a disabled item.
132
133
        * UserInterface/Base/Setting.js:
134
        * UserInterface/Views/SettingsTabContentView.js:
135
        (WI.SettingsTabContentView.prototype._createEngineeringSettingsView):
136
        Create an engineering setting that controls whether `Internal` execution contexts are shown.
137
138
        * UserInterface/Test/InspectorProtocol.js:
139
        (InspectorProtocol.addEventListener):
140
        (InspectorProtocol.removeEventListener): Added.
141
142
        * Localizations/en.lproj/localizedStrings.js:
143
1
2020-01-21  Keith Rollin  <krollin@apple.com>
144
2020-01-21  Keith Rollin  <krollin@apple.com>
2
145
3
        Fix tvOS values in SUPPORTED_PLATFORMS
146
        Fix tvOS values in SUPPORTED_PLATFORMS
- a/Source/WebKit/ChangeLog +22 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
13
        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
14
        (WebKit::InjectedBundleScriptWorld::create):
15
16
        * WebProcess/UserContent/WebUserContentController.cpp:
17
        (WebKit::WebUserContentController::addUserContentWorlds):
18
        * WebProcess/InjectedBundle/API/glib/WebKitScriptWorld.cpp:
19
        (webkit_script_world_new):
20
        (webkit_script_world_new_with_name):
21
        Treat isolated worlds created by API calls as `User` worlds.
22
1
2020-01-26  Chris Dumez  <cdumez@apple.com>
23
2020-01-26  Chris Dumez  <cdumez@apple.com>
2
24
3
        Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com
25
        Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com
- a/Source/WebKitLegacy/mac/ChangeLog +15 lines
Lines 1-3 a/Source/WebKitLegacy/mac/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * WebView/WebScriptWorld.mm:
13
        (-[WebScriptWorld init]):
14
        Treat isolated worlds created by API calls as `User` worlds.
15
1
2020-01-26  Said Abou-Hallawa  <said@apple.com>
16
2020-01-26  Said Abou-Hallawa  <said@apple.com>
2
17
3
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
18
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
- a/Source/WebKitLegacy/win/ChangeLog +15 lines
Lines 1-3 a/Source/WebKitLegacy/win/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * WebScriptWorld.cpp:
13
        (WebScriptWorld::createInstance):
14
        Treat isolated worlds created by API calls as `User` worlds.
15
1
2020-01-26  Said Abou-Hallawa  <said@apple.com>
16
2020-01-26  Said Abou-Hallawa  <said@apple.com>
2
17
3
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
18
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
- a/Source/JavaScriptCore/inspector/protocol/Runtime.json -1 / +7 lines
Lines 108-120 a/Source/JavaScriptCore/inspector/protocol/Runtime.json_sec1
108
            "type": "integer",
108
            "type": "integer",
109
            "description": "Id of an execution context."
109
            "description": "Id of an execution context."
110
        },
110
        },
111
        {
112
            "id": "ExecutionContextType",
113
            "type": "string",
114
            "enum": ["normal", "user", "internal"],
115
            "description": "Type of the execution context."
116
        },
111
        {
117
        {
112
            "id": "ExecutionContextDescription",
118
            "id": "ExecutionContextDescription",
113
            "type": "object",
119
            "type": "object",
114
            "description": "Description of an isolated world.",
120
            "description": "Description of an isolated world.",
115
            "properties": [
121
            "properties": [
116
                { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." },
122
                { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." },
117
                { "name": "isPageContext", "type": "boolean", "description": "True if this is a context where inpspected web page scripts run. False if it is a content script isolated context." },
123
                { "name": "type", "$ref": "ExecutionContextType" },
118
                { "name": "name", "type": "string", "description": "Human readable name describing given context."},
124
                { "name": "name", "type": "string", "description": "Human readable name describing given context."},
119
                { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the owning frame." }
125
                { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the owning frame." }
120
            ]
126
            ]
- a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm -1 / +1 lines
Lines 137-143 RenderPtr<RenderElement> QuickTimePluginReplacement::createElementRenderer(HTMLP a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm_sec1
137
137
138
DOMWrapperWorld& QuickTimePluginReplacement::isolatedWorld()
138
DOMWrapperWorld& QuickTimePluginReplacement::isolatedWorld()
139
{
139
{
140
    static DOMWrapperWorld& isolatedWorld = DOMWrapperWorld::create(commonVM()).leakRef();
140
    static DOMWrapperWorld& isolatedWorld = DOMWrapperWorld::create(commonVM(), DOMWrapperWorld::Type::Internal, "QuickTimePluginReplacement"_s).leakRef();
141
    return isolatedWorld;
141
    return isolatedWorld;
142
}
142
}
143
143
- a/Source/WebCore/bindings/js/DOMWrapperWorld.cpp -2 / +5 lines
Lines 31-40 a/Source/WebCore/bindings/js/DOMWrapperWorld.cpp_sec1
31
namespace WebCore {
31
namespace WebCore {
32
using namespace JSC;
32
using namespace JSC;
33
33
34
DOMWrapperWorld::DOMWrapperWorld(JSC::VM& vm, bool isNormal)
34
DOMWrapperWorld::DOMWrapperWorld(JSC::VM& vm, Type type, const String& name)
35
    : m_vm(vm)
35
    : m_vm(vm)
36
    , m_isNormal(isNormal)
36
    , m_name(name)
37
    , m_type(type)
37
{
38
{
39
    ASSERT(!name.isEmpty() || m_type == Type::Normal);
40
38
    VM::ClientData* clientData = m_vm.clientData;
41
    VM::ClientData* clientData = m_vm.clientData;
39
    ASSERT(clientData);
42
    ASSERT(clientData);
40
    static_cast<JSVMClientData*>(clientData)->rememberWorld(*this);
43
    static_cast<JSVMClientData*>(clientData)->rememberWorld(*this);
- a/Source/WebCore/bindings/js/DOMWrapperWorld.h -5 / +16 lines
Lines 32-40 typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap; a/Source/WebCore/bindings/js/DOMWrapperWorld.h_sec1
32
32
33
class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
33
class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
34
public:
34
public:
35
    static Ref<DOMWrapperWorld> create(JSC::VM& vm, bool isNormal = false)
35
    enum class Type {
36
        Normal,   // Main (e.g. Page)
37
        User,     // User Scripts (e.g. Extensions)
38
        Internal, // WebKit Internal (e.g. Media Controls)
39
    };
40
41
    static Ref<DOMWrapperWorld> create(JSC::VM& vm, Type type = Type::Internal, const String& name = { })
36
    {
42
    {
37
        return adoptRef(*new DOMWrapperWorld(vm, isNormal));
43
        return adoptRef(*new DOMWrapperWorld(vm, type, name));
38
    }
44
    }
39
    WEBCORE_EXPORT ~DOMWrapperWorld();
45
    WEBCORE_EXPORT ~DOMWrapperWorld();
40
46
Lines 52-70 public: a/Source/WebCore/bindings/js/DOMWrapperWorld.h_sec2
52
58
53
    DOMObjectWrapperMap& wrappers() { return m_wrappers; }
59
    DOMObjectWrapperMap& wrappers() { return m_wrappers; }
54
60
55
    bool isNormal() const { return m_isNormal; }
61
    Type type() const { return m_type; }
62
    bool isNormal() const { return m_type == Type::Normal; }
63
64
    const String& name() const { return m_name; }
56
65
57
    JSC::VM& vm() const { return m_vm; }
66
    JSC::VM& vm() const { return m_vm; }
58
67
59
protected:
68
protected:
60
    DOMWrapperWorld(JSC::VM&, bool isNormal);
69
    DOMWrapperWorld(JSC::VM&, Type, const String& name);
61
70
62
private:
71
private:
63
    JSC::VM& m_vm;
72
    JSC::VM& m_vm;
64
    HashSet<WindowProxy*> m_jsWindowProxies;
73
    HashSet<WindowProxy*> m_jsWindowProxies;
65
    DOMObjectWrapperMap m_wrappers;
74
    DOMObjectWrapperMap m_wrappers;
66
75
67
    bool m_isNormal;
76
    String m_name;
77
    Type m_type { Type::Internal };
78
68
    bool m_shadowRootIsAlwaysOpen { false };
79
    bool m_shadowRootIsAlwaysOpen { false };
69
    bool m_shouldDisableOverrideBuiltinsBehavior { false };
80
    bool m_shouldDisableOverrideBuiltinsBehavior { false };
70
};
81
};
- a/Source/WebCore/bindings/js/ScriptController.cpp -2 / +3 lines
Lines 26-31 a/Source/WebCore/bindings/js/ScriptController.cpp_sec1
26
#include "CommonVM.h"
26
#include "CommonVM.h"
27
#include "ContentSecurityPolicy.h"
27
#include "ContentSecurityPolicy.h"
28
#include "CustomHeaderFields.h"
28
#include "CustomHeaderFields.h"
29
#include "DOMWrapperWorld.h"
29
#include "DocumentLoader.h"
30
#include "DocumentLoader.h"
30
#include "Event.h"
31
#include "Event.h"
31
#include "Frame.h"
32
#include "Frame.h"
Lines 247-255 JSC::JSValue ScriptController::evaluateModule(const URL& sourceURL, JSModuleReco a/Source/WebCore/bindings/js/ScriptController.cpp_sec2
247
    return evaluateModule(sourceURL, moduleRecord, mainThreadNormalWorld());
248
    return evaluateModule(sourceURL, moduleRecord, mainThreadNormalWorld());
248
}
249
}
249
250
250
Ref<DOMWrapperWorld> ScriptController::createWorld()
251
Ref<DOMWrapperWorld> ScriptController::createWorld(const String& name, WorldType type)
251
{
252
{
252
    return DOMWrapperWorld::create(commonVM());
253
    return DOMWrapperWorld::create(commonVM(), type == WorldType::User ? DOMWrapperWorld::Type::User : DOMWrapperWorld::Type::Internal, name);
253
}
254
}
254
255
255
void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds)
256
void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds)
- a/Source/WebCore/bindings/js/ScriptController.h -2 / +3 lines
Lines 87-93 public: a/Source/WebCore/bindings/js/ScriptController.h_sec1
87
    explicit ScriptController(Frame&);
87
    explicit ScriptController(Frame&);
88
    ~ScriptController();
88
    ~ScriptController();
89
89
90
    WEBCORE_EXPORT static Ref<DOMWrapperWorld> createWorld();
90
    enum class WorldType { User, Internal };
91
    WEBCORE_EXPORT static Ref<DOMWrapperWorld> createWorld(const String& name, WorldType = WorldType::Internal);
91
92
92
    JSDOMWindow* globalObject(DOMWrapperWorld& world)
93
    JSDOMWindow* globalObject(DOMWrapperWorld& world)
93
    {
94
    {
Lines 104-110 public: a/Source/WebCore/bindings/js/ScriptController.h_sec2
104
    WEBCORE_EXPORT ValueOrException executeUserAgentScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture);
105
    WEBCORE_EXPORT ValueOrException executeUserAgentScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture);
105
    WEBCORE_EXPORT void executeAsynchronousUserAgentScriptInWorld(DOMWrapperWorld&, RunJavaScriptParameters&&, ResolveFunction&&);
106
    WEBCORE_EXPORT void executeAsynchronousUserAgentScriptInWorld(DOMWrapperWorld&, RunJavaScriptParameters&&, ResolveFunction&&);
106
    JSC::JSValue evaluateIgnoringException(const ScriptSourceCode&);
107
    JSC::JSValue evaluateIgnoringException(const ScriptSourceCode&);
107
    JSC::JSValue evaluateInWorldIgnoringException(const ScriptSourceCode&, DOMWrapperWorld&);
108
    WEBCORE_EXPORT JSC::JSValue evaluateInWorldIgnoringException(const ScriptSourceCode&, DOMWrapperWorld&);
108
109
109
    Expected<void, ExceptionDetails> shouldAllowUserAgentScripts(Document&) const;
110
    Expected<void, ExceptionDetails> shouldAllowUserAgentScripts(Document&) const;
110
111
- a/Source/WebCore/bindings/js/WebCoreJSClientData.cpp -3 / +3 lines
Lines 114-123 void JSVMClientData::initNormalWorld(VM* vm) a/Source/WebCore/bindings/js/WebCoreJSClientData.cpp_sec1
114
{
114
{
115
    JSVMClientData* clientData = new JSVMClientData(*vm);
115
    JSVMClientData* clientData = new JSVMClientData(*vm);
116
    vm->clientData = clientData; // ~VM deletes this pointer.
116
    vm->clientData = clientData; // ~VM deletes this pointer.
117
    
117
118
    vm->heap.addMarkingConstraint(makeUnique<DOMGCOutputConstraint>(*vm, *clientData));
118
    vm->heap.addMarkingConstraint(makeUnique<DOMGCOutputConstraint>(*vm, *clientData));
119
        
119
120
    clientData->m_normalWorld = DOMWrapperWorld::create(*vm, true);
120
    clientData->m_normalWorld = DOMWrapperWorld::create(*vm, DOMWrapperWorld::Type::Normal);
121
    vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController());
121
    vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController());
122
}
122
}
123
123
- a/Source/WebCore/html/HTMLMediaElement.cpp -1 / +1 lines
Lines 7218-7224 RefPtr<VideoPlaybackQuality> HTMLMediaElement::getVideoPlaybackQuality() a/Source/WebCore/html/HTMLMediaElement.cpp_sec1
7218
DOMWrapperWorld& HTMLMediaElement::ensureIsolatedWorld()
7218
DOMWrapperWorld& HTMLMediaElement::ensureIsolatedWorld()
7219
{
7219
{
7220
    if (!m_isolatedWorld)
7220
    if (!m_isolatedWorld)
7221
        m_isolatedWorld = DOMWrapperWorld::create(commonVM());
7221
        m_isolatedWorld = DOMWrapperWorld::create(commonVM(), DOMWrapperWorld::Type::Internal, makeString("Media Controls (", localName(), ')'));
7222
    return *m_isolatedWorld;
7222
    return *m_isolatedWorld;
7223
}
7223
}
7224
7224
- a/Source/WebCore/html/HTMLPlugInImageElement.cpp -1 / +1 lines
Lines 363-369 void HTMLPlugInImageElement::updateSnapshot(Image* image) a/Source/WebCore/html/HTMLPlugInImageElement.cpp_sec1
363
363
364
static DOMWrapperWorld& plugInImageElementIsolatedWorld()
364
static DOMWrapperWorld& plugInImageElementIsolatedWorld()
365
{
365
{
366
    static auto& isolatedWorld = DOMWrapperWorld::create(commonVM()).leakRef();
366
    static auto& isolatedWorld = DOMWrapperWorld::create(commonVM(), DOMWrapperWorld::Type::Internal, "Plugin"_s).leakRef();
367
    return isolatedWorld;
367
    return isolatedWorld;
368
}
368
}
369
369
- a/Source/WebCore/inspector/InspectorInstrumentation.cpp -6 / +3 lines
Lines 121-137 static Frame* frameForScriptExecutionContext(ScriptExecutionContext& context) a/Source/WebCore/inspector/InspectorInstrumentation.cpp_sec1
121
121
122
void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world)
122
void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world)
123
{
123
{
124
    if (&world != &mainThreadNormalWorld())
125
        return;
126
127
    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
124
    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
128
        pageDebuggerAgent->didClearWindowObjectInWorld(frame);
125
        pageDebuggerAgent->didClearWindowObjectInWorld(frame, world);
129
126
130
    if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())
127
    if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())
131
        pageRuntimeAgent->didClearWindowObjectInWorld(frame);
128
        pageRuntimeAgent->didClearWindowObjectInWorld(frame, world);
132
129
133
    if (auto* pageAgent = instrumentingAgents.inspectorPageAgent())
130
    if (auto* pageAgent = instrumentingAgents.inspectorPageAgent())
134
        pageAgent->didClearWindowObjectInWorld(frame);
131
        pageAgent->didClearWindowObjectInWorld(frame, world);
135
}
132
}
136
133
137
bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents& instrumentingAgents)
134
bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents& instrumentingAgents)
- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp -1 / +5 lines
Lines 37-42 a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp_sec1
37
#include "Cookie.h"
37
#include "Cookie.h"
38
#include "CookieJar.h"
38
#include "CookieJar.h"
39
#include "CustomHeaderFields.h"
39
#include "CustomHeaderFields.h"
40
#include "DOMWrapperWorld.h"
40
#include "Document.h"
41
#include "Document.h"
41
#include "DocumentLoader.h"
42
#include "DocumentLoader.h"
42
#include "Frame.h"
43
#include "Frame.h"
Lines 770-777 void InspectorPageAgent::defaultAppearanceDidChange(bool useDarkAppearance) a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp_sec2
770
    m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);
771
    m_frontendDispatcher->defaultAppearanceDidChange(useDarkAppearance ? Inspector::Protocol::Page::Appearance::Dark : Inspector::Protocol::Page::Appearance::Light);
771
}
772
}
772
773
773
void InspectorPageAgent::didClearWindowObjectInWorld(Frame& frame)
774
void InspectorPageAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
774
{
775
{
776
    if (&world != &mainThreadNormalWorld())
777
        return;
778
775
    if (m_bootstrapScript.isEmpty())
779
    if (m_bootstrapScript.isEmpty())
776
        return;
780
        return;
777
781
- a/Source/WebCore/inspector/agents/InspectorPageAgent.h -1 / +2 lines
Lines 42-47 a/Source/WebCore/inspector/agents/InspectorPageAgent.h_sec1
42
42
43
namespace WebCore {
43
namespace WebCore {
44
44
45
class DOMWrapperWorld;
45
class DocumentLoader;
46
class DocumentLoader;
46
class Frame;
47
class Frame;
47
class InspectorClient;
48
class InspectorClient;
Lines 127-133 public: a/Source/WebCore/inspector/agents/InspectorPageAgent.h_sec2
127
    void defaultAppearanceDidChange(bool useDarkAppearance);
128
    void defaultAppearanceDidChange(bool useDarkAppearance);
128
    void applyUserAgentOverride(String&);
129
    void applyUserAgentOverride(String&);
129
    void applyEmulatedMedia(String&);
130
    void applyEmulatedMedia(String&);
130
    void didClearWindowObjectInWorld(Frame&);
131
    void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
131
    void didPaint(RenderObject&, const LayoutRect&);
132
    void didPaint(RenderObject&, const LayoutRect&);
132
    void didLayout();
133
    void didLayout();
133
    void didScroll();
134
    void didScroll();
- a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp -2 / +3 lines
Lines 33-38 a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp_sec1
33
#include "PageDebuggerAgent.h"
33
#include "PageDebuggerAgent.h"
34
34
35
#include "CachedResource.h"
35
#include "CachedResource.h"
36
#include "DOMWrapperWorld.h"
36
#include "Document.h"
37
#include "Document.h"
37
#include "Frame.h"
38
#include "Frame.h"
38
#include "InspectorPageAgent.h"
39
#include "InspectorPageAgent.h"
Lines 139-147 InjectedScript PageDebuggerAgent::injectedScriptForEval(ErrorString& errorString a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp_sec2
139
    return injectedScript;
140
    return injectedScript;
140
}
141
}
141
142
142
void PageDebuggerAgent::didClearWindowObjectInWorld(Frame& frame)
143
void PageDebuggerAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
143
{
144
{
144
    if (!frame.isMainFrame())
145
    if (!frame.isMainFrame() || &world != &mainThreadNormalWorld())
145
        return;
146
        return;
146
147
147
    didClearGlobalObject();
148
    didClearGlobalObject();
- a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h -1 / +2 lines
Lines 35-40 a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h_sec1
35
35
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class DOMWrapperWorld;
38
class Document;
39
class Document;
39
class Frame;
40
class Frame;
40
class Page;
41
class Page;
Lines 54-60 public: a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h_sec2
54
    void breakpointActionLog(JSC::JSGlobalObject*, const String&) override;
55
    void breakpointActionLog(JSC::JSGlobalObject*, const String&) override;
55
56
56
    // InspectorInstrumentation
57
    // InspectorInstrumentation
57
    void didClearWindowObjectInWorld(Frame&);
58
    void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
58
    void mainFrameStartedLoading();
59
    void mainFrameStartedLoading();
59
    void mainFrameStoppedLoading();
60
    void mainFrameStoppedLoading();
60
    void mainFrameNavigated();
61
    void mainFrameNavigated();
- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp -27 / +40 lines
Lines 32-37 a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp_sec1
32
#include "config.h"
32
#include "config.h"
33
#include "PageRuntimeAgent.h"
33
#include "PageRuntimeAgent.h"
34
34
35
#include "DOMWrapperWorld.h"
35
#include "Document.h"
36
#include "Document.h"
36
#include "Frame.h"
37
#include "Frame.h"
37
#include "InspectorPageAgent.h"
38
#include "InspectorPageAgent.h"
Lines 46-53 a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp_sec2
46
#include <JavaScriptCore/InjectedScript.h>
47
#include <JavaScriptCore/InjectedScript.h>
47
#include <JavaScriptCore/InjectedScriptManager.h>
48
#include <JavaScriptCore/InjectedScriptManager.h>
48
49
49
using Inspector::Protocol::Runtime::ExecutionContextDescription;
50
51
namespace WebCore {
50
namespace WebCore {
52
51
53
using namespace Inspector;
52
using namespace Inspector;
Lines 97-111 void PageRuntimeAgent::frameNavigated(Frame& frame) a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp_sec3
97
    mainWorldExecState(&frame);
96
    mainWorldExecState(&frame);
98
}
97
}
99
98
100
void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame)
99
void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
101
{
100
{
102
    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
101
    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
103
    if (!pageAgent)
102
    if (!pageAgent)
104
        return;
103
        return;
105
104
106
    auto frameId = pageAgent->frameId(&frame);
105
    notifyContextCreated(pageAgent->frameId(&frame), frame.script().globalObject(world), world);
107
    auto* scriptState = mainWorldExecState(&frame);
108
    notifyContextCreated(frameId, scriptState, nullptr, true);
109
}
106
}
110
107
111
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
108
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
Lines 140-178 void PageRuntimeAgent::reportExecutionContextCreation() a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp_sec4
140
    if (!pageAgent)
137
    if (!pageAgent)
141
        return;
138
        return;
142
139
143
    Vector<std::pair<JSC::JSGlobalObject*, SecurityOrigin*>> isolatedContexts;
140
    for (auto* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
144
    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
145
        if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
141
        if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
146
            continue;
142
            continue;
147
143
148
        String frameId = pageAgent->frameId(frame);
144
        auto frameId = pageAgent->frameId(frame);
149
145
150
        JSC::JSGlobalObject* scriptState = mainWorldExecState(frame);
146
        // Always send the main world first.
151
        notifyContextCreated(frameId, scriptState, nullptr, true);
147
        auto* mainGlobalObject = mainWorldExecState(frame);
152
        frame->script().collectIsolatedContexts(isolatedContexts);
148
        notifyContextCreated(frameId, mainGlobalObject, mainThreadNormalWorld());
153
        if (isolatedContexts.isEmpty())
149
154
            continue;
150
        for (auto& jsWindowProxy : frame->windowProxy().jsWindowProxiesAsVector()) {
155
        for (auto& [globalObject, securityOrigin] : isolatedContexts) {
151
            auto* globalObject = jsWindowProxy->window();
156
            if (globalObject != scriptState)
152
            if (globalObject == mainGlobalObject)
157
                notifyContextCreated(frameId, globalObject, securityOrigin, false);
153
                continue;
154
155
            auto& securityOrigin = downcast<DOMWindow>(jsWindowProxy->wrapped()).document()->securityOrigin();
156
            notifyContextCreated(frameId, globalObject, jsWindowProxy->world(), &securityOrigin);
158
        }
157
        }
159
        isolatedContexts.clear();
160
    }
158
    }
161
}
159
}
162
160
163
void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobalObject* scriptState, SecurityOrigin* securityOrigin, bool isPageContext)
161
static Inspector::Protocol::Runtime::ExecutionContextType toProtocol(DOMWrapperWorld::Type type)
164
{
162
{
165
    ASSERT(securityOrigin || isPageContext);
163
    switch (type) {
164
    case DOMWrapperWorld::Type::Normal:
165
        return Inspector::Protocol::Runtime::ExecutionContextType::Normal;
166
    case DOMWrapperWorld::Type::User:
167
        return Inspector::Protocol::Runtime::ExecutionContextType::User;
168
    case DOMWrapperWorld::Type::Internal:
169
        return Inspector::Protocol::Runtime::ExecutionContextType::Internal;
170
    }
166
171
167
    InjectedScript result = injectedScriptManager().injectedScriptFor(scriptState);
172
    ASSERT_NOT_REACHED();
168
    if (result.hasNoValue())
173
    return Inspector::Protocol::Runtime::ExecutionContextType::Internal;
174
}
175
176
void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobalObject* globalObject, const DOMWrapperWorld& world, SecurityOrigin* securityOrigin)
177
{
178
    auto injectedScript = injectedScriptManager().injectedScriptFor(globalObject);
179
    if (injectedScript.hasNoValue())
169
        return;
180
        return;
170
181
171
    int executionContextId = injectedScriptManager().injectedScriptIdFor(scriptState);
182
    auto name = world.name();
172
    String name = securityOrigin ? securityOrigin->toRawString() : String();
183
    if (name.isEmpty() && securityOrigin)
173
    m_frontendDispatcher->executionContextCreated(ExecutionContextDescription::create()
184
        name = securityOrigin->toRawString();
174
        .setId(executionContextId)
185
175
        .setIsPageContext(isPageContext)
186
    m_frontendDispatcher->executionContextCreated(Inspector::Protocol::Runtime::ExecutionContextDescription::create()
187
        .setId(injectedScriptManager().injectedScriptIdFor(globalObject))
188
        .setType(toProtocol(world.type()))
176
        .setName(name)
189
        .setName(name)
177
        .setFrameId(frameId)
190
        .setFrameId(frameId)
178
        .release());
191
        .release());
- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h -2 / +3 lines
Lines 41-46 class CallFrame; a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h_sec1
41
41
42
namespace WebCore {
42
namespace WebCore {
43
43
44
class DOMWrapperWorld;
44
class Frame;
45
class Frame;
45
class Page;
46
class Page;
46
class SecurityOrigin;
47
class SecurityOrigin;
Lines 61-74 public: a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h_sec2
61
62
62
    // InspectorInstrumentation
63
    // InspectorInstrumentation
63
    void frameNavigated(Frame&);
64
    void frameNavigated(Frame&);
64
    void didClearWindowObjectInWorld(Frame&);
65
    void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
65
66
66
private:
67
private:
67
    Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
68
    Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
68
    void muteConsole() override;
69
    void muteConsole() override;
69
    void unmuteConsole() override;
70
    void unmuteConsole() override;
70
    void reportExecutionContextCreation();
71
    void reportExecutionContextCreation();
71
    void notifyContextCreated(const String& frameId, JSC::JSGlobalObject*, SecurityOrigin*, bool isPageContext);
72
    void notifyContextCreated(const String& frameId, JSC::JSGlobalObject*, const DOMWrapperWorld&, SecurityOrigin* = nullptr);
72
73
73
    std::unique_ptr<Inspector::RuntimeFrontendDispatcher> m_frontendDispatcher;
74
    std::unique_ptr<Inspector::RuntimeFrontendDispatcher> m_frontendDispatcher;
74
    RefPtr<Inspector::RuntimeBackendDispatcher> m_backendDispatcher;
75
    RefPtr<Inspector::RuntimeBackendDispatcher> m_backendDispatcher;
- a/Source/WebCore/testing/Internals.cpp +9 lines
Lines 162-167 a/Source/WebCore/testing/Internals.cpp_sec1
162
#include "SVGPathStringBuilder.h"
162
#include "SVGPathStringBuilder.h"
163
#include "SVGSVGElement.h"
163
#include "SVGSVGElement.h"
164
#include "SWClientConnection.h"
164
#include "SWClientConnection.h"
165
#include "ScriptController.h"
165
#include "ScriptedAnimationController.h"
166
#include "ScriptedAnimationController.h"
166
#include "ScrollingCoordinator.h"
167
#include "ScrollingCoordinator.h"
167
#include "ScrollingMomentumCalculator.h"
168
#include "ScrollingMomentumCalculator.h"
Lines 3487-3492 bool Internals::isFromCurrentWorld(JSC::JSValue value) const a/Source/WebCore/testing/Internals.cpp_sec2
3487
    return isWorldCompatible(*vm.topCallFrame->lexicalGlobalObject(vm), value);
3488
    return isWorldCompatible(*vm.topCallFrame->lexicalGlobalObject(vm), value);
3488
}
3489
}
3489
3490
3491
JSC::JSValue Internals::evaluateInWorldIgnoringException(const String& name, const String& source)
3492
{
3493
    auto* document = contextDocument();
3494
    auto& scriptController = document->frame()->script();
3495
    auto world = ScriptController::createWorld(name);
3496
    return scriptController.evaluateInWorldIgnoringException(ScriptSourceCode(source), world);
3497
}
3498
3490
void Internals::setUsesOverlayScrollbars(bool enabled)
3499
void Internals::setUsesOverlayScrollbars(bool enabled)
3491
{
3500
{
3492
    WebCore::DeprecatedGlobalSettings::setUsesOverlayScrollbars(enabled);
3501
    WebCore::DeprecatedGlobalSettings::setUsesOverlayScrollbars(enabled);
- a/Source/WebCore/testing/Internals.h +1 lines
Lines 516-521 public: a/Source/WebCore/testing/Internals.h_sec1
516
    Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
516
    Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
517
517
518
    bool isFromCurrentWorld(JSC::JSValue) const;
518
    bool isFromCurrentWorld(JSC::JSValue) const;
519
    JSC::JSValue evaluateInWorldIgnoringException(const String& name, const String& source);
519
520
520
    void setUsesOverlayScrollbars(bool);
521
    void setUsesOverlayScrollbars(bool);
521
    void setUsesMockScrollAnimator(bool);
522
    void setUsesMockScrollAnimator(bool);
- a/Source/WebCore/testing/Internals.idl +1 lines
Lines 548-553 enum CompositingPolicy { a/Source/WebCore/testing/Internals.idl_sec1
548
    ArrayBuffer serializeObject(SerializedScriptValue object);
548
    ArrayBuffer serializeObject(SerializedScriptValue object);
549
549
550
    boolean isFromCurrentWorld(any obj);
550
    boolean isFromCurrentWorld(any obj);
551
    any evaluateInWorldIgnoringException(DOMString name, DOMString source);
551
552
552
    void setUsesOverlayScrollbars(boolean enabled);
553
    void setUsesOverlayScrollbars(boolean enabled);
553
    void setUsesMockScrollAnimator(boolean enabled);
554
    void setUsesMockScrollAnimator(boolean enabled);
- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js -3 / +2 lines
Lines 158-166 localizedStrings["Audit Warning: %s"] = "Audit Warning: %s"; a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js_sec1
158
localizedStrings["Audit version: %s"] = "Audit version: %s";
158
localizedStrings["Audit version: %s"] = "Audit version: %s";
159
localizedStrings["Audits"] = "Audits";
159
localizedStrings["Audits"] = "Audits";
160
localizedStrings["Author Style Sheet"] = "Author Style Sheet";
160
localizedStrings["Author Style Sheet"] = "Author Style Sheet";
161
localizedStrings["Auto"] = "Auto";
162
localizedStrings["Auto - %s"] = "Auto - %s";
163
localizedStrings["Auto Increment"] = "Auto Increment";
161
localizedStrings["Auto Increment"] = "Auto Increment";
162
localizedStrings["Auto \u2014 %s"] = "Auto \u2014 %s";
164
localizedStrings["Auto-expand"] = "Auto-expand";
163
localizedStrings["Auto-expand"] = "Auto-expand";
165
localizedStrings["Automatically continue after evaluating"] = "Automatically continue after evaluating";
164
localizedStrings["Automatically continue after evaluating"] = "Automatically continue after evaluating";
166
localizedStrings["Available Style Sheets"] = "Available Style Sheets";
165
localizedStrings["Available Style Sheets"] = "Available Style Sheets";
Lines 1312-1319 localizedStrings["With Object Properties"] = "With Object Properties"; a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js_sec2
1312
localizedStrings["Worker"] = "Worker";
1311
localizedStrings["Worker"] = "Worker";
1313
localizedStrings["Worker Thread"] = "Worker Thread";
1312
localizedStrings["Worker Thread"] = "Worker Thread";
1314
localizedStrings["Worker Threads"] = "Worker Threads";
1313
localizedStrings["Worker Threads"] = "Worker Threads";
1315
localizedStrings["Worker \u2014 %s"] = "Worker \u2014 %s";
1316
localizedStrings["Worker: %s"] = "Worker: %s";
1314
localizedStrings["Worker: %s"] = "Worker: %s";
1315
localizedStrings["Workers"] = "Workers";
1317
localizedStrings["Wrap lines to editor width"] = "Wrap lines to editor width";
1316
localizedStrings["Wrap lines to editor width"] = "Wrap lines to editor width";
1318
localizedStrings["XBM"] = "XBM";
1317
localizedStrings["XBM"] = "XBM";
1319
localizedStrings["XHR"] = "XHR";
1318
localizedStrings["XHR"] = "XHR";
- a/Source/WebInspectorUI/UserInterface/Base/Setting.js +1 lines
Lines 227-232 WI.settings = { a/Source/WebInspectorUI/UserInterface/Base/Setting.js_sec1
227
    protocolFilterMultiplexingBackendMessages: new WI.Setting("protocol-filter-multiplexing-backend-messages", true),
227
    protocolFilterMultiplexingBackendMessages: new WI.Setting("protocol-filter-multiplexing-backend-messages", true),
228
228
229
    // Engineering
229
    // Engineering
230
    engineeringShowInternalExecutionContexts: new WI.EngineeringSetting("engineering-show-internal-execution-contexts", false),
230
    engineeringShowInternalScripts: new WI.EngineeringSetting("engineering-show-internal-scripts", false),
231
    engineeringShowInternalScripts: new WI.EngineeringSetting("engineering-show-internal-scripts", false),
231
    engineeringPauseForInternalScripts: new WI.EngineeringSetting("engineering-pause-for-internal-scripts", false),
232
    engineeringPauseForInternalScripts: new WI.EngineeringSetting("engineering-pause-for-internal-scripts", false),
232
    engineeringShowInternalObjectsInHeapSnapshot: new WI.EngineeringSetting("engineering-show-internal-objects-in-heap-snapshot", false),
233
    engineeringShowInternalObjectsInHeapSnapshot: new WI.EngineeringSetting("engineering-show-internal-objects-in-heap-snapshot", false),
- a/Source/WebInspectorUI/UserInterface/Base/Utilities.js -1 / +1 lines
Lines 1646-1652 function isWebKitInternalScript(url) a/Source/WebInspectorUI/UserInterface/Base/Utilities.js_sec1
1646
1646
1647
function isWebKitExtensionScheme(scheme)
1647
function isWebKitExtensionScheme(scheme)
1648
{
1648
{
1649
    return scheme && scheme.endsWith("extension");
1649
    return scheme && scheme.endsWith("-extension");
1650
}
1650
}
1651
1651
1652
function isFunctionStringNativeCode(str)
1652
function isFunctionStringNativeCode(str)
- a/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js -4 / +4 lines
Lines 976-991 WI.NetworkManager = class NetworkManager extends WI.Object a/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js_sec1
976
976
977
    // RuntimeObserver
977
    // RuntimeObserver
978
978
979
    executionContextCreated(contextPayload)
979
    executionContextCreated(payload)
980
    {
980
    {
981
        let frame = this.frameForIdentifier(contextPayload.frameId);
981
        let frame = this.frameForIdentifier(payload.frameId);
982
        console.assert(frame);
982
        console.assert(frame);
983
        if (!frame)
983
        if (!frame)
984
            return;
984
            return;
985
985
986
        let displayName = contextPayload.name || frame.mainResource.displayName;
986
        let type = WI.ExecutionContext.typeFromPayload(payload);
987
        let target = frame.mainResource.target;
987
        let target = frame.mainResource.target;
988
        let executionContext = new WI.ExecutionContext(target, contextPayload.id, displayName, contextPayload.isPageContext, frame);
988
        let executionContext = new WI.ExecutionContext(target, payload.id, type, payload.name, frame);
989
        frame.addExecutionContext(executionContext);
989
        frame.addExecutionContext(executionContext);
990
    }
990
    }
991
991
- a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js -11 lines
Lines 38-45 WI.RuntimeManager = class RuntimeManager extends WI.Object a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js_sec1
38
                    target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value);
38
                    target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value);
39
            }
39
            }
40
        });
40
        });
41
42
        WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this);
43
    }
41
    }
44
42
45
    // Static
43
    // Static
Lines 189-203 WI.RuntimeManager = class RuntimeManager extends WI.Object a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js_sec2
189
187
190
    // Private
188
    // Private
191
189
192
    _frameExecutionContextsCleared(event)
193
    {
194
        let contexts = event.data.contexts || [];
195
196
        let currentContextWasDestroyed = contexts.some((context) => context.id === this._activeExecutionContext.id);
197
        if (currentContextWasDestroyed)
198
            this.activeExecutionContext = WI.mainTarget.executionContext;
199
    }
200
201
    _tryApplyAwaitConvenience(originalExpression)
190
    _tryApplyAwaitConvenience(originalExpression)
202
    {
191
    {
203
        let esprimaSyntaxTree;
192
        let esprimaSyntaxTree;
- a/Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js -2 / +6 lines
Lines 44-49 WI.TargetManager = class TargetManager extends WI.Object a/Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js_sec1
44
        return this._cachedTargetsList;
44
        return this._cachedTargetsList;
45
    }
45
    }
46
46
47
    get workerTargets()
48
    {
49
        return this.targets.filter((target) => target.type === WI.TargetType.Worker);
50
    }
51
47
    get allTargets()
52
    get allTargets()
48
    {
53
    {
49
        return Array.from(this._targets.values());
54
        return Array.from(this._targets.values());
Lines 275-282 WI.TargetManager = class TargetManager extends WI.Object a/Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js_sec2
275
        console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.WebPage);
280
        console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.WebPage);
276
281
277
        // Remove any Worker targets associated with this page.
282
        // Remove any Worker targets associated with this page.
278
        let workerTargets = WI.targets.filter((x) => x.type === WI.TargetType.Worker);
283
        for (let workerTarget of this.workerTargets)
279
        for (let workerTarget of workerTargets)
280
            WI.workerManager.workerTerminated(workerTarget.identifier);
284
            WI.workerManager.workerTerminated(workerTarget.identifier);
281
285
282
        WI.pageTarget = null;
286
        WI.pageTarget = null;
- a/Source/WebInspectorUI/UserInterface/Main.html -1 / +1 lines
Lines 767-773 a/Source/WebInspectorUI/UserInterface/Main.html_sec1
767
    <script src="Views/ProfileView.js"></script>
767
    <script src="Views/ProfileView.js"></script>
768
    <script src="Views/ProgressView.js"></script>
768
    <script src="Views/ProgressView.js"></script>
769
    <script src="Views/QuickConsole.js"></script>
769
    <script src="Views/QuickConsole.js"></script>
770
    <script src="Views/QuickConsoleNavigationBar.js"></script>
771
    <script src="Views/RadioButtonNavigationItem.js"></script>
770
    <script src="Views/RadioButtonNavigationItem.js"></script>
772
    <script src="Views/RangeChart.js"></script>
771
    <script src="Views/RangeChart.js"></script>
773
    <script src="Views/RecordingActionTreeElement.js"></script>
772
    <script src="Views/RecordingActionTreeElement.js"></script>
Lines 807-812 a/Source/WebInspectorUI/UserInterface/Main.html_sec2
807
    <script src="Views/ShaderProgramContentView.js"></script>
806
    <script src="Views/ShaderProgramContentView.js"></script>
808
    <script src="Views/ShaderProgramTreeElement.js"></script>
807
    <script src="Views/ShaderProgramTreeElement.js"></script>
809
    <script src="Views/Sidebar.js"></script>
808
    <script src="Views/Sidebar.js"></script>
809
    <script src="Views/SizesToFitNavigationBar.js"></script>
810
    <script src="Views/Slider.js"></script>
810
    <script src="Views/Slider.js"></script>
811
    <script src="Views/SoftContextMenu.js"></script>
811
    <script src="Views/SoftContextMenu.js"></script>
812
    <script src="Views/SourceCodeTextEditor.js"></script>
812
    <script src="Views/SourceCodeTextEditor.js"></script>
- a/Source/WebInspectorUI/UserInterface/Models/ExecutionContext.js -5 / +34 lines
Lines 25-48 a/Source/WebInspectorUI/UserInterface/Models/ExecutionContext.js_sec1
25
25
26
WI.ExecutionContext = class ExecutionContext
26
WI.ExecutionContext = class ExecutionContext
27
{
27
{
28
    constructor(target, id, name, isPageContext, frame)
28
    constructor(target, id, type, name, frame)
29
    {
29
    {
30
        console.assert(target instanceof WI.Target);
30
        console.assert(target instanceof WI.Target);
31
        console.assert(typeof id === "number" || id === WI.RuntimeManager.TopLevelExecutionContextIdentifier);
31
        console.assert(typeof id === "number" || id === WI.RuntimeManager.TopLevelExecutionContextIdentifier);
32
        console.assert(typeof name === "string");
32
        console.assert(Object.values(WI.ExecutionContext.Type).includes(type));
33
        console.assert(!name || typeof name === "string");
34
        console.assert(frame instanceof WI.Frame || id === WI.RuntimeManager.TopLevelExecutionContextIdentifier);
33
35
34
        this._target = target;
36
        this._target = target;
35
        this._id = id;
37
        this._id = id;
36
        this._name = name;
38
        this._type = type || WI.ExecutionContext.Type.Internal;
37
        this._isPageContext = isPageContext || false;
39
        this._name = name || "";
38
        this._frame = frame || null;
40
        this._frame = frame || null;
39
    }
41
    }
40
42
43
    // Static
44
45
    static typeFromPayload(payload)
46
    {
47
        // COMPATIBILITY (iOS 13.1): `Runtime.ExecutionContextType` did not exist yet.
48
        if (!("type" in payload))
49
            return payload.isPageContext ? WI.ExecutionContext.Type.Normal : WI.ExecutionContext.Type.Internal;
50
51
        switch (payload.type) {
52
        case InspectorBackend.Enum.Runtime.ExecutionContextType.Normal:
53
            return WI.ExecutionContext.Type.Normal;
54
        case InspectorBackend.Enum.Runtime.ExecutionContextType.User:
55
            return WI.ExecutionContext.Type.User;
56
        case InspectorBackend.Enum.Runtime.ExecutionContextType.Internal:
57
            return WI.ExecutionContext.Type.Internal;
58
        }
59
60
        console.assert(false, "Unknown Runtime.ExecutionContextType", payload.type);
61
        return WI.ExecutionContext.Type.Internal;
62
    }
63
41
    // Public
64
    // Public
42
65
43
    get target() { return this._target; }
66
    get target() { return this._target; }
44
    get id() { return this._id; }
67
    get id() { return this._id; }
68
    get type() { return this._type; }
45
    get name() { return this._name; }
69
    get name() { return this._name; }
46
    get isPageContext() { return this._isPageContext; }
47
    get frame() { return this._frame; }
70
    get frame() { return this._frame; }
48
};
71
};
72
73
WI.ExecutionContext.Type = {
74
    Normal: "normal",
75
    User: "user",
76
    Internal: "internal",
77
};
- a/Source/WebInspectorUI/UserInterface/Models/ExecutionContextList.js -6 / +3 lines
Lines 47-66 WI.ExecutionContextList = class ExecutionContextList a/Source/WebInspectorUI/UserInterface/Models/ExecutionContextList.js_sec1
47
    {
47
    {
48
        // COMPATIBILITY (iOS 13.0): Older iOS releases will send duplicates.
48
        // COMPATIBILITY (iOS 13.0): Older iOS releases will send duplicates.
49
        // Newer releases will not and this check should be removed eventually.
49
        // Newer releases will not and this check should be removed eventually.
50
        if (context.isPageContext && this._pageExecutionContext) {
50
        if (context.type === WI.ExecutionContext.Type.Normal && this._pageExecutionContext) {
51
            console.assert(context.id === this._pageExecutionContext.id);
51
            console.assert(context.id === this._pageExecutionContext.id);
52
            return false;
52
            return;
53
        }
53
        }
54
54
55
        this._contexts.push(context);
55
        this._contexts.push(context);
56
56
57
        if (context.isPageContext) {
57
        if (context.type === WI.ExecutionContext.Type.Normal && context.target.type === WI.TargetType.Page) {
58
            console.assert(!this._pageExecutionContext);
58
            console.assert(!this._pageExecutionContext);
59
            this._pageExecutionContext = context;
59
            this._pageExecutionContext = context;
60
            return true;
61
        }
60
        }
62
63
        return false;
64
    }
61
    }
65
62
66
    clear()
63
    clear()
- a/Source/WebInspectorUI/UserInterface/Models/Frame.js -2 / +5 lines
Lines 223-231 WI.Frame = class Frame extends WI.Object a/Source/WebInspectorUI/UserInterface/Models/Frame.js_sec1
223
223
224
    addExecutionContext(context)
224
    addExecutionContext(context)
225
    {
225
    {
226
        var changedPageContext = this._executionContextList.add(context);
226
        this._executionContextList.add(context);
227
227
228
        if (changedPageContext)
228
        this.dispatchEventToListeners(WI.Frame.Event.ExecutionContextAdded, {context});
229
230
        if (this._executionContextList.pageExecutionContext === context)
229
            this.dispatchEventToListeners(WI.Frame.Event.PageExecutionContextChanged);
231
            this.dispatchEventToListeners(WI.Frame.Event.PageExecutionContextChanged);
230
    }
232
    }
231
233
Lines 509-514 WI.Frame.Event = { a/Source/WebInspectorUI/UserInterface/Models/Frame.js_sec2
509
    ChildFrameWasRemoved: "frame-child-frame-was-removed",
511
    ChildFrameWasRemoved: "frame-child-frame-was-removed",
510
    AllChildFramesRemoved: "frame-all-child-frames-removed",
512
    AllChildFramesRemoved: "frame-all-child-frames-removed",
511
    PageExecutionContextChanged: "frame-page-execution-context-changed",
513
    PageExecutionContextChanged: "frame-page-execution-context-changed",
514
    ExecutionContextAdded: "frame-execution-context-added",
512
    ExecutionContextsCleared: "frame-execution-contexts-cleared"
515
    ExecutionContextsCleared: "frame-execution-contexts-cleared"
513
};
516
};
514
517
- a/Source/WebInspectorUI/UserInterface/Protocol/DirectBackendTarget.js -1 / +1 lines
Lines 35-41 WI.DirectBackendTarget = class DirectBackendTarget extends WI.Target a/Source/WebInspectorUI/UserInterface/Protocol/DirectBackendTarget.js_sec1
35
        let {type, displayName} = DirectBackendTarget.connectionInfoForDebuggable();
35
        let {type, displayName} = DirectBackendTarget.connectionInfoForDebuggable();
36
        super(parentTarget, targetId, displayName, type, InspectorBackend.backendConnection);
36
        super(parentTarget, targetId, displayName, type, InspectorBackend.backendConnection);
37
37
38
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, displayName, true, null);
38
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, WI.ExecutionContext.Type.Normal, displayName);
39
        this._mainResource = null;
39
        this._mainResource = null;
40
    }
40
    }
41
41
- a/Source/WebInspectorUI/UserInterface/Protocol/PageTarget.js -2 / +1 lines
Lines 29-35 WI.PageTarget = class PageTarget extends WI.Target a/Source/WebInspectorUI/UserInterface/Protocol/PageTarget.js_sec1
29
    {
29
    {
30
        super(parentTarget, targetId, name, WI.TargetType.Page, connection, options);
30
        super(parentTarget, targetId, name, WI.TargetType.Page, connection, options);
31
31
32
        const isPageContext = true;
32
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, WI.ExecutionContext.Type.Normal, this.displayName);
33
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, this.displayName, isPageContext, null);
34
    }
33
    }
35
};
34
};
- a/Source/WebInspectorUI/UserInterface/Protocol/WorkerTarget.js -2 / +1 lines
Lines 29-36 WI.WorkerTarget = class WorkerTarget extends WI.Target a/Source/WebInspectorUI/UserInterface/Protocol/WorkerTarget.js_sec1
29
    {
29
    {
30
        super(parentTarget, workerId, name, WI.TargetType.Worker, connection, options);
30
        super(parentTarget, workerId, name, WI.TargetType.Worker, connection, options);
31
31
32
        const isPageContext = false;
32
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, WI.ExecutionContext.Type.Normal, this.displayName);
33
        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, this.displayName, isPageContext, null);
34
    }
33
    }
35
34
36
    // Protected (Target)
35
    // Protected (Target)
- a/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js +21 lines
Lines 120-125 InspectorProtocol.addEventListener = function(eventTypeOrObject, listener) a/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js_sec1
120
        throw new Error("Cannot register the same listener more than once.");
120
        throw new Error("Cannot register the same listener more than once.");
121
121
122
    listeners.push(listener);
122
    listeners.push(listener);
123
    return listener;
124
};
125
126
InspectorProtocol.removeEventListener = function(eventTypeOrObject, listener)
127
{
128
    let event = eventTypeOrObject;
129
    if (typeof eventTypeOrObject === "object")
130
        ({event, listener} = eventTypeOrObject);
131
132
    if (typeof event !== "string")
133
        throw new Error("Event name must be a string.");
134
135
    if (typeof listener !== "function")
136
        throw new Error("Event listener must be callable.");
137
138
    // Convert to an array of listeners.
139
    let listeners = InspectorProtocol.eventHandler[event];
140
    if (!listeners)
141
        return;
142
143
    listeners.removeAll(listener);
123
};
144
};
124
145
125
InspectorProtocol.checkForError = function(responseObject)
146
InspectorProtocol.checkForError = function(responseObject)
- a/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js +7 lines
Lines 116-121 WI.ContextSubMenuItem = class ContextSubMenuItem extends WI.ContextMenuItem a/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js_sec1
116
        return item;
116
        return item;
117
    }
117
    }
118
118
119
    appendHeader(label)
120
    {
121
        return this.appendItem(label, () => {
122
            console.assert(false, "not reached");
123
        }, true);
124
    }
125
119
    appendSeparator()
126
    appendSeparator()
120
    {
127
    {
121
        if (this._items.length)
128
        if (this._items.length)
- a/Source/WebInspectorUI/UserInterface/Views/GroupNavigationItem.js +4 lines
Lines 71-76 WI.GroupNavigationItem = class GroupNavigationItem extends WI.NavigationItem a/Source/WebInspectorUI/UserInterface/Views/GroupNavigationItem.js_sec1
71
    {
71
    {
72
        super.update(options);
72
        super.update(options);
73
73
74
        this._updateItems();
75
74
        for (let item of this._navigationItems)
76
        for (let item of this._navigationItems)
75
            item.update(options);
77
            item.update(options);
76
    }
78
    }
Lines 79-84 WI.GroupNavigationItem = class GroupNavigationItem extends WI.NavigationItem a/Source/WebInspectorUI/UserInterface/Views/GroupNavigationItem.js_sec2
79
    {
81
    {
80
        super.didAttach(navigationBar);
82
        super.didAttach(navigationBar);
81
83
84
        this._updateItems();
85
82
        for (let item of this._navigationItems)
86
        for (let item of this._navigationItems)
83
            item.didAttach(navigationBar);
87
            item.didAttach(navigationBar);
84
    }
88
    }
- a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.css -20 / +24 lines
Lines 51-57 a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.css_sec1
51
51
52
    align-items: flex-start;
52
    align-items: flex-start;
53
53
54
    max-height: 150px;
54
    max-height: 33vh;
55
55
56
    overflow-y: auto;
56
    overflow-y: auto;
57
    overflow-x: hidden;
57
    overflow-x: hidden;
Lines 79-113 a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.css_sec2
79
}
79
}
80
80
81
.quick-console > .navigation-bar {
81
.quick-console > .navigation-bar {
82
    background: transparent;
83
    border: none;
84
85
    height: 21px;
82
    height: 21px;
83
    border-bottom: none;
86
}
84
}
87
85
88
.quick-console .execution-context {
86
.quick-console > .navigation-bar .active-execution-context {
89
    margin-top: -1px;
90
}
91
92
.quick-console > .navigation-bar > .hierarchical-path .execution-context {
93
    -webkit-margin-end: 7px;
87
    -webkit-margin-end: 7px;
94
}
95
96
.quick-console > .navigation-bar > .hierarchical-path .execution-context .separator {
97
    display: none;
98
}
99
100
.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context) {
101
    -webkit-padding-start: 5px;
88
    -webkit-padding-start: 5px;
89
    -webkit-padding-end: 1px;
90
    font-family: -webkit-system-font, sans-serif;
91
    font-size: 11px;
102
}
92
}
103
93
104
.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context) .execution-context {
94
.quick-console > .navigation-bar .active-execution-context > .selector-arrows {
105
    background: var(--selected-background-color);
95
    width: 5px;
106
    border-radius: 3px;
96
    height: 16px;
97
    margin-top: 2px;
98
    margin-bottom: 2px;
99
    -webkit-margin-start: 4px;
100
    -webkit-margin-end: 3px;
101
    opacity: 0.6;
102
}
103
104
.quick-console > .navigation-bar .active-execution-context:not(.automatic) {
105
    margin-top: -1px;
106
    height: 20px;
107
    -webkit-margin-start: 5px;
108
    line-height: 20px;
107
    color: var(--selected-foreground-color);
109
    color: var(--selected-foreground-color);
110
    background-color: var(--selected-background-color);
111
    border-radius: 3px;
108
}
112
}
109
113
110
.quick-console > .navigation-bar > .hierarchical-path:not(.automatic-execution-context) .execution-context .selector-arrows {
114
.quick-console > .navigation-bar .active-execution-context:not(.automatic) > .selector-arrows {
111
    color: var(--selected-foreground-color);
115
    color: var(--selected-foreground-color);
112
    opacity: 1;
116
    opacity: 1;
113
}
117
}
- a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js -288 / +237 lines
Lines 33-49 WI.QuickConsole = class QuickConsole extends WI.View a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js_sec1
33
        this._toggleOrFocusKeyboardShortcut.implicitlyPreventsDefault = false;
33
        this._toggleOrFocusKeyboardShortcut.implicitlyPreventsDefault = false;
34
        this._keyboardShortcutDisabled = false;
34
        this._keyboardShortcutDisabled = false;
35
35
36
        this._automaticExecutionContextPathComponent = this._createExecutionContextPathComponent(null, WI.UIString("Auto"));
36
        this._useExecutionContextOfInspectedNode = InspectorBackend.hasDomain("DOM");
37
        this._updateAutomaticExecutionContextPathComponentTooltip();
37
        this._restoreSelectedExecutionContextForFrame = null;
38
39
        this._mainExecutionContextPathComponent = null;
40
        this._otherExecutionContextPathComponents = [];
41
42
        this._frameToPathComponent = new Map;
43
        this._targetToPathComponent = new Map;
44
45
        this._shouldAutomaticallySelectExecutionContext = true;
46
        this._restoreSelectedExecutionContextForFrame = false;
47
38
48
        this.element.classList.add("quick-console");
39
        this.element.classList.add("quick-console");
49
        this.element.addEventListener("mousedown", this._handleMouseDown.bind(this));
40
        this.element.addEventListener("mousedown", this._handleMouseDown.bind(this));
Lines 60-107 WI.QuickConsole = class QuickConsole extends WI.View a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js_sec2
60
        // would be for CodeMirror's event handler to pass if it doesn't do anything.
51
        // would be for CodeMirror's event handler to pass if it doesn't do anything.
61
        this.prompt.escapeKeyHandlerWhenEmpty = function() { WI.toggleSplitConsole(); };
52
        this.prompt.escapeKeyHandlerWhenEmpty = function() { WI.toggleSplitConsole(); };
62
53
63
        this._navigationBar = new WI.QuickConsoleNavigationBar;
54
        this._navigationBar = new WI.SizesToFitNavigationBar;
64
        this.addSubview(this._navigationBar);
55
        this.addSubview(this._navigationBar);
65
56
66
        this._executionContextSelectorItem = new WI.HierarchicalPathNavigationItem;
57
        this._activeExecutionContextNavigationItemDivider = new WI.DividerNavigationItem;
67
        this._executionContextSelectorItem.showSelectorArrows = true;
58
        this._navigationBar.addNavigationItem(this._activeExecutionContextNavigationItemDivider);
68
        this._navigationBar.addNavigationItem(this._executionContextSelectorItem);
69
59
70
        this._executionContextSelectorDivider = new WI.DividerNavigationItem;
60
        this._activeExecutionContextNavigationItem = new WI.NavigationItem("active-execution-context");
71
        this._navigationBar.addNavigationItem(this._executionContextSelectorDivider);
61
        WI.addMouseDownContextMenuHandlers(this._activeExecutionContextNavigationItem.element, this._populateActiveExecutionContextNavigationItemContextMenu.bind(this));
62
        this._navigationBar.addNavigationItem(this._activeExecutionContextNavigationItem);
72
63
73
        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, this._updateAutomaticExecutionContextPathComponentTooltip, this);
64
        this._updateActiveExecutionContextDisplay();
74
65
75
        WI.consoleDrawer.toggleButtonShortcutTooltip(this._toggleOrFocusKeyboardShortcut);
66
        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, this._handleConsoleSavedResultAliasSettingChanged, this);
76
        WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this);
67
        WI.settings.engineeringShowInternalExecutionContexts.addEventListener(WI.Setting.Event.Changed, this._handleEngineeringShowInternalExecutionContextsSettingChanged, this);
77
68
78
        WI.Frame.addEventListener(WI.Frame.Event.PageExecutionContextChanged, this._framePageExecutionContextsChanged, this);
69
        WI.Frame.addEventListener(WI.Frame.Event.PageExecutionContextChanged, this._handleFramePageExecutionContextChanged, this);
79
        WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this);
70
        WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._handleFrameExecutionContextsCleared, this);
80
71
81
        WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._debuggerActiveCallFrameDidChange, this);
72
        WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._handleDebuggerActiveCallFrameDidChange, this);
82
73
83
        WI.runtimeManager.addEventListener(WI.RuntimeManager.Event.ActiveExecutionContextChanged, this._activeExecutionContextChanged, this);
74
        WI.runtimeManager.addEventListener(WI.RuntimeManager.Event.ActiveExecutionContextChanged, this._handleActiveExecutionContextChanged, this);
84
        WI.notifications.addEventListener(WI.Notification.TransitionPageTarget, this._pageTargetTransitioned, this);
85
75
86
        WI.targetManager.addEventListener(WI.TargetManager.Event.TargetAdded, this._targetAdded, this);
76
        WI.notifications.addEventListener(WI.Notification.TransitionPageTarget, this._handleTransitionPageTarget, this);
87
        WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this);
77
78
        WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._handleTargetRemoved, this);
88
79
89
        WI.domManager.addEventListener(WI.DOMManager.Event.InspectedNodeChanged, this._handleInspectedNodeChanged, this);
80
        WI.domManager.addEventListener(WI.DOMManager.Event.InspectedNodeChanged, this._handleInspectedNodeChanged, this);
90
81
82
        WI.consoleDrawer.toggleButtonShortcutTooltip(this._toggleOrFocusKeyboardShortcut);
83
        WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this);
91
        WI.TabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._updateStyles, this);
84
        WI.TabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._updateStyles, this);
92
85
93
        WI.whenTargetsAvailable().then(() => {
86
        WI.whenTargetsAvailable().then(() => {
94
            this._initializeMainExecutionContextPathComponent();
87
            this._updateActiveExecutionContextDisplay();
95
        });
88
        });
96
    }
89
    }
97
90
98
    // Public
91
    // Public
99
92
100
    get navigationBar()
101
    {
102
        return this._navigationBar;
103
    }
104
105
    set keyboardShortcutDisabled(disabled)
93
    set keyboardShortcutDisabled(disabled)
106
    {
94
    {
107
        this._keyboardShortcutDisabled = disabled;
95
        this._keyboardShortcutDisabled = disabled;
Lines 120-194 WI.QuickConsole = class QuickConsole extends WI.View a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js_sec3
120
        super.closed();
108
        super.closed();
121
    }
109
    }
122
110
123
    _pageTargetTransitioned()
124
    {
125
        this._initializeMainExecutionContextPathComponent();
126
    }
127
128
    _initializeMainExecutionContextPathComponent()
129
    {
130
        if (!WI.mainTarget || WI.mainTarget instanceof WI.MultiplexingBackendTarget)
131
            return;
132
133
        let nextSibling = this._mainExecutionContextPathComponent ? this._mainExecutionContextPathComponent.nextSibling : null;
134
135
        this._mainExecutionContextPathComponent = this._createExecutionContextPathComponent(WI.mainTarget.executionContext);
136
        this._mainExecutionContextPathComponent.previousSibling = this._automaticExecutionContextPathComponent;
137
        this._mainExecutionContextPathComponent.nextSibling = nextSibling;
138
139
        this._automaticExecutionContextPathComponent.nextSibling = this._mainExecutionContextPathComponent;
140
141
        this._shouldAutomaticallySelectExecutionContext = true;
142
        this._selectExecutionContext(WI.mainTarget.executionContext);
143
        this._rebuildExecutionContextPathComponents();
144
    }
145
146
    // Protected
147
148
    layout()
149
    {
150
        // A hard maximum size of 33% of the window.
151
        let maximumAllowedHeight = Math.round(window.innerHeight * 0.33);
152
        this.prompt.element.style.maxHeight = maximumAllowedHeight + "px";
153
    }
154
155
    // Private
111
    // Private
156
112
157
    _preferredNameForFrame(frame)
113
    _displayNameForExecutionContext(context, maxLength = Infinity)
158
    {
114
    {
159
        if (frame.name)
115
        function truncate(string, length) {
160
            return WI.UIString("%s (%s)").format(frame.name, frame.mainResource.displayName);
116
            if (!Number.isFinite(maxLength))
161
        return frame.mainResource.displayName;
117
                return string;
162
    }
118
            return string.trim().truncateMiddle(length);
119
        }
163
120
164
    _selectExecutionContext(executionContext)
121
        if (context.type === WI.ExecutionContext.Type.Internal)
165
    {
122
            return WI.unlocalizedString("[Internal] ") + context.name;
166
        let preferredName = null;
167
123
168
        let inspectedNode = WI.domManager.inspectedNode;
124
        let target = context.target;
169
        if (inspectedNode) {
125
        if (target.type === WI.TargetType.Worker)
170
            let frame = inspectedNode.frame;
126
            return truncate(target.displayName, maxLength);
171
            if (frame) {
127
172
                if (this._shouldAutomaticallySelectExecutionContext)
128
        let frame = context.frame;
173
                    executionContext = frame.pageExecutionContext;
129
        if (frame) {
174
                preferredName = this._preferredNameForFrame(frame);
130
            if (context === frame.executionContextList.pageExecutionContext) {
131
                let resourceName = frame.mainResource.displayName;
132
                let frameName = frame.name;
133
                if (frameName) {
134
                    // Attempt to show all of the frame name, but ensure that at least 20 characters
135
                    // of the resource name are shown as well.
136
                    let frameNameMaxLength = Math.max(maxLength - resourceName.length, 20);
137
                    return WI.UIString("%s (%s)").format(truncate(frameName, frameNameMaxLength), truncate(resourceName, maxLength - frameNameMaxLength));
138
                }
139
                return truncate(resourceName, maxLength);
175
            }
140
            }
176
        }
141
        }
177
142
178
        if (!executionContext)
143
        return truncate(context.name, maxLength);
179
            executionContext = WI.mainTarget.executionContext;
180
181
        this._automaticExecutionContextPathComponent.displayName = WI.UIString("Auto - %s").format(preferredName || executionContext.name);
182
183
        let changed = WI.runtimeManager.activeExecutionContext !== executionContext;
184
        if (changed)
185
            WI.runtimeManager.activeExecutionContext = executionContext;
186
        return changed;
187
    }
144
    }
188
145
189
    _updateAutomaticExecutionContextPathComponentTooltip()
146
    _resolveDesiredActiveExecutionContext(forceInspectedNode)
190
    {
147
    {
191
        this._automaticExecutionContextPathComponent.tooltip = WI.UIString("Execution context for %s").format(WI.RuntimeManager.preferredSavedResultPrefix() + "0");
148
        let executionContext = null;
149
150
        if (this._useExecutionContextOfInspectedNode || forceInspectedNode) {
151
            let inspectedNode = WI.domManager.inspectedNode;
152
            if (inspectedNode) {
153
                let frame = inspectedNode.frame;
154
                if (frame) {
155
                    let pageExecutionContext = frame.pageExecutionContext;
156
                    if (pageExecutionContext)
157
                        executionContext = pageExecutionContext;
158
                }
159
            }
160
        }
161
162
        if (!executionContext && WI.networkManager.mainFrame)
163
            executionContext = WI.networkManager.mainFrame.pageExecutionContext;
164
165
        return executionContext || WI.mainTarget.executionContext;
166
    }
167
168
    _setActiveExecutionContext(context)
169
    {
170
        let wasActive = WI.runtimeManager.activeExecutionContext === context;
171
172
        WI.runtimeManager.activeExecutionContext = context;
173
174
        if (wasActive)
175
            this._updateActiveExecutionContextDisplay();
176
    }
177
178
    _updateActiveExecutionContextDisplay()
179
    {
180
        let toggleHidden = (hidden) => {
181
            this._activeExecutionContextNavigationItemDivider.hidden = hidden;
182
            this._activeExecutionContextNavigationItem.hidden = hidden;
183
        };
184
185
        if (WI.debuggerManager.activeCallFrame) {
186
            toggleHidden(true);
187
            return;
188
        }
189
190
        if (!WI.runtimeManager.activeExecutionContext || !WI.networkManager.mainFrame) {
191
            toggleHidden(true);
192
            return;
193
        }
194
195
        if (WI.networkManager.frames.length === 1 && WI.networkManager.mainFrame.executionContextList.contexts.length === 1 && !WI.targetManager.workerTargets.length) {
196
            toggleHidden(true);
197
            return;
198
        }
199
200
        const maxLength = 40;
201
202
        if (this._useExecutionContextOfInspectedNode) {
203
            this._activeExecutionContextNavigationItem.element.classList.add("automatic");
204
            this._activeExecutionContextNavigationItem.element.textContent = WI.UIString("Auto \u2014 %s").format(this._displayNameForExecutionContext(WI.runtimeManager.activeExecutionContext, maxLength));
205
            this._activeExecutionContextNavigationItem.tooltip = WI.UIString("Execution context for %s").format(WI.RuntimeManager.preferredSavedResultPrefix() + "0");
206
        } else {
207
            this._activeExecutionContextNavigationItem.element.classList.remove("automatic");
208
            this._activeExecutionContextNavigationItem.element.textContent = this._displayNameForExecutionContext(WI.runtimeManager.activeExecutionContext, maxLength);
209
            this._activeExecutionContextNavigationItem.tooltip = this._displayNameForExecutionContext(WI.runtimeManager.activeExecutionContext);
210
        }
211
212
        this._activeExecutionContextNavigationItem.element.appendChild(WI.ImageUtilities.useSVGSymbol("Images/UpDownArrows.svg", "selector-arrows"));
213
214
        toggleHidden(false);
215
    }
216
217
    _populateActiveExecutionContextNavigationItemContextMenu(contextMenu)
218
    {
219
        const maxLength = 120;
220
221
        let activeExecutionContext = WI.runtimeManager.activeExecutionContext;
222
223
        if (InspectorBackend.hasDomain("DOM")) {
224
            let executionContextForInspectedNode = this._resolveDesiredActiveExecutionContext(true);
225
            contextMenu.appendCheckboxItem(WI.UIString("Auto \u2014 %s").format(this._displayNameForExecutionContext(executionContextForInspectedNode, maxLength)), () => {
226
                this._useExecutionContextOfInspectedNode = true;
227
                this._setActiveExecutionContext(executionContextForInspectedNode);
228
            }, this._useExecutionContextOfInspectedNode);
229
230
            contextMenu.appendSeparator();
231
        }
232
233
        let indent = 0;
234
        let addExecutionContext = (context) => {
235
            if (context.type === WI.ExecutionContext.Type.Internal && !WI.settings.engineeringShowInternalExecutionContexts.value)
236
                return;
237
238
            let additionalIndent = (context.frame && context !== context.frame.executionContextList.pageExecutionContext) || context.type !== WI.ExecutionContext.Type.Normal;
239
240
            // Mimic macOS `-[NSMenuItem setIndentationLevel]`.
241
            contextMenu.appendCheckboxItem("   ".repeat(indent + additionalIndent) + this._displayNameForExecutionContext(context, maxLength), () => {
242
                this._useExecutionContextOfInspectedNode = false;
243
                this._setActiveExecutionContext(context);
244
            }, activeExecutionContext === context);
245
        };
246
247
        let addExecutionContextsForFrame = (frame) => {
248
            let pageExecutionContext = frame.executionContextList.pageExecutionContext;
249
250
            let contexts = frame.executionContextList.contexts.sort((a, b) => {
251
                if (a === pageExecutionContext)
252
                    return -1;
253
                if (b === pageExecutionContext)
254
                    return 1;
255
256
                const executionContextTypeRanking = [
257
                    WI.ExecutionContext.Type.Normal,
258
                    WI.ExecutionContext.Type.User,
259
                    WI.ExecutionContext.Type.Internal,
260
                ];
261
                return executionContextTypeRanking.indexOf(a.type) - executionContextTypeRanking.indexOf(b.type);
262
            });
263
            for (let context of contexts)
264
                addExecutionContext(context);
265
        };
266
267
        let mainFrame = WI.networkManager.mainFrame;
268
        addExecutionContextsForFrame(mainFrame);
269
270
        indent = 1;
271
272
        let otherFrames = WI.networkManager.frames.filter((frame) => frame !== mainFrame && frame.executionContextList.pageExecutionContext);
273
        if (otherFrames.length) {
274
            contextMenu.appendHeader(WI.UIString("Frames"));
275
276
            for (let frame of otherFrames)
277
                addExecutionContextsForFrame(frame);
278
        }
279
280
        let workerTargets = WI.targetManager.workerTargets;
281
        if (workerTargets.length) {
282
            contextMenu.appendHeader(WI.UIString("Workers"));
283
284
            for (let target of workerTargets)
285
                addExecutionContext(target.executionContext);
286
        }
192
    }
287
    }
193
288
194
    _handleMouseDown(event)
289
    _handleMouseDown(event)
Lines 226-453 WI.QuickConsole = class QuickConsole extends WI.View a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js_sec4
226
        }
321
        }
227
    }
322
    }
228
323
229
    _executionContextPathComponentsToDisplay()
324
    _handleConsoleSavedResultAliasSettingChanged()
230
    {
325
    {
231
        // If we are in the debugger the console will use the active call frame, don't show the selector.
326
        this._updateActiveExecutionContextDisplay();
232
        if (WI.debuggerManager.activeCallFrame)
233
            return [];
234
235
        // If there is only the Main ExecutionContext, don't show the selector.
236
        if (!this._otherExecutionContextPathComponents.length)
237
            return [];
238
239
        if (this._shouldAutomaticallySelectExecutionContext)
240
            return [this._automaticExecutionContextPathComponent];
241
242
        if (WI.runtimeManager.activeExecutionContext === WI.mainTarget.executionContext)
243
            return [this._mainExecutionContextPathComponent];
244
245
        return this._otherExecutionContextPathComponents.filter((component) => component.representedObject === WI.runtimeManager.activeExecutionContext);
246
    }
327
    }
247
328
248
    _rebuildExecutionContextPathComponents()
329
    _handleEngineeringShowInternalExecutionContextsSettingChanged(event)
249
    {
330
    {
250
        let components = this._executionContextPathComponentsToDisplay();
331
        if (WI.runtimeManager.activeExecutionContext.type !== WI.ExecutionContext.Type.Internal)
251
        let isEmpty = !components.length;
332
            return;
252
253
        this._executionContextSelectorItem.element.classList.toggle("automatic-execution-context", this._shouldAutomaticallySelectExecutionContext);
254
        this._executionContextSelectorItem.components = components;
255
256
        this._executionContextSelectorItem.hidden = isEmpty;
257
        this._executionContextSelectorDivider.hidden = isEmpty;
258
333
334
        this._useExecutionContextOfInspectedNode = InspectorBackend.hasDomain("DOM");
335
        this._setActiveExecutionContext(this._resolveDesiredActiveExecutionContext());
259
    }
336
    }
260
337
261
    _framePageExecutionContextsChanged(event)
338
    _handleFramePageExecutionContextChanged(event)
262
    {
339
    {
263
        let frame = event.target;
340
        if (this._restoreSelectedExecutionContextForFrame !== event.target)
341
            return;
264
342
265
        let newExecutionContextPathComponent = this._insertExecutionContextPathComponentForFrame(frame);
343
        this._restoreSelectedExecutionContextForFrame = null;
266
344
267
        if (this._restoreSelectedExecutionContextForFrame === frame) {
345
        let {context} = event.data;
268
            this._restoreSelectedExecutionContextForFrame = null;
269
346
270
            this._selectExecutionContext(newExecutionContextPathComponent.representedObject);
347
        this._useExecutionContextOfInspectedNode = false;
271
        }
348
        this._setActiveExecutionContext(context);
272
    }
349
    }
273
350
274
    _frameExecutionContextsCleared(event)
351
    _handleFrameExecutionContextsCleared(event)
275
    {
352
    {
276
        let frame = event.target;
353
        let {committingProvisionalLoad, contexts} = event.data;
354
355
        let hasActiveExecutionContext = contexts.some((context) => context === WI.runtimeManager.activeExecutionContext);
356
        if (!hasActiveExecutionContext)
357
            return;
277
358
278
        // If this frame is navigating and it is selected in the UI we want to reselect its new item after navigation.
359
        // If this frame is navigating and it is selected in the UI we want to reselect its new item after navigation.
279
        if (event.data.committingProvisionalLoad && !this._restoreSelectedExecutionContextForFrame) {
360
        if (committingProvisionalLoad && !this._restoreSelectedExecutionContextForFrame) {
280
            let executionContextPathComponent = this._frameToPathComponent.get(frame);
361
            this._restoreSelectedExecutionContextForFrame = event.target;
281
            if (executionContextPathComponent && executionContextPathComponent.representedObject === WI.runtimeManager.activeExecutionContext) {
282
                this._restoreSelectedExecutionContextForFrame = frame;
283
                // As a fail safe, if the frame never gets an execution context, clear the restore value.
284
                setTimeout(() => {
285
                    this._restoreSelectedExecutionContextForFrame = false;
286
                }, 10);
287
            }
288
        }
289
362
290
        this._removeExecutionContextPathComponentForFrame(frame);
363
            // As a fail safe, if the frame never gets an execution context, clear the restore value.
291
    }
364
            setTimeout(() => {
292
365
                this._restoreSelectedExecutionContextForFrame = null;
293
    _activeExecutionContextChanged(event)
366
            }, 10);
294
    {
295
        this._rebuildExecutionContextPathComponents();
296
    }
297
298
    _createExecutionContextPathComponent(executionContext, preferredName)
299
    {
300
        console.assert(!executionContext || executionContext instanceof WI.ExecutionContext);
301
302
        let pathComponent = new WI.HierarchicalPathComponent(preferredName || executionContext.name, "execution-context", executionContext, true, true);
303
        pathComponent.addEventListener(WI.HierarchicalPathComponent.Event.SiblingWasSelected, this._pathComponentSelected, this);
304
        pathComponent.addEventListener(WI.HierarchicalPathComponent.Event.Clicked, this._pathComponentClicked, this);
305
        pathComponent.truncatedDisplayNameLength = 50;
306
        return pathComponent;
307
    }
308
309
    _compareExecutionContextPathComponents(a, b)
310
    {
311
        let aExecutionContext = a.representedObject;
312
        let bExecutionContext = b.representedObject;
313
314
        // "Targets" (workers) at the top.
315
        let aNonMainTarget = aExecutionContext.target !== WI.mainTarget;
316
        let bNonMainTarget = bExecutionContext.target !== WI.mainTarget;
317
        if (aNonMainTarget && !bNonMainTarget)
318
            return -1;
319
        if (bNonMainTarget && !aNonMainTarget)
320
            return 1;
321
        if (aNonMainTarget && bNonMainTarget)
322
            return a.displayName.extendedLocaleCompare(b.displayName);
323
324
        // "Main Frame" follows.
325
        if (aExecutionContext === WI.mainTarget.executionContext)
326
            return -1;
327
        if (bExecutionContext === WI.mainTarget.executionContext)
328
            return 1;
329
330
        // Only Frame contexts remain.
331
        console.assert(aExecutionContext.frame);
332
        console.assert(bExecutionContext.frame);
333
334
        // Frames with a name above frames without a name.
335
        if (aExecutionContext.frame.name && !bExecutionContext.frame.name)
336
            return -1;
337
        if (!aExecutionContext.frame.name && bExecutionContext.frame.name)
338
            return 1;
339
340
        return a.displayName.extendedLocaleCompare(b.displayName);
341
    }
342
343
    _insertOtherExecutionContextPathComponent(executionContextPathComponent)
344
    {
345
        let index = insertionIndexForObjectInListSortedByFunction(executionContextPathComponent, this._otherExecutionContextPathComponents, this._compareExecutionContextPathComponents);
346
347
        let prev = index > 0 ? this._otherExecutionContextPathComponents[index - 1] : this._mainExecutionContextPathComponent;
348
        let next = this._otherExecutionContextPathComponents[index] || null;
349
        if (prev) {
350
            prev.nextSibling = executionContextPathComponent;
351
            executionContextPathComponent.previousSibling = prev;
352
        }
353
        if (next) {
354
            next.previousSibling = executionContextPathComponent;
355
            executionContextPathComponent.nextSibling = next;
356
        }
357
358
        this._otherExecutionContextPathComponents.splice(index, 0, executionContextPathComponent);
359
360
        this._rebuildExecutionContextPathComponents();
361
    }
362
363
    _removeOtherExecutionContextPathComponent(executionContextPathComponent)
364
    {
365
        executionContextPathComponent.removeEventListener(WI.HierarchicalPathComponent.Event.SiblingWasSelected, this._pathComponentSelected, this);
366
        executionContextPathComponent.removeEventListener(WI.HierarchicalPathComponent.Event.Clicked, this._pathComponentClicked, this);
367
368
        let prev = executionContextPathComponent.previousSibling;
369
        let next = executionContextPathComponent.nextSibling;
370
        if (prev)
371
            prev.nextSibling = next;
372
        if (next)
373
            next.previousSibling = prev;
374
375
        this._otherExecutionContextPathComponents.remove(executionContextPathComponent, true);
376
377
        this._rebuildExecutionContextPathComponents();
378
    }
379
380
    _insertExecutionContextPathComponentForFrame(frame)
381
    {
382
        if (frame.isMainFrame())
383
            return this._mainExecutionContextPathComponent;
384
385
        let executionContextPathComponent = this._createExecutionContextPathComponent(frame.pageExecutionContext, this._preferredNameForFrame(frame));
386
        this._insertOtherExecutionContextPathComponent(executionContextPathComponent);
387
        this._frameToPathComponent.set(frame, executionContextPathComponent);
388
        return executionContextPathComponent;
389
    }
390
391
    _removeExecutionContextPathComponentForFrame(frame)
392
    {
393
        if (frame.isMainFrame()) {
394
            this._shouldAutomaticallySelectExecutionContext = true;
395
            this._initializeMainExecutionContextPathComponent();
396
            return;
367
            return;
397
        }
368
        }
398
369
399
        let executionContextPathComponent = this._frameToPathComponent.take(frame);
370
        this._useExecutionContextOfInspectedNode = InspectorBackend.hasDomain("DOM");
400
        this._removeOtherExecutionContextPathComponent(executionContextPathComponent);
371
        this._setActiveExecutionContext(this._resolveDesiredActiveExecutionContext());
401
    }
372
    }
402
373
403
    _targetAdded(event)
374
    _handleDebuggerActiveCallFrameDidChange(event)
404
    {
375
    {
405
        let target = event.data.target;
376
        this._updateActiveExecutionContextDisplay();
406
        if (target.type !== WI.TargetType.Worker)
377
    }
378
379
    _handleActiveExecutionContextChanged(event)
380
    {
381
        this._updateActiveExecutionContextDisplay();
382
    }
383
384
    _handleTransitionPageTarget()
385
    {
386
        this._updateActiveExecutionContextDisplay();
387
    }
388
389
    _handleTargetRemoved(event)
390
    {
391
        let {target} = event.data;
392
        if (target !== WI.runtimeManager.activeExecutionContext)
407
            return;
393
            return;
408
394
409
        console.assert(target.type === WI.TargetType.Worker);
395
        this._useExecutionContextOfInspectedNode = InspectorBackend.hasDomain("DOM");
410
        let preferredName = WI.UIString("Worker \u2014 %s").format(target.displayName);
396
        this._setActiveExecutionContext(this._resolveDesiredActiveExecutionContext());
411
        let executionContextPathComponent = this._createExecutionContextPathComponent(target.executionContext, preferredName);
412
413
        this._targetToPathComponent.set(target, executionContextPathComponent);
414
        this._insertOtherExecutionContextPathComponent(executionContextPathComponent);
415
    }
397
    }
416
398
417
    _targetRemoved(event)
399
    _handleInspectedNodeChanged(event)
418
    {
400
    {
419
        let target = event.data.target;
401
        if (!this._useExecutionContextOfInspectedNode)
420
        if (target.type !== WI.TargetType.Worker)
421
            return;
402
            return;
422
403
423
        let executionContextPathComponent = this._targetToPathComponent.take(target);
404
        this._setActiveExecutionContext(this._resolveDesiredActiveExecutionContext());
424
425
        if (WI.runtimeManager.activeExecutionContext === executionContextPathComponent.representedObject) {
426
            this._shouldAutomaticallySelectExecutionContext = true;
427
            this._selectExecutionContext();
428
        }
429
430
        this._removeOtherExecutionContextPathComponent(executionContextPathComponent);
431
    }
432
433
    _pathComponentSelected(event)
434
    {
435
        this._shouldAutomaticallySelectExecutionContext = event.data.pathComponent === this._automaticExecutionContextPathComponent;
436
437
        // Only manually rebuild the execution context path components if the newly selected
438
        // execution context matches the previously selected one.
439
        if (!this._selectExecutionContext(event.data.pathComponent.representedObject))
440
            this._rebuildExecutionContextPathComponents();
441
    }
442
443
    _pathComponentClicked(event)
444
    {
445
        this.prompt.focus();
446
    }
447
448
    _debuggerActiveCallFrameDidChange(event)
449
    {
450
        this._rebuildExecutionContextPathComponents();
451
    }
405
    }
452
406
453
    _toggleOrFocus(event)
407
    _toggleOrFocus(event)
Lines 468-476 WI.QuickConsole = class QuickConsole extends WI.View a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js_sec5
468
    {
422
    {
469
        this.element.classList.toggle("showing-log", WI.isShowingConsoleTab() || WI.isShowingSplitConsole());
423
        this.element.classList.toggle("showing-log", WI.isShowingConsoleTab() || WI.isShowingSplitConsole());
470
    }
424
    }
471
472
    _handleInspectedNodeChanged(event)
473
    {
474
        this._selectExecutionContext(WI.runtimeManager.activeExecutionContext);
475
    }
476
};
425
};
- a/Source/WebInspectorUI/UserInterface/Views/QuickConsoleNavigationBar.js -38 lines
Lines 1-38 a/Source/WebInspectorUI/UserInterface/Views/QuickConsoleNavigationBar.js_sec1
1
/*
2
 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
WI.QuickConsoleNavigationBar = class QuickConsoleNavigationBar extends WI.NavigationBar
27
{
28
    get sizesToFit()
29
    {
30
        return true;
31
    }
32
33
    addNavigationItem(navigationItem)
34
    {
35
        // Add new navigation items to the left.
36
        return this.insertNavigationItem(navigationItem, 0);
37
    }
38
};
- a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js +3 lines
Lines 405-411 WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js_sec1
405
        let elementsGroup = engineeringSettingsView.addGroup(WI.unlocalizedString("Elements:"));
405
        let elementsGroup = engineeringSettingsView.addGroup(WI.unlocalizedString("Elements:"));
406
        elementsGroup.addSetting(WI.settings.engineeringAllowEditingUserAgentShadowTrees, WI.unlocalizedString("Allow editing UserAgent shadow trees"));
406
        elementsGroup.addSetting(WI.settings.engineeringAllowEditingUserAgentShadowTrees, WI.unlocalizedString("Allow editing UserAgent shadow trees"));
407
407
408
        engineeringSettingsView.addSeparator();
409
408
        let debuggingGroup = engineeringSettingsView.addGroup(WI.unlocalizedString("Debugging:"));
410
        let debuggingGroup = engineeringSettingsView.addGroup(WI.unlocalizedString("Debugging:"));
411
        debuggingGroup.addSetting(WI.settings.engineeringShowInternalExecutionContexts, WI.unlocalizedString("Show WebKit-internal execution contexts"));
409
        debuggingGroup.addSetting(WI.settings.engineeringShowInternalScripts, WI.unlocalizedString("Show WebKit-internal scripts"));
412
        debuggingGroup.addSetting(WI.settings.engineeringShowInternalScripts, WI.unlocalizedString("Show WebKit-internal scripts"));
410
        debuggingGroup.addSetting(WI.settings.engineeringPauseForInternalScripts, WI.unlocalizedString("Pause in WebKit-internal scripts"));
413
        debuggingGroup.addSetting(WI.settings.engineeringPauseForInternalScripts, WI.unlocalizedString("Pause in WebKit-internal scripts"));
411
414
- a/Source/WebInspectorUI/UserInterface/Views/SizesToFitNavigationBar.js +32 lines
Line 0 a/Source/WebInspectorUI/UserInterface/Views/SizesToFitNavigationBar.js_sec1
1
/*
2
 * Copyright (C) 2020 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
WI.SizesToFitNavigationBar = class SizesToFitNavigationBar extends WI.NavigationBar
27
{
28
    get sizesToFit()
29
    {
30
        return true;
31
    }
32
};
- a/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitScriptWorld.cpp -2 / +2 lines
Lines 152-158 WebKitScriptWorld* webkit_script_world_get_default(void) a/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitScriptWorld.cpp_sec1
152
 */
152
 */
153
WebKitScriptWorld* webkit_script_world_new(void)
153
WebKitScriptWorld* webkit_script_world_new(void)
154
{
154
{
155
    return webkitScriptWorldCreate(InjectedBundleScriptWorld::create());
155
    return webkitScriptWorldCreate(InjectedBundleScriptWorld::create(InjectedBundleScriptWorld::Type::User));
156
}
156
}
157
157
158
/**
158
/**
Lines 173-179 WebKitScriptWorld* webkit_script_world_new_with_name(const char* name) a/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitScriptWorld.cpp_sec2
173
{
173
{
174
    g_return_val_if_fail(name, nullptr);
174
    g_return_val_if_fail(name, nullptr);
175
175
176
    return webkitScriptWorldCreate(InjectedBundleScriptWorld::create(String::fromUTF8(name)));
176
    return webkitScriptWorldCreate(InjectedBundleScriptWorld::create(String::fromUTF8(name), InjectedBundleScriptWorld::Type::User));
177
}
177
}
178
178
179
/**
179
/**
- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp -4 / +4 lines
Lines 50-63 static String uniqueWorldName() a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp_sec1
50
    return makeString("UniqueWorld_", uniqueWorldNameNumber++);
50
    return makeString("UniqueWorld_", uniqueWorldNameNumber++);
51
}
51
}
52
52
53
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create()
53
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create(Type type)
54
{
54
{
55
    return adoptRef(*new InjectedBundleScriptWorld(ScriptController::createWorld(), uniqueWorldName()));
55
    return InjectedBundleScriptWorld::create(uniqueWorldName(), type);
56
}
56
}
57
57
58
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create(const String& name)
58
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create(const String& name, Type type)
59
{
59
{
60
    return adoptRef(*new InjectedBundleScriptWorld(ScriptController::createWorld(), name));
60
    return adoptRef(*new InjectedBundleScriptWorld(ScriptController::createWorld(name, type == Type::User ? ScriptController::WorldType::User : ScriptController::WorldType::Internal), name));
61
}
61
}
62
62
63
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::getOrCreate(DOMWrapperWorld& world)
63
Ref<InjectedBundleScriptWorld> InjectedBundleScriptWorld::getOrCreate(DOMWrapperWorld& world)
- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h -2 / +3 lines
Lines 39-46 namespace WebKit { a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h_sec1
39
39
40
class InjectedBundleScriptWorld : public API::ObjectImpl<API::Object::Type::BundleScriptWorld> {
40
class InjectedBundleScriptWorld : public API::ObjectImpl<API::Object::Type::BundleScriptWorld> {
41
public:
41
public:
42
    static Ref<InjectedBundleScriptWorld> create();
42
    enum class Type { User, Internal };
43
    static Ref<InjectedBundleScriptWorld> create(const String&);
43
    static Ref<InjectedBundleScriptWorld> create(Type = Type::Internal);
44
    static Ref<InjectedBundleScriptWorld> create(const String& name, Type = Type::Internal);
44
    static Ref<InjectedBundleScriptWorld> getOrCreate(WebCore::DOMWrapperWorld&);
45
    static Ref<InjectedBundleScriptWorld> getOrCreate(WebCore::DOMWrapperWorld&);
45
    static InjectedBundleScriptWorld* find(const String&);
46
    static InjectedBundleScriptWorld* find(const String&);
46
    static InjectedBundleScriptWorld& normalWorld();
47
    static InjectedBundleScriptWorld& normalWorld();
- a/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp -1 / +1 lines
Lines 115-121 void WebUserContentController::addUserContentWorld(const std::pair<ContentWorldI a/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp_sec1
115
        if (auto* existingWorld = InjectedBundleScriptWorld::find(world.second))
115
        if (auto* existingWorld = InjectedBundleScriptWorld::find(world.second))
116
            return std::make_pair(Ref<InjectedBundleScriptWorld>(*existingWorld), 1);
116
            return std::make_pair(Ref<InjectedBundleScriptWorld>(*existingWorld), 1);
117
#endif
117
#endif
118
        return std::make_pair(InjectedBundleScriptWorld::create(world.second), 1);
118
        return std::make_pair(InjectedBundleScriptWorld::create(world.second, InjectedBundleScriptWorld::Type::User), 1);
119
    });
119
    });
120
}
120
}
121
121
- a/Source/WebKitLegacy/mac/WebView/WebScriptWorld.mm -1 / +1 lines
Lines 66-72 - (id)initWithWorld:(Ref<WebCore::DOMWrapperWorld>&&)world a/Source/WebKitLegacy/mac/WebView/WebScriptWorld.mm_sec1
66
66
67
- (id)init
67
- (id)init
68
{
68
{
69
    return [self initWithWorld:WebCore::ScriptController::createWorld()];
69
    return [self initWithWorld:WebCore::ScriptController::createWorld("WebScriptWorld"_s, WebCore::ScriptController::WorldType::User)];
70
}
70
}
71
71
72
- (void)unregisterWorld
72
- (void)unregisterWorld
- a/Source/WebKitLegacy/win/WebScriptWorld.cpp -1 / +1 lines
Lines 67-73 WebScriptWorld* WebScriptWorld::standardWorld() a/Source/WebKitLegacy/win/WebScriptWorld.cpp_sec1
67
67
68
COMPtr<WebScriptWorld> WebScriptWorld::createInstance()
68
COMPtr<WebScriptWorld> WebScriptWorld::createInstance()
69
{
69
{
70
    return createInstance(ScriptController::createWorld());
70
    return createInstance(ScriptController::createWorld("WebScriptWorld"_s, WebCore::ScriptController::WorldType::User));
71
}
71
}
72
72
73
COMPtr<WebScriptWorld> WebScriptWorld::createInstance(RefPtr<DOMWrapperWorld>&& world)
73
COMPtr<WebScriptWorld> WebScriptWorld::createInstance(RefPtr<DOMWrapperWorld>&& world)
- a/LayoutTests/ChangeLog +22 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2020-02-27  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: unable to evaluate in the isolated world of content scripts injected by safari app extensions
4
        https://bugs.webkit.org/show_bug.cgi?id=206110
5
        <rdar://problem/16945643>
6
7
        Reviewed by Timothy Hatcher, Joseph Pecoraro, and Brian Burg.
8
9
        In addition to evaluating in subframe execution contexts, add the ability for Web Inspector
10
        to evaluate in non-normal isolated worlds.
11
12
        * inspector/runtime/executionContextCreated-isolated-world.html: Added.
13
        * inspector/runtime/executionContextCreated-isolated-world-expected.txt: Added.
14
15
        * inspector/runtime/change-execution-context-identifier.html:
16
        * inspector/runtime/change-execution-context-identifier-expected.txt:
17
        Don't expect the active execution context to change when the owner frame is removed, as that
18
        is now handled by the UI (`WI.QuickConsole`) instead of the `WI.RuntimeManager`.
19
20
        * inspector/runtime/executionContextCreated-onEnable.html:
21
        Ignore internal worlds.
22
1
2020-01-26  Said Abou-Hallawa  <said@apple.com>
23
2020-01-26  Said Abou-Hallawa  <said@apple.com>
2
24
3
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
25
        Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
- a/LayoutTests/inspector/runtime/change-execution-context-identifier-expected.txt -1 / +1 lines
Lines 25-29 PASS: The passphrase should match the phrase defined in the main frame. a/LayoutTests/inspector/runtime/change-execution-context-identifier-expected.txt_sec1
25
-- Running test case: ScriptExecutionContextRemoveSubframe
25
-- Running test case: ScriptExecutionContextRemoveSubframe
26
PASS: The test page should only have one sub-frame.
26
PASS: The test page should only have one sub-frame.
27
PASS: The test page should now have no sub-frames.
27
PASS: The test page should now have no sub-frames.
28
PASS: When a selected non-top-level execution context is removed, the active execution context should revert to the main frame context.
28
PASS: When a selected non-top-level execution context is removed, the active execution context should not change, as that is handled by the UI.
29
29
- a/LayoutTests/inspector/runtime/change-execution-context-identifier.html -1 / +2 lines
Lines 85-90 function test() a/LayoutTests/inspector/runtime/change-execution-context-identifier.html_sec1
85
85
86
            // Set the execution context to the subframe so we can switch away from it when the frame is detached.
86
            // Set the execution context to the subframe so we can switch away from it when the frame is detached.
87
            WI.runtimeManager.activeExecutionContext = subframes[0].pageExecutionContext;
87
            WI.runtimeManager.activeExecutionContext = subframes[0].pageExecutionContext;
88
            let activeExecutionContextId = WI.runtimeManager.activeExecutionContext.id;
88
89
89
            // Force-override the contextId, otherwise we won't be able to access the iframe's DOM element when evaluating in the iframe execution context.
90
            // Force-override the contextId, otherwise we won't be able to access the iframe's DOM element when evaluating in the iframe execution context.
90
            let expression = `document.getElementById("subframe").remove();`;
91
            let expression = `document.getElementById("subframe").remove();`;
Lines 92-98 function test() a/LayoutTests/inspector/runtime/change-execution-context-identifier.html_sec2
92
            let contextId = WI.RuntimeManager.TopLevelExecutionContextIdentifier;
93
            let contextId = WI.RuntimeManager.TopLevelExecutionContextIdentifier;
93
            RuntimeAgent.evaluate.invoke({expression, objectGroup, contextId}, () => {
94
            RuntimeAgent.evaluate.invoke({expression, objectGroup, contextId}, () => {
94
                InspectorTest.expectEqual(WI.networkManager.frames.length, 1, "The test page should now have no sub-frames.");
95
                InspectorTest.expectEqual(WI.networkManager.frames.length, 1, "The test page should now have no sub-frames.");
95
                InspectorTest.expectEqual(WI.runtimeManager.activeExecutionContext.id, WI.RuntimeManager.TopLevelExecutionContextIdentifier, "When a selected non-top-level execution context is removed, the active execution context should revert to the main frame context.");
96
                InspectorTest.expectEqual(WI.runtimeManager.activeExecutionContext.id, activeExecutionContextId, "When a selected non-top-level execution context is removed, the active execution context should not change, as that is handled by the UI.");
96
                resolve();
97
                resolve();
97
            });
98
            });
98
        }
99
        }
- a/LayoutTests/inspector/runtime/executionContextCreated-isolated-world-expected.txt +9 lines
Line 0 a/LayoutTests/inspector/runtime/executionContextCreated-isolated-world-expected.txt_sec1
1
2
Test that exactly one Runtime.executionContextCreated event is fired for each existing context when Runtime.enable is called.
3
4
5
== Running test suite: Runtime.executionContextCreated.IsolatedWorld
6
-- Running test case: Runtime.executionContextCreated.IsolatedWorld.Internal
7
PASS: Received event for internal isolated world.
8
PASS: Execution context should be internal.
9
- a/LayoutTests/inspector/runtime/executionContextCreated-isolated-world.html +63 lines
Line 0 a/LayoutTests/inspector/runtime/executionContextCreated-isolated-world.html_sec1
1
<html>
2
<head>
3
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
4
<script src="../../http/tests/inspector/resources/stable-id-map.js"></script>
5
<script>
6
function createIsolatedWorld() {
7
    const name = "InspectorTestInternalIsolatedWorld";
8
    function source() { return 42; }
9
10
    if (window.internals)
11
        window.internals.evaluateInWorldIgnoringException(name, source.toString());
12
}
13
14
function test()
15
{
16
    ProtocolTest.debug();
17
18
    let suite = ProtocolTest.createAsyncSuite("Runtime.executionContextCreated.IsolatedWorld");
19
20
    suite.addTestCase({
21
        name: "Runtime.executionContextCreated.IsolatedWorld.Internal",
22
        description: "Test that Runtime.executionContextCreated events are dispatched for internal isolated worlds.",
23
        async test() {
24
            let completion = new WI.WrappedPromise;
25
26
            let listener = InspectorProtocol.addEventListener("Runtime.executionContextCreated", (messageObject) => {
27
                let {id, name, type} = messageObject.params.context;
28
                if (name !== "InspectorTestInternalIsolatedWorld")
29
                    return;
30
31
                InspectorProtocol.removeEventListener("Runtime.executionContextCreated", listener);
32
33
                ProtocolTest.pass("Received event for internal isolated world.");
34
                ProtocolTest.expectEqual(type, "internal", "Execution context should be internal.");
35
36
                completion.resolve();
37
            });
38
39
            await Promise.all([
40
                InspectorProtocol.awaitCommand({method: "Page.enable"}),
41
                InspectorProtocol.awaitCommand({method: "Runtime.enable"}),
42
            ]);
43
44
            await InspectorProtocol.awaitCommand({
45
                method: "Runtime.evaluate",
46
                params: {
47
                    expression: `createIsolatedWorld()`,
48
                },
49
            });
50
51
            await completion.promise;
52
        },
53
    });
54
55
    suite.runTestCasesAndFinish();
56
}
57
</script>
58
</head>
59
<body>
60
<iframe id="subframe" src="resources/change-execution-context-identifier-subframe.html" onload="runTest()"></iframe>
61
<p>Test that exactly one Runtime.executionContextCreated event is fired for each existing context when Runtime.enable is called.</p>
62
</body>
63
</html>
- a/LayoutTests/inspector/runtime/executionContextCreated-onEnable.html -2 / +5 lines
Lines 16-23 function test() a/LayoutTests/inspector/runtime/executionContextCreated-onEnable.html_sec1
16
            let contextCount = 0;
16
            let contextCount = 0;
17
17
18
            InspectorProtocol.addEventListener("Runtime.executionContextCreated", (messageObject) => {
18
            InspectorProtocol.addEventListener("Runtime.executionContextCreated", (messageObject) => {
19
                let {id, isPageContext, frameId} = messageObject.params.context;
19
                let {id, type, frameId} = messageObject.params.context;
20
                ProtocolTest.log(`Execution context created: id=${contextIdMap.get(id)} frameId=${frameIdMap.get(frameId)} isPageContext=${isPageContext}`)
20
                if (type === "internal")
21
                    return;
22
23
                ProtocolTest.log(`Execution context created: id=${contextIdMap.get(id)} frameId=${frameIdMap.get(frameId)} isPageContext=${type === "normal"}`)
21
                ++contextCount;
24
                ++contextCount;
22
            });
25
            });
23
26

Return to Bug 206110