chrome-devtools-frontend 1.0.939144 → 1.0.940714
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.stylelintrc.json +1 -7
- package/config/gni/all_devtools_files.gni +0 -1
- package/config/gni/devtools_grd_files.gni +2 -0
- package/docs/triage_guidelines.md +13 -11
- package/front_end/Tests.js +33 -0
- package/front_end/core/host/InspectorFrontendHostAPI.ts +5 -0
- package/front_end/core/host/UserMetrics.ts +72 -0
- package/front_end/core/i18n/locales/en-US.json +30 -9
- package/front_end/core/i18n/locales/en-XL.json +30 -9
- package/front_end/core/protocol_client/InspectorBackend.ts +4 -0
- package/front_end/core/root/Runtime.ts +4 -0
- package/front_end/core/sdk/CSSModel.ts +64 -50
- package/front_end/core/sdk/CategorizedBreakpoint.ts +35 -0
- package/front_end/core/sdk/DOMDebuggerModel.ts +28 -42
- package/front_end/core/sdk/EventBreakpointsModel.ts +178 -0
- package/front_end/core/sdk/Target.ts +2 -1
- package/front_end/core/sdk/sdk.ts +4 -0
- package/front_end/devtools_compatibility.js +5 -0
- package/front_end/entrypoints/main/MainImpl.ts +6 -3
- package/front_end/entrypoints/main/main-meta.ts +1 -2
- package/front_end/entrypoints/shell/shell.js +1 -0
- package/front_end/entrypoints/shell/shell.json +0 -1
- package/front_end/models/logs/LogManager.ts +1 -0
- package/front_end/panels/accessibility/AXBreadcrumbsPane.ts +1 -1
- package/front_end/panels/accessibility/AccessibilityNodeView.ts +1 -1
- package/front_end/panels/application/ApplicationPanelCacheSection.ts +1 -1
- package/front_end/panels/application/BackForwardCacheView.ts +24 -24
- package/front_end/panels/browser_debugger/CSPViolationBreakpointsSidebarPane.ts +2 -2
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +7 -7
- package/front_end/panels/browser_debugger/EventListenerBreakpointsSidebarPane.ts +14 -6
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +6 -8
- package/front_end/panels/css_overview/components/cssOverviewStartView.css +7 -1
- package/front_end/panels/elements/StylesSidebarPane.ts +2 -1
- package/front_end/panels/issues/IssueKindView.ts +22 -4
- package/front_end/panels/lighthouse/LighthouseController.ts +10 -33
- package/front_end/panels/lighthouse/LighthousePanel.ts +2 -1
- package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +2 -1
- package/front_end/panels/network/NetworkLogView.ts +16 -0
- package/front_end/panels/network/RequestPayloadView.ts +2 -0
- package/front_end/panels/network/requestPayloadTree.css +5 -0
- package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +1 -0
- package/front_end/panels/settings/components/SyncSection.ts +25 -4
- package/front_end/panels/sources/DebuggerPausedMessage.ts +14 -7
- package/front_end/third_party/codemirror.next/bundle-tsconfig.json +1 -1
- package/front_end/ui/components/buttons/Button.ts +11 -0
- package/front_end/ui/components/buttons/button.css +4 -0
- package/front_end/ui/components/docs/button/basic.ts +10 -0
- package/package.json +2 -2
- package/scripts/eslint_rules/lib/check_component_naming.js +1 -1
- package/scripts/eslint_rules/lib/enforce_custom_event_names.js +1 -1
- package/scripts/eslint_rules/lib/l10n_no_i18nString_calls_module_instantiation.js +1 -1
- package/scripts/eslint_rules/lib/no_underscored_properties.js +1 -1
- package/front_end/entrypoints/main/module.json +0 -5
|
@@ -47,6 +47,7 @@ import {CSSStyleDeclaration, Type} from './CSSStyleDeclaration.js';
|
|
|
47
47
|
import {CSSStyleSheetHeader} from './CSSStyleSheetHeader.js';
|
|
48
48
|
import type {DOMNode} from './DOMModel.js';
|
|
49
49
|
import {DOMModel} from './DOMModel.js';
|
|
50
|
+
import type {ResourceTreeFrame} from './ResourceTreeModel.js';
|
|
50
51
|
import {Events as ResourceTreeModelEvents, ResourceTreeModel} from './ResourceTreeModel.js';
|
|
51
52
|
import type {Target} from './Target.js';
|
|
52
53
|
import {Capability} from './Target.js';
|
|
@@ -54,37 +55,37 @@ import {SDKModel} from './SDKModel.js';
|
|
|
54
55
|
import {SourceMapManager} from './SourceMapManager.js';
|
|
55
56
|
|
|
56
57
|
export class CSSModel extends SDKModel<EventTypes> {
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
readonly #
|
|
61
|
-
readonly #sourceMapManagerInternal: SourceMapManager<CSSStyleSheetHeader>;
|
|
62
|
-
agent: ProtocolProxyApi.CSSApi;
|
|
63
|
-
readonly #styleLoader: ComputedStyleLoader;
|
|
58
|
+
readonly agent: ProtocolProxyApi.CSSApi;
|
|
59
|
+
readonly #domModel: DOMModel;
|
|
60
|
+
readonly #fontFaces: Map<string, CSSFontFace>;
|
|
61
|
+
readonly #originalStyleSheetText: Map<CSSStyleSheetHeader, Promise<string|null>>;
|
|
64
62
|
readonly #resourceTreeModel: ResourceTreeModel|null;
|
|
65
|
-
#
|
|
63
|
+
readonly #sourceMapManager: SourceMapManager<CSSStyleSheetHeader>;
|
|
64
|
+
readonly #styleLoader: ComputedStyleLoader;
|
|
65
|
+
readonly #stylePollingThrottler: Common.Throttler.Throttler;
|
|
66
66
|
readonly #styleSheetIdsForURL: Map<string, Map<string, Set<Protocol.CSS.StyleSheetId>>>;
|
|
67
|
-
readonly #
|
|
68
|
-
#
|
|
69
|
-
|
|
67
|
+
readonly #styleSheetIdToHeader: Map<Protocol.CSS.StyleSheetId, CSSStyleSheetHeader>;
|
|
68
|
+
#cachedMatchedCascadeNode: DOMNode|null;
|
|
69
|
+
#cachedMatchedCascadePromise: Promise<CSSMatchedStyles|null>|null;
|
|
70
70
|
#cssPropertyTracker: CSSPropertyTracker|null;
|
|
71
71
|
#isCSSPropertyTrackingEnabled: boolean;
|
|
72
|
+
#isEnabled: boolean;
|
|
73
|
+
#isRuleUsageTrackingEnabled: boolean;
|
|
72
74
|
#isTrackingRequestPending: boolean;
|
|
73
|
-
readonly #trackedCSSProperties: Map<number, Protocol.CSS.CSSComputedStyleProperty[]>;
|
|
74
|
-
readonly #stylePollingThrottler: Common.Throttler.Throttler;
|
|
75
75
|
|
|
76
76
|
constructor(target: Target) {
|
|
77
77
|
super(target);
|
|
78
|
-
this.#
|
|
78
|
+
this.#isEnabled = false;
|
|
79
79
|
this.#cachedMatchedCascadeNode = null;
|
|
80
80
|
this.#cachedMatchedCascadePromise = null;
|
|
81
|
-
this.#
|
|
82
|
-
this.#
|
|
81
|
+
this.#domModel = (target.model(DOMModel) as DOMModel);
|
|
82
|
+
this.#sourceMapManager = new SourceMapManager(target);
|
|
83
83
|
this.agent = target.cssAgent();
|
|
84
84
|
this.#styleLoader = new ComputedStyleLoader(this);
|
|
85
85
|
this.#resourceTreeModel = target.model(ResourceTreeModel);
|
|
86
86
|
if (this.#resourceTreeModel) {
|
|
87
|
-
this.#resourceTreeModel.addEventListener(
|
|
87
|
+
this.#resourceTreeModel.addEventListener(
|
|
88
|
+
ResourceTreeModelEvents.MainFrameNavigated, this.onMainFrameNavigated, this);
|
|
88
89
|
}
|
|
89
90
|
target.registerCSSDispatcher(new CSSDispatcher(this));
|
|
90
91
|
if (!target.suspended()) {
|
|
@@ -93,23 +94,21 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
93
94
|
this.#styleSheetIdToHeader = new Map();
|
|
94
95
|
this.#styleSheetIdsForURL = new Map();
|
|
95
96
|
|
|
96
|
-
this.#
|
|
97
|
+
this.#originalStyleSheetText = new Map();
|
|
97
98
|
|
|
98
99
|
this.#isRuleUsageTrackingEnabled = false;
|
|
99
100
|
|
|
100
|
-
this.#
|
|
101
|
+
this.#fontFaces = new Map();
|
|
101
102
|
|
|
102
103
|
this.#cssPropertyTracker = null; // TODO: support multiple trackers when we refactor the backend
|
|
103
104
|
this.#isCSSPropertyTrackingEnabled = false;
|
|
104
105
|
this.#isTrackingRequestPending = false;
|
|
105
|
-
this.#trackedCSSProperties = new Map();
|
|
106
106
|
this.#stylePollingThrottler = new Common.Throttler.Throttler(StylePollingInterval);
|
|
107
107
|
|
|
108
|
-
this.#
|
|
109
|
-
Common.Settings.Settings.instance().moduleSetting('cssSourceMapsEnabled').get());
|
|
108
|
+
this.#sourceMapManager.setEnabled(Common.Settings.Settings.instance().moduleSetting('cssSourceMapsEnabled').get());
|
|
110
109
|
Common.Settings.Settings.instance()
|
|
111
110
|
.moduleSetting('cssSourceMapsEnabled')
|
|
112
|
-
.addChangeListener(event => this.#
|
|
111
|
+
.addChangeListener(event => this.#sourceMapManager.setEnabled((event.data as boolean)));
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
headersForSourceURL(sourceURL: string): CSSStyleSheetHeader[] {
|
|
@@ -148,7 +147,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
sourceMapManager(): SourceMapManager<CSSStyleSheetHeader> {
|
|
151
|
-
return this.#
|
|
150
|
+
return this.#sourceMapManager;
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
static trimSourceURL(text: string): string {
|
|
@@ -172,7 +171,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
domModel(): DOMModel {
|
|
175
|
-
return this.#
|
|
174
|
+
return this.#domModel;
|
|
176
175
|
}
|
|
177
176
|
|
|
178
177
|
async setStyleText(
|
|
@@ -187,7 +186,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
187
186
|
return false;
|
|
188
187
|
}
|
|
189
188
|
|
|
190
|
-
this.#
|
|
189
|
+
this.#domModel.markUndoableState(!majorChange);
|
|
191
190
|
const edit = new Edit(styleSheetId, range, text, styles[0]);
|
|
192
191
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
193
192
|
return true;
|
|
@@ -207,7 +206,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
207
206
|
if (!selectorList) {
|
|
208
207
|
return false;
|
|
209
208
|
}
|
|
210
|
-
this.#
|
|
209
|
+
this.#domModel.markUndoableState();
|
|
211
210
|
const edit = new Edit(styleSheetId, range, text, selectorList);
|
|
212
211
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
213
212
|
return true;
|
|
@@ -227,7 +226,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
227
226
|
if (!keyText) {
|
|
228
227
|
return false;
|
|
229
228
|
}
|
|
230
|
-
this.#
|
|
229
|
+
this.#domModel.markUndoableState();
|
|
231
230
|
const edit = new Edit(styleSheetId, range, text, keyText);
|
|
232
231
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
233
232
|
return true;
|
|
@@ -268,12 +267,12 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
268
267
|
}
|
|
269
268
|
|
|
270
269
|
isEnabled(): boolean {
|
|
271
|
-
return this.#
|
|
270
|
+
return this.#isEnabled;
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
private async enable(): Promise<void> {
|
|
275
274
|
await this.agent.invoke_enable();
|
|
276
|
-
this.#
|
|
275
|
+
this.#isEnabled = true;
|
|
277
276
|
if (this.#isRuleUsageTrackingEnabled) {
|
|
278
277
|
await this.startCoverage();
|
|
279
278
|
}
|
|
@@ -287,7 +286,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
287
286
|
return null;
|
|
288
287
|
}
|
|
289
288
|
|
|
290
|
-
const node = this.#
|
|
289
|
+
const node = this.#domModel.nodeForId(nodeId);
|
|
291
290
|
if (!node) {
|
|
292
291
|
return null;
|
|
293
292
|
}
|
|
@@ -399,7 +398,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
399
398
|
if (!media) {
|
|
400
399
|
return false;
|
|
401
400
|
}
|
|
402
|
-
this.#
|
|
401
|
+
this.#domModel.markUndoableState();
|
|
403
402
|
const edit = new Edit(styleSheetId, range, newMediaText, media);
|
|
404
403
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
405
404
|
return true;
|
|
@@ -421,7 +420,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
421
420
|
if (!containerQuery) {
|
|
422
421
|
return false;
|
|
423
422
|
}
|
|
424
|
-
this.#
|
|
423
|
+
this.#domModel.markUndoableState();
|
|
425
424
|
const edit = new Edit(styleSheetId, range, newContainerQueryText, containerQuery);
|
|
426
425
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
427
426
|
return true;
|
|
@@ -439,7 +438,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
439
438
|
if (!rule) {
|
|
440
439
|
return null;
|
|
441
440
|
}
|
|
442
|
-
this.#
|
|
441
|
+
this.#domModel.markUndoableState();
|
|
443
442
|
const edit = new Edit(styleSheetId, ruleLocation, ruleText, rule);
|
|
444
443
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
445
444
|
return new CSSStyleRule(this, rule);
|
|
@@ -477,13 +476,13 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
477
476
|
|
|
478
477
|
fontsUpdated(fontFace?: Protocol.CSS.FontFace|null): void {
|
|
479
478
|
if (fontFace) {
|
|
480
|
-
this.#
|
|
479
|
+
this.#fontFaces.set(fontFace.src, new CSSFontFace(fontFace));
|
|
481
480
|
}
|
|
482
481
|
this.dispatchEventToListeners(Events.FontsUpdated);
|
|
483
482
|
}
|
|
484
483
|
|
|
485
484
|
fontFaces(): CSSFontFace[] {
|
|
486
|
-
return [...this.#
|
|
485
|
+
return [...this.#fontFaces.values()];
|
|
487
486
|
}
|
|
488
487
|
|
|
489
488
|
styleSheetHeaderForId(id: Protocol.CSS.StyleSheetId): CSSStyleSheetHeader|null {
|
|
@@ -503,10 +502,10 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
503
502
|
if (!header) {
|
|
504
503
|
return Promise.resolve(null);
|
|
505
504
|
}
|
|
506
|
-
let promise = this.#
|
|
505
|
+
let promise = this.#originalStyleSheetText.get(header);
|
|
507
506
|
if (!promise) {
|
|
508
507
|
promise = this.getStyleSheetText(header.id);
|
|
509
|
-
this.#
|
|
508
|
+
this.#originalStyleSheetText.set(header, promise);
|
|
510
509
|
this.originalContentRequestedForTest(header);
|
|
511
510
|
}
|
|
512
511
|
return promise;
|
|
@@ -541,8 +540,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
541
540
|
}
|
|
542
541
|
styleSheetIds.add(styleSheetHeader.id);
|
|
543
542
|
}
|
|
544
|
-
this.#
|
|
545
|
-
styleSheetHeader, styleSheetHeader.sourceURL, styleSheetHeader.sourceMapURL);
|
|
543
|
+
this.#sourceMapManager.attachSourceMap(styleSheetHeader, styleSheetHeader.sourceURL, styleSheetHeader.sourceMapURL);
|
|
546
544
|
this.dispatchEventToListeners(Events.StyleSheetAdded, styleSheetHeader);
|
|
547
545
|
}
|
|
548
546
|
|
|
@@ -569,8 +567,8 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
569
567
|
}
|
|
570
568
|
}
|
|
571
569
|
}
|
|
572
|
-
this.#
|
|
573
|
-
this.#
|
|
570
|
+
this.#originalStyleSheetText.delete(header);
|
|
571
|
+
this.#sourceMapManager.detachSourceMap(header);
|
|
574
572
|
this.dispatchEventToListeners(Events.StyleSheetRemoved, header);
|
|
575
573
|
}
|
|
576
574
|
|
|
@@ -602,13 +600,13 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
602
600
|
const response = await this.agent.invoke_setStyleSheetText({styleSheetId: header.id, text: newText});
|
|
603
601
|
const sourceMapURL = response.sourceMapURL;
|
|
604
602
|
|
|
605
|
-
this.#
|
|
603
|
+
this.#sourceMapManager.detachSourceMap(header);
|
|
606
604
|
header.setSourceMapURL(sourceMapURL);
|
|
607
|
-
this.#
|
|
605
|
+
this.#sourceMapManager.attachSourceMap(header, header.sourceURL, header.sourceMapURL);
|
|
608
606
|
if (sourceMapURL === null) {
|
|
609
607
|
return 'Error in CSS.setStyleSheetText';
|
|
610
608
|
}
|
|
611
|
-
this.#
|
|
609
|
+
this.#domModel.markUndoableState(!majorChange);
|
|
612
610
|
this.fireStyleSheetChanged(styleSheetId);
|
|
613
611
|
return null;
|
|
614
612
|
}
|
|
@@ -622,22 +620,38 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
622
620
|
}
|
|
623
621
|
}
|
|
624
622
|
|
|
623
|
+
private async onMainFrameNavigated(event: Common.EventTarget.EventTargetEvent<ResourceTreeFrame>): Promise<void> {
|
|
624
|
+
// If the main frame was restored from the back-forward cache, the order of CDP
|
|
625
|
+
// is different from the regular navigations. In this case, events about CSS
|
|
626
|
+
// stylesheet has already been received and they are mixed with the previous page
|
|
627
|
+
// stylesheets. Therefore, we re-enable the CSS agent to get fresh events.
|
|
628
|
+
// For the regular navigatons, we can just clear the local data because events about
|
|
629
|
+
// stylesheets will arrive later.
|
|
630
|
+
if (event.data.backForwardCacheDetails.restoredFromCache) {
|
|
631
|
+
await this.suspendModel();
|
|
632
|
+
await this.resumeModel();
|
|
633
|
+
} else {
|
|
634
|
+
this.resetStyleSheets();
|
|
635
|
+
this.resetFontFaces();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
625
639
|
private resetStyleSheets(): void {
|
|
626
640
|
const headers = [...this.#styleSheetIdToHeader.values()];
|
|
627
641
|
this.#styleSheetIdsForURL.clear();
|
|
628
642
|
this.#styleSheetIdToHeader.clear();
|
|
629
643
|
for (const header of headers) {
|
|
630
|
-
this.#
|
|
644
|
+
this.#sourceMapManager.detachSourceMap(header);
|
|
631
645
|
this.dispatchEventToListeners(Events.StyleSheetRemoved, header);
|
|
632
646
|
}
|
|
633
647
|
}
|
|
634
648
|
|
|
635
649
|
private resetFontFaces(): void {
|
|
636
|
-
this.#
|
|
650
|
+
this.#fontFaces.clear();
|
|
637
651
|
}
|
|
638
652
|
|
|
639
653
|
async suspendModel(): Promise<void> {
|
|
640
|
-
this.#
|
|
654
|
+
this.#isEnabled = false;
|
|
641
655
|
await this.agent.invoke_disable();
|
|
642
656
|
this.resetStyleSheets();
|
|
643
657
|
this.resetFontFaces();
|
|
@@ -713,7 +727,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
713
727
|
if (this.#cssPropertyTracker) {
|
|
714
728
|
this.#cssPropertyTracker.dispatchEventToListeners(
|
|
715
729
|
CSSPropertyTrackerEvents.TrackedCSSPropertiesUpdated,
|
|
716
|
-
result.nodeIds.map(nodeId => this.#
|
|
730
|
+
result.nodeIds.map(nodeId => this.#domModel.nodeForId(nodeId)));
|
|
717
731
|
}
|
|
718
732
|
}
|
|
719
733
|
|
|
@@ -725,7 +739,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
725
739
|
dispose(): void {
|
|
726
740
|
this.disableCSSPropertyTracker();
|
|
727
741
|
super.dispose();
|
|
728
|
-
this.#
|
|
742
|
+
this.#sourceMapManager.dispose();
|
|
729
743
|
}
|
|
730
744
|
|
|
731
745
|
getAgent(): ProtocolProxyApi.CSSApi {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
export class CategorizedBreakpoint {
|
|
6
|
+
readonly #categoryInternal: string;
|
|
7
|
+
titleInternal: string;
|
|
8
|
+
enabledInternal: boolean;
|
|
9
|
+
|
|
10
|
+
constructor(category: string, title: string) {
|
|
11
|
+
this.#categoryInternal = category;
|
|
12
|
+
this.titleInternal = title;
|
|
13
|
+
this.enabledInternal = false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
category(): string {
|
|
17
|
+
return this.#categoryInternal;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enabled(): boolean {
|
|
21
|
+
return this.enabledInternal;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setEnabled(enabled: boolean): void {
|
|
25
|
+
this.enabledInternal = enabled;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
title(): string {
|
|
29
|
+
return this.titleInternal;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setTitle(title: string): void {
|
|
33
|
+
this.titleInternal = title;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -7,6 +7,7 @@ import * as i18n from '../i18n/i18n.js';
|
|
|
7
7
|
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
|
|
8
8
|
import * as Protocol from '../../generated/protocol.js';
|
|
9
9
|
|
|
10
|
+
import {CategorizedBreakpoint} from './CategorizedBreakpoint.js';
|
|
10
11
|
import type {Location} from './DebuggerModel.js';
|
|
11
12
|
import type {DOMNode} from './DOMModel.js';
|
|
12
13
|
import {DOMModel, Events as DOMModelEvents} from './DOMModel.js';
|
|
@@ -690,38 +691,6 @@ export namespace EventListener {
|
|
|
690
691
|
}
|
|
691
692
|
}
|
|
692
693
|
|
|
693
|
-
export class CategorizedBreakpoint {
|
|
694
|
-
readonly #categoryInternal: string;
|
|
695
|
-
titleInternal: string;
|
|
696
|
-
enabledInternal: boolean;
|
|
697
|
-
|
|
698
|
-
constructor(category: string, title: string) {
|
|
699
|
-
this.#categoryInternal = category;
|
|
700
|
-
this.titleInternal = title;
|
|
701
|
-
this.enabledInternal = false;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
category(): string {
|
|
705
|
-
return this.#categoryInternal;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
enabled(): boolean {
|
|
709
|
-
return this.enabledInternal;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
setEnabled(enabled: boolean): void {
|
|
713
|
-
this.enabledInternal = enabled;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
title(): string {
|
|
717
|
-
return this.titleInternal;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
setTitle(title: string): void {
|
|
721
|
-
this.titleInternal = title;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
694
|
export class CSPViolationBreakpoint extends CategorizedBreakpoint {
|
|
726
695
|
readonly #typeInternal: Protocol.DOMDebugger.CSPViolationType;
|
|
727
696
|
constructor(category: string, title: string, type: Protocol.DOMDebugger.CSPViolationType) {
|
|
@@ -734,7 +703,7 @@ export class CSPViolationBreakpoint extends CategorizedBreakpoint {
|
|
|
734
703
|
}
|
|
735
704
|
}
|
|
736
705
|
|
|
737
|
-
export class
|
|
706
|
+
export class DOMEventListenerBreakpoint extends CategorizedBreakpoint {
|
|
738
707
|
readonly instrumentationName: string;
|
|
739
708
|
readonly eventName: string;
|
|
740
709
|
readonly eventTargetNames: string[];
|
|
@@ -784,7 +753,7 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
784
753
|
readonly #xhrBreakpointsSetting: Common.Settings.Setting<{url: string, enabled: boolean}[]>;
|
|
785
754
|
readonly #xhrBreakpointsInternal: Map<string, boolean>;
|
|
786
755
|
readonly #cspViolationsToBreakOn: CSPViolationBreakpoint[];
|
|
787
|
-
readonly #eventListenerBreakpointsInternal:
|
|
756
|
+
readonly #eventListenerBreakpointsInternal: DOMEventListenerBreakpoint[];
|
|
788
757
|
|
|
789
758
|
constructor() {
|
|
790
759
|
this.#xhrBreakpointsSetting = Common.Settings.Settings.instance().createLocalSetting('xhrBreakpoints', []);
|
|
@@ -861,7 +830,24 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
861
830
|
this.createEventListenerBreakpoints(
|
|
862
831
|
i18nString(UIStrings.keyboard), ['keydown', 'keyup', 'keypress', 'input'], ['*']);
|
|
863
832
|
this.createEventListenerBreakpoints(
|
|
864
|
-
i18nString(UIStrings.load),
|
|
833
|
+
i18nString(UIStrings.load),
|
|
834
|
+
[
|
|
835
|
+
'load',
|
|
836
|
+
'beforeunload',
|
|
837
|
+
'unload',
|
|
838
|
+
'abort',
|
|
839
|
+
'error',
|
|
840
|
+
'hashchange',
|
|
841
|
+
'popstate',
|
|
842
|
+
'navigate',
|
|
843
|
+
'navigatesuccess',
|
|
844
|
+
'navigateerror',
|
|
845
|
+
'currentchange',
|
|
846
|
+
'navigateto',
|
|
847
|
+
'navigatefrom',
|
|
848
|
+
'finish',
|
|
849
|
+
'dispose',
|
|
850
|
+
],
|
|
865
851
|
['*']);
|
|
866
852
|
this.createEventListenerBreakpoints(
|
|
867
853
|
i18nString(UIStrings.mouse),
|
|
@@ -933,19 +919,19 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
933
919
|
private createInstrumentationBreakpoints(category: string, instrumentationNames: string[]): void {
|
|
934
920
|
for (const instrumentationName of instrumentationNames) {
|
|
935
921
|
this.#eventListenerBreakpointsInternal.push(
|
|
936
|
-
new
|
|
922
|
+
new DOMEventListenerBreakpoint(instrumentationName, '', [], category, instrumentationName));
|
|
937
923
|
}
|
|
938
924
|
}
|
|
939
925
|
|
|
940
926
|
private createEventListenerBreakpoints(category: string, eventNames: string[], eventTargetNames: string[]): void {
|
|
941
927
|
for (const eventName of eventNames) {
|
|
942
928
|
this.#eventListenerBreakpointsInternal.push(
|
|
943
|
-
new
|
|
929
|
+
new DOMEventListenerBreakpoint('', eventName, eventTargetNames, category, eventName));
|
|
944
930
|
}
|
|
945
931
|
}
|
|
946
932
|
|
|
947
|
-
private resolveEventListenerBreakpointInternal(eventName: string, eventTargetName?: string):
|
|
948
|
-
|null {
|
|
933
|
+
private resolveEventListenerBreakpointInternal(eventName: string, eventTargetName?: string):
|
|
934
|
+
DOMEventListenerBreakpoint|null {
|
|
949
935
|
const instrumentationPrefix = 'instrumentation:';
|
|
950
936
|
const listenerPrefix = 'listener:';
|
|
951
937
|
let instrumentationName = '';
|
|
@@ -958,7 +944,7 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
958
944
|
return null;
|
|
959
945
|
}
|
|
960
946
|
eventTargetName = (eventTargetName || '*').toLowerCase();
|
|
961
|
-
let result:
|
|
947
|
+
let result: DOMEventListenerBreakpoint|null = null;
|
|
962
948
|
for (const breakpoint of this.#eventListenerBreakpointsInternal) {
|
|
963
949
|
if (instrumentationName && breakpoint.instrumentationName === instrumentationName) {
|
|
964
950
|
result = breakpoint;
|
|
@@ -975,7 +961,7 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
975
961
|
return result;
|
|
976
962
|
}
|
|
977
963
|
|
|
978
|
-
eventListenerBreakpoints():
|
|
964
|
+
eventListenerBreakpoints(): DOMEventListenerBreakpoint[] {
|
|
979
965
|
return this.#eventListenerBreakpointsInternal.slice();
|
|
980
966
|
}
|
|
981
967
|
|
|
@@ -1008,7 +994,7 @@ export class DOMDebuggerManager implements SDKModelObserver<DOMDebuggerModel> {
|
|
|
1008
994
|
resolveEventListenerBreakpoint(auxData: {
|
|
1009
995
|
eventName: string,
|
|
1010
996
|
targetName: string,
|
|
1011
|
-
}):
|
|
997
|
+
}): DOMEventListenerBreakpoint|null {
|
|
1012
998
|
return this.resolveEventListenerBreakpointInternal(auxData['eventName'], auxData['targetName']);
|
|
1013
999
|
}
|
|
1014
1000
|
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import type * as Common from '../common/common.js';
|
|
6
|
+
import * as i18n from '../i18n/i18n.js';
|
|
7
|
+
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
|
|
8
|
+
|
|
9
|
+
import {CategorizedBreakpoint} from './CategorizedBreakpoint.js';
|
|
10
|
+
import type {Target} from './Target.js';
|
|
11
|
+
import {Capability} from './Target.js';
|
|
12
|
+
import {SDKModel} from './SDKModel.js';
|
|
13
|
+
import type {SDKModelObserver} from './TargetManager.js';
|
|
14
|
+
import {TargetManager} from './TargetManager.js';
|
|
15
|
+
|
|
16
|
+
const UIStrings = {
|
|
17
|
+
/**
|
|
18
|
+
* @description Category of breakpoints
|
|
19
|
+
*/
|
|
20
|
+
auctionWorklet: 'Ad Auction Worklet',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @description Name of a breakpoint type.
|
|
24
|
+
* https://github.com/WICG/turtledove/blob/main/FLEDGE.md#32-on-device-bidding
|
|
25
|
+
*/
|
|
26
|
+
beforeBidderWorkletBiddingStart: 'Bidder Bidding Phase Start',
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @description Name of a breakpoint type.
|
|
30
|
+
* https://github.com/WICG/turtledove/blob/main/FLEDGE.md#52-buyer-reporting-on-render-and-ad-events
|
|
31
|
+
*/
|
|
32
|
+
beforeBidderWorkletReportingStart: 'Bidder Reporting Phase Start',
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @description Name of a breakpoint type.
|
|
36
|
+
* https://github.com/WICG/turtledove/blob/main/FLEDGE.md#23-scoring-bids
|
|
37
|
+
*/
|
|
38
|
+
beforeSellerWorkletScoringStart: 'Seller Scoring Phase Start',
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description Name of a breakpoint type.
|
|
42
|
+
* https://github.com/WICG/turtledove/blob/main/FLEDGE.md#51-seller-reporting-on-render
|
|
43
|
+
*/
|
|
44
|
+
beforeSellerWorkletReportingStart: 'Seller Reporting Phase Start',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const str_ = i18n.i18n.registerUIStrings('core/sdk/EventBreakpointsModel.ts', UIStrings);
|
|
48
|
+
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
49
|
+
|
|
50
|
+
const enum InstrumentationNames {
|
|
51
|
+
BeforeBidderWorkletBiddingStart = 'beforeBidderWorkletBiddingStart',
|
|
52
|
+
BeforeBidderWorkletReportingStart = 'beforeBidderWorkletReportingStart',
|
|
53
|
+
BeforeSellerWorkletScoringStart = 'beforeSellerWorkletScoringStart',
|
|
54
|
+
BeforeSellerWorkletReportingStart = 'beforeSellerWorkletReportingStart',
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getTitleForInstrumentationName(instrumentationName: InstrumentationNames): Common.UIString.LocalizedString {
|
|
58
|
+
switch (instrumentationName) {
|
|
59
|
+
case InstrumentationNames.BeforeBidderWorkletBiddingStart:
|
|
60
|
+
return i18nString(UIStrings.beforeBidderWorkletBiddingStart);
|
|
61
|
+
|
|
62
|
+
case InstrumentationNames.BeforeBidderWorkletReportingStart:
|
|
63
|
+
return i18nString(UIStrings.beforeBidderWorkletReportingStart);
|
|
64
|
+
|
|
65
|
+
case InstrumentationNames.BeforeSellerWorkletScoringStart:
|
|
66
|
+
return i18nString(UIStrings.beforeSellerWorkletScoringStart);
|
|
67
|
+
|
|
68
|
+
case InstrumentationNames.BeforeSellerWorkletReportingStart:
|
|
69
|
+
return i18nString(UIStrings.beforeSellerWorkletReportingStart);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class EventBreakpointsModel extends SDKModel<void> {
|
|
74
|
+
readonly agent: ProtocolProxyApi.EventBreakpointsApi;
|
|
75
|
+
|
|
76
|
+
constructor(target: Target) {
|
|
77
|
+
super(target);
|
|
78
|
+
this.agent = target.eventBreakpointsAgent();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// This implementation (as opposed to similar class in DOMDebuggerModel) is for
|
|
83
|
+
// instrumentation breakpoints in targets that run JS but do not have a DOM.
|
|
84
|
+
class EventListenerBreakpoint extends CategorizedBreakpoint {
|
|
85
|
+
readonly instrumentationName: string;
|
|
86
|
+
constructor(instrumentationName: InstrumentationNames, category: string) {
|
|
87
|
+
super(category, getTitleForInstrumentationName(instrumentationName));
|
|
88
|
+
this.instrumentationName = instrumentationName;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setEnabled(enabled: boolean): void {
|
|
92
|
+
if (this.enabled() === enabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
super.setEnabled(enabled);
|
|
96
|
+
for (const model of TargetManager.instance().models(EventBreakpointsModel)) {
|
|
97
|
+
this.updateOnModel(model);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
updateOnModel(model: EventBreakpointsModel): void {
|
|
102
|
+
if (this.enabled()) {
|
|
103
|
+
model.agent.invoke_setInstrumentationBreakpoint({eventName: this.instrumentationName});
|
|
104
|
+
} else {
|
|
105
|
+
model.agent.invoke_removeInstrumentationBreakpoint({eventName: this.instrumentationName});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static readonly instrumentationPrefix = 'instrumentation:';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let eventBreakpointManagerInstance: EventBreakpointsManager;
|
|
113
|
+
|
|
114
|
+
export class EventBreakpointsManager implements SDKModelObserver<EventBreakpointsModel> {
|
|
115
|
+
readonly #eventListenerBreakpointsInternal: EventListenerBreakpoint[] = [];
|
|
116
|
+
|
|
117
|
+
constructor() {
|
|
118
|
+
this.createInstrumentationBreakpoints(i18nString(UIStrings.auctionWorklet), [
|
|
119
|
+
InstrumentationNames.BeforeBidderWorkletBiddingStart,
|
|
120
|
+
InstrumentationNames.BeforeBidderWorkletReportingStart,
|
|
121
|
+
InstrumentationNames.BeforeSellerWorkletScoringStart,
|
|
122
|
+
InstrumentationNames.BeforeSellerWorkletReportingStart,
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
TargetManager.instance().observeModels(EventBreakpointsModel, this);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static instance(opts: {
|
|
129
|
+
forceNew: boolean|null,
|
|
130
|
+
} = {forceNew: null}): EventBreakpointsManager {
|
|
131
|
+
const {forceNew} = opts;
|
|
132
|
+
if (!eventBreakpointManagerInstance || forceNew) {
|
|
133
|
+
eventBreakpointManagerInstance = new EventBreakpointsManager();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return eventBreakpointManagerInstance;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private createInstrumentationBreakpoints(category: string, instrumentationNames: InstrumentationNames[]): void {
|
|
140
|
+
for (const instrumentationName of instrumentationNames) {
|
|
141
|
+
this.#eventListenerBreakpointsInternal.push(new EventListenerBreakpoint(instrumentationName, category));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
eventListenerBreakpoints(): EventListenerBreakpoint[] {
|
|
146
|
+
return this.#eventListenerBreakpointsInternal.slice();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
resolveEventListenerBreakpointTitle(auxData: {
|
|
150
|
+
eventName: string,
|
|
151
|
+
}): string|null {
|
|
152
|
+
const breakpoint = this.resolveEventListenerBreakpoint(auxData);
|
|
153
|
+
return breakpoint ? breakpoint.title() : null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
resolveEventListenerBreakpoint(auxData: {eventName: string}): EventListenerBreakpoint|null {
|
|
157
|
+
const eventName = auxData.eventName;
|
|
158
|
+
if (!eventName.startsWith(EventListenerBreakpoint.instrumentationPrefix)) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const instrumentationName = eventName.substring(EventListenerBreakpoint.instrumentationPrefix.length);
|
|
163
|
+
return this.#eventListenerBreakpointsInternal.find(b => b.instrumentationName === instrumentationName) || null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
modelAdded(eventBreakpointModel: EventBreakpointsModel): void {
|
|
167
|
+
for (const breakpoint of this.#eventListenerBreakpointsInternal) {
|
|
168
|
+
if (breakpoint.enabled()) {
|
|
169
|
+
breakpoint.updateOnModel(eventBreakpointModel);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
modelRemoved(_eventBreakpointModel: EventBreakpointsModel): void {
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
SDKModel.register(EventBreakpointsModel, {capabilities: Capability.EventBreakpoints, autostart: false});
|
|
@@ -67,7 +67,7 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
|
|
|
67
67
|
this.#capabilitiesMask = Capability.JS;
|
|
68
68
|
break;
|
|
69
69
|
case Type.AuctionWorklet:
|
|
70
|
-
this.#capabilitiesMask = Capability.JS;
|
|
70
|
+
this.#capabilitiesMask = Capability.JS | Capability.EventBreakpoints;
|
|
71
71
|
break;
|
|
72
72
|
case Type.Browser:
|
|
73
73
|
this.#capabilitiesMask = Capability.Target | Capability.IO;
|
|
@@ -249,5 +249,6 @@ export enum Capability {
|
|
|
249
249
|
WebAuthn = 1 << 16,
|
|
250
250
|
IO = 1 << 17,
|
|
251
251
|
Media = 1 << 18,
|
|
252
|
+
EventBreakpoints = 1 << 19,
|
|
252
253
|
None = 0,
|
|
253
254
|
}
|