Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: rework frontend agent construction to allow commands/e…
…vents to be controlled by the related target's type https://bugs.webkit.org/show_bug.cgi?id=200384 <rdar://problem/53850352> Reviewed by Joseph Pecoraro. Source/JavaScriptCore: * inspector/scripts/codegen/generate_js_backend_commands.py: (JSBackendCommandsGenerator.generate_domain): (JSBackendCommandsGenerator.generate_domain.generate_parameter_object): * inspector/scripts/codegen/models.py: (validate_target_types): Added. (Protocol.parse_domain): (Protocol.parse_command): (Protocol.parse_event): (Domain.__init__): (Domains): (Command.__init__): (Event.__init__): * inspector/protocol/ApplicationCache.json: * inspector/protocol/Audit.json: * inspector/protocol/CPUProfiler.json: * inspector/protocol/CSS.json: * inspector/protocol/Canvas.json: * inspector/protocol/Console.json: * inspector/protocol/DOM.json: * inspector/protocol/DOMDebugger.json: * inspector/protocol/DOMStorage.json: * inspector/protocol/Database.json: * inspector/protocol/Debugger.json: * inspector/protocol/Heap.json: * inspector/protocol/IndexedDB.json: * inspector/protocol/Inspector.json: * inspector/protocol/LayerTree.json: * inspector/protocol/Memory.json: * inspector/protocol/Network.json: * inspector/protocol/Page.json: * inspector/protocol/Recording.json: * inspector/protocol/Runtime.json: * inspector/protocol/ScriptProfiler.json: * inspector/protocol/Security.json: * inspector/protocol/ServiceWorker.json: * inspector/protocol/Target.json: * inspector/protocol/Timeline.json: * inspector/protocol/Worker.json: Add `debuggableTypes` and `targetTypes` arrays to domains/commands/events that are used when generating InspectorBackendCommands.js for more accurate compatibility checks. * inspector/InspectorTarget.h: * inspector/agents/InspectorTargetAgent.h: * inspector/agents/InspectorTargetAgent.cpp: (Inspector::targetTypeToProtocolType): (Inspector::InspectorTargetAgent::exists): Deleted. Remove `Target.exists` now that the frontend can do proper feature checking. * inspector/remote/RemoteControllableTarget.h: * inspector/remote/RemoteInspectionTarget.h: * inspector/remote/RemoteInspectorConstants.h: * inspector/remote/cocoa/RemoteInspectorCocoa.mm: (Inspector::RemoteInspector::listingForInspectionTarget const): * inspector/remote/glib/RemoteInspectorGlib.cpp: (Inspector::RemoteInspector::listingForInspectionTarget const): * inspector/remote/socket/RemoteInspectorSocket.cpp: (Inspector::RemoteInspector::listingForInspectionTarget const): Split the `Web` debuggable type into `Page` (WebCore::Page) and `WebPage` (WebKit::WebPageProxy). * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/command-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/domain-availability.json: Removed. * inspector/scripts/tests/generic/domain-debuggableTypes.json: Added. * inspector/scripts/tests/generic/domain-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/domain-targetTypes.json: Added. * inspector/scripts/tests/generic/event-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/expected/command-targetType-matching-domain-debuggableType.json-result: Added. * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/generic/expected/domain-debuggableTypes.json-result: Added. * inspector/scripts/tests/generic/expected/domain-targetType-matching-domain-debuggableType.json-result: Added. * inspector/scripts/tests/generic/expected/domain-targetTypes.json-result: Added. * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result: * inspector/scripts/tests/generic/expected/enum-values.json-result: * inspector/scripts/tests/generic/expected/event-targetType-matching-domain-debuggableType.json-result: Added. * inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result: * inspector/scripts/tests/generic/expected/fail-on-command-targetType-matching-domain-debuggableType.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-command-targetTypes-type.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-command-targetTypes-value.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-domain-availability-type.json-error: Removed. * inspector/scripts/tests/generic/expected/fail-on-domain-availability-value.json-error: Removed. * inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error: Removed. * inspector/scripts/tests/generic/expected/fail-on-domain-debuggableTypes-type.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-domain-debuggableTypes-value.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-domain-targetType-matching-domain-debuggableType.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-domain-targetTypes-type.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-domain-targetTypes-value.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-event-targetType-matching-domain-debuggableType.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-event-targetTypes-type.json-error: Added. * inspector/scripts/tests/generic/expected/fail-on-event-targetTypes-value.json-error: Added. * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result: * inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result: * inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result: * inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result: * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result: * inspector/scripts/tests/generic/expected/version.json-result: * inspector/scripts/tests/generic/fail-on-command-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/fail-on-command-targetTypes-type.json: Added. * inspector/scripts/tests/generic/fail-on-command-targetTypes-value.json: Added. * inspector/scripts/tests/generic/fail-on-domain-debuggableTypes-type.json: Added. * inspector/scripts/tests/generic/fail-on-domain-debuggableTypes-value.json: Added. * inspector/scripts/tests/generic/fail-on-domain-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/fail-on-domain-targetTypes-type.json: Added. * inspector/scripts/tests/generic/fail-on-domain-targetTypes-value.json: Added. * inspector/scripts/tests/generic/fail-on-event-targetType-matching-domain-debuggableType.json: Added. * inspector/scripts/tests/generic/fail-on-event-targetTypes-type.json: Added. * inspector/scripts/tests/generic/fail-on-event-targetTypes-value.json: Added. * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result: Update test results, as well as added new tests for `debuggableTypes` and `targetTypes`. Source/WebCore: * inspector/InspectorFrontendClient.h: (WebCore::InspectorFrontendClient::backendCommandsURL): Deleted. (WebCore::InspectorFrontendClient::debuggableType): Deleted. * inspector/InspectorFrontendClientLocal.h: * page/PageDebuggable.h: (WebCore::PageDebuggable::type const): * testing/Internals.cpp: (WebCore::InspectorStubFrontend::debuggableType const): Added. Split the `Web` debuggable type into `Page` (WebCore::Page) and `WebPage` (WebKit::WebPageProxy). Source/WebInspectorUI: `InspectorBackend.domains.${domain}` isn't a truly valid way to feature check, as it indicates what's supported by the WebKit framework underlying whatever's currently being inspected, not what the current inspection target supports. As an example, inspecting an iOS `JSContext` will still show `InspectorBackend.domains.DOM` as the `DOMAgent` is supported by WebKit, even though `JSContext`s have no concept of the DOM. In this example, however, `window.DOMAgent` would NOT exist, as the `availability` check for the `DOM` domain wouldn't pass, meaning that the agent never gets connected. In order to do proper feature checking, `InspectorBackend.domains` needs to be accurate depending on the debuggable type. Furthermore, each target underneath that debuggable needs to be able to "choose" what commands/events are supported based on that target's type. This patch modifies how InspectorBackendCommands.js ties into `InspectorBackend`. Rather than directly creating an `InspectorBackend.Agent` for each domain, we now create more of a "blueprint" of the domain, and wait to actually create an `InspectorBackend.Agent` until we have a `WI.Target` (and therefore an `InspectorBackend.Connection`). Each "concept" of the protocol now directly maps to an object. - InspectorBackend.Domain - InspectorBackend.Command - InspectorBackend.Event - InspectorBackend.Dispatcher When a `WI.Target` is created, it gets the list of `InspectorBackend.Domain` that support that `WI.Target`'s type (specified in the protocol JSON files) and generates an `InspectorBackend.Agent` for each, which in turn generates an `InspectorBackend.Callable` for each supported `InspectorBackend.Command` and instantiates `InspectorBackend.Dispatcher`. Activating a `InspectorBackend.Domain` means it's visible for `InspectorBackend` feature checking. This must be done this way for older ITML backends that will still appear as "JSContext" targets and therefore go through the "extra domains" path. Ideally, the process of registering a domain should be enough to activate it. <https://webkit.org/b/201150> Feature checking can now only be done via `hasDomain`, `hasCommand`, and `hasEvent` on `InspectorBackend` or a specific `WI.Target`, and there are different implications for each: - `InspectorBackend.hasDomain(DOM)` asks whether the `DOM` domain is supported by the current debuggable, but says nothing about whether any `WI.Target` support `DOM`. - `target.hasDomain("DOM")` asks whether the given `target` supports `DOM`, which is limited by `InspectorBackend.hasDomain("DOM")`. Now that `InspectorBackend.Agent` is only created by a `WI.Target`, it's no longer valid to write `window.DOMAgent`, as there is no "global" agent. All protocol logic _must_ go through a `WI.Target`. <https://webkit.org/b/201149> Debuggable Types: - JavaScript (JSC::JSGlobalObject) - Page (WebCore::Page) - ServiceWorker (WebCore::ServiceWorkerThreadProxy) - WebPage (WebKit::WebPageProxy) Target Types: - JavaScript (direct connection) - Page (multi-target connection to any Worker) - ServiceWorker (direct connection) - WebPage (multi-target connection to 1+ Page) - Worker (direct connection, only available for Page debuggables) * UserInterface/Base/DebuggableType.js: * UserInterface/Base/TargetType.js: Copied from Source/WebInspectorUI/UserInterface/Base/DebuggableType.js. * UserInterface/Protocol/Connection.js: * UserInterface/Protocol/InspectorBackend.js: * UserInterface/Protocol/ApplicationCacheObserver.js: * UserInterface/Protocol/CPUProfilerObserver.js: * UserInterface/Protocol/CSSObserver.js: * UserInterface/Protocol/CanvasObserver.js: * UserInterface/Protocol/ConsoleObserver.js: * UserInterface/Protocol/DOMObserver.js: * UserInterface/Protocol/DOMStorageObserver.js: * UserInterface/Protocol/DatabaseObserver.js: * UserInterface/Protocol/DebuggerObserver.js: * UserInterface/Protocol/HeapObserver.js: * UserInterface/Protocol/InspectorObserver.js: * UserInterface/Protocol/LayerTreeObserver.js: * UserInterface/Protocol/MemoryObserver.js: * UserInterface/Protocol/NetworkObserver.js: * UserInterface/Protocol/PageObserver.js: * UserInterface/Protocol/RuntimeObserver.js: * UserInterface/Protocol/ScriptProfilerObserver.js: * UserInterface/Protocol/TargetObserver.js: * UserInterface/Protocol/TimelineObserver.js: * UserInterface/Protocol/WorkerObserver.js: All observers now extend from `InspectorBackend.Dispatcher` and have a separate instance for each `InspectorBackend.Agent`, each having their own `_target`. * UserInterface/Protocol/Target.js: * UserInterface/Protocol/DirectBackendTarget.js: * UserInterface/Protocol/JavaScriptContextTarget.js: Removed. * UserInterface/Protocol/MultiplexingBackendTarget.js: * UserInterface/Protocol/PageTarget.js: * UserInterface/Protocol/WorkerTarget.js: Agents are now created per-target instead of copied from the "global" list. This means that agents can have a different set of commands/events depending on the associated target. * UserInterface/Base/Main.js: * UserInterface/Base/Utilities.js: * UserInterface/Controllers/AppController.js: * UserInterface/Controllers/AppControllerBase.js: * UserInterface/Controllers/ApplicationCacheManager.js: * UserInterface/Controllers/AuditManager.js: * UserInterface/Controllers/BreakpointPopoverController.js: * UserInterface/Controllers/CSSManager.js: * UserInterface/Controllers/CanvasManager.js: * UserInterface/Controllers/ConsoleManager.js: * UserInterface/Controllers/DOMDebuggerManager.js: * UserInterface/Controllers/DOMManager.js: * UserInterface/Controllers/DOMStorageManager.js: * UserInterface/Controllers/DatabaseManager.js: * UserInterface/Controllers/DebuggerManager.js: * UserInterface/Controllers/HeapManager.js: * UserInterface/Controllers/IndexedDBManager.js: * UserInterface/Controllers/JavaScriptLogViewController.js: * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: * UserInterface/Controllers/LayerTreeManager.js: * UserInterface/Controllers/MemoryManager.js: * UserInterface/Controllers/NetworkManager.js: * UserInterface/Controllers/RuntimeManager.js: * UserInterface/Controllers/TargetManager.js: * UserInterface/Controllers/TimelineManager.js: * UserInterface/Controllers/WorkerManager.js: * UserInterface/Main.html: * UserInterface/Models/AuditTestBase.js: * UserInterface/Models/AuditTestCase.js: * UserInterface/Models/AuditTestCaseResult.js: * UserInterface/Models/CPUInstrument.js: * UserInterface/Models/CPUTimelineRecord.js: * UserInterface/Models/CSSCompletions.js: * UserInterface/Models/CSSStyleSheet.js: * UserInterface/Models/Canvas.js: * UserInterface/Models/DOMNode.js: * UserInterface/Models/DOMNodeStyles.js: * UserInterface/Models/DOMStorageObject.js: * UserInterface/Models/DOMTree.js: * UserInterface/Models/DatabaseObject.js: * UserInterface/Models/FPSInstrument.js: * UserInterface/Models/GarbageCollection.js: * UserInterface/Models/HeapAllocationsInstrument.js: * UserInterface/Models/Instrument.js: * UserInterface/Models/MediaInstrument.js: * UserInterface/Models/MemoryInstrument.js: * UserInterface/Models/MemoryPressureEvent.js: * UserInterface/Models/MemoryTimelineRecord.js: * UserInterface/Models/Recording.js: * UserInterface/Models/Resource.js: * UserInterface/Models/ScriptInstrument.js: * UserInterface/Models/ScriptSyntaxTree.js: * UserInterface/Models/ScriptTimelineRecord.js: * UserInterface/Models/ShaderProgram.js: * UserInterface/Models/SourceMapResource.js: * UserInterface/Models/TimelineRecording.js: * UserInterface/Protocol/RemoteObject.js: * UserInterface/Test.html: * UserInterface/Test/FrontendTestHarness.js: * UserInterface/Test/Test.js: * UserInterface/Test/TestAppController.js: * UserInterface/Views/AuditNavigationSidebarPanel.js: * UserInterface/Views/AuditTabContentView.js: * UserInterface/Views/CanvasTabContentView.js: * UserInterface/Views/ContextMenuUtilities.js: * UserInterface/Views/CookieStorageContentView.js: * UserInterface/Views/DOMNodeDetailsSidebarPanel.js: * UserInterface/Views/DOMTreeContentView.js: * UserInterface/Views/ElementsTabContentView.js: * UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js: * UserInterface/Views/Layers3DContentView.js: * UserInterface/Views/LayersTabContentView.js: * UserInterface/Views/LayoutTimelineView.js: * UserInterface/Views/LogContentView.js: * UserInterface/Views/NetworkTabContentView.js: * UserInterface/Views/NetworkTableContentView.js: * UserInterface/Views/NetworkTimelineView.js: * UserInterface/Views/ObjectTreeView.js: * UserInterface/Views/QuickConsole.js: * UserInterface/Views/ResourceDetailsSidebarPanel.js: * UserInterface/Views/ScriptClusterTimelineView.js: * UserInterface/Views/ScriptDetailsTimelineView.js: * UserInterface/Views/ScriptTreeElement.js: * UserInterface/Views/SearchSidebarPanel.js: * UserInterface/Views/SearchTabContentView.js: * UserInterface/Views/SettingsTabContentView.js: * UserInterface/Views/SourceCodeTextEditor.js: * UserInterface/Views/SourcesNavigationSidebarPanel.js: * UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js: * UserInterface/Views/SpreadsheetStyleProperty.js: * UserInterface/Views/StorageTabContentView.js: * UserInterface/Views/TimelineRecordingContentView.js: * UserInterface/Views/TimelineTabContentView.js: * UserInterface/Views/Toolbar.js: * UserInterface/Views/WebSocketContentView.js: * UserInterface/Views/WorkerTreeElement.js: Replace all instances of `window.DomainAgent` with `target.DomainAgent`, where `target` is either derived from an associated model object or `WI.assumingMainTarget()`. Split the `WI.DebuggableType.Web` debuggable type into `WI.DebuggableType.Page` (WebCore::Page) and `WI.DebuggableType.WebPage` (WebKit::WebPageProxy). * UserInterface/Protocol/Legacy/*: * Versions/*: Update protocol files for older versions of iOS. * .eslintrc: * Localizations/en.lproj/localizedStrings.js: Source/WebKit: * WebProcess/WebPage/RemoteWebInspectorUI.h: (WebKit::WebInspectorUI::backendCommandsURL const): Added. (WebKit::WebInspectorUI::debuggableType const): Added. (WebKit::WebInspectorUI::backendCommandsURL): Deleted. (WebKit::WebInspectorUI::debuggableType): Deleted. * WebProcess/WebPage/WebInspectorUI.h: (WebKit::WebInspectorUI::backendCommandsURL const): Added. (WebKit::WebInspectorUI::debuggableType const): Added. * UIProcess/WebPageDebuggable.h: (WebKit::WebPageDebuggable::type const): * UIProcess/glib/RemoteInspectorClient.cpp: (WebKit::RemoteInspectorClient::RemoteInspectorClient): * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h: * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm: (debuggableTypeString): Split the `Web` debuggable type into `Page` (WebCore::Page) and `WebPage` (WebKit::WebPageProxy). Source/WebKitLegacy/mac: * WebCoreSupport/WebInspectorClient.h: (WebInspectorFrontendClient::debuggableType const): Added. Split the `Web` debuggable type into `Page` (WebCore::Page) and `WebPage` (WebKit::WebPageProxy). Source/WebKitLegacy/win: * WebCoreSupport/WebInspectorClient.h: (WebInspectorFrontendClient::debuggableType const): Added. Split the `Web` debuggable type into `Page` (WebCore::Page) and `WebPage` (WebKit::WebPageProxy). LayoutTests: * inspector/canvas/requestShaderSource-webgl.html: * inspector/canvas/updateShader-webgl: * inspector/page/overrideSetting.html: * inspector/page/overrideSetting-ICECandidateFilteringEnabled.html: * inspector/page/overrideSetting-MockCaptureDevicesEnabled.html: * inspector/runtime/parse.html: Replace all instances of `DomainAgent.Enum` with `InspectorBackend.domains.Domain.Enum`. * inspector/audit/run.html: * inspector/audit/version.html: * inspector/recording/version.html: Use new `InspectorBackend` methods. * inspector/unit-tests/target-manager.html: * inspector/unit-tests/target-manager-expected.txt: * inspector/worker/console-basic.html: * inspector/worker/debugger-pause.html: * inspector/worker/debugger-scripts.html: * inspector/worker/debugger-shared-breakpoint.html: * inspector/worker/resources-in-worker.html: * inspector/worker/resources/dom-debugger-utilities.js: * inspector/worker/runtime-basic.html: * http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html: Replace `WI.Target.Type` with `WI.TargetType`. * inspector/dom/inspect.html: * inspector/dom/inspect-expected.txt: Rewrite test since faking events from the backend now requires a target. * inspector/unit-tests/set-utilities.html: * inspector/unit-tests/set-utilities-expected.txt: Add tests for `Set.prototype.addAll`. Canonical link: https://commits.webkit.org/216493@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information