Skip to content

Commit 0cc1cdd

Browse files
masnobleDevtools-frontend LUCI CQ
authored andcommitted
Reveal the CookieReportView by selecting sidebar element
This fixes the issue where the someone may click a console message that reveals the CookieReportView, but the wrong sidebar element is highlighted. By making the revealer select the sidebar element directly, we allow the sidebar to manage showing the the CookieReportView as it would with a normal user selection. Bug:394934461 Change-Id: Iada064f42db049ce7e9a0f40c0438886684e891e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6241738 Reviewed-by: Shuran Huang <[email protected]> Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Shuran Huang <[email protected]>
1 parent 29348c7 commit 0cc1cdd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

front_end/panels/security/SecurityPanel.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,15 +1624,16 @@ export interface OriginState {
16241624
export type Origin = Platform.DevToolsPath.UrlString;
16251625

16261626
export class SecurityRevealer implements Common.Revealer.Revealer<CookieReportView> {
1627-
async reveal(cookieReportView: CookieReportView): Promise<void> {
1627+
async reveal(): Promise<void> {
16281628
await UI.ViewManager.ViewManager.instance().showView('security');
16291629
const view = UI.ViewManager.ViewManager.instance().view('security');
16301630
if (view) {
16311631
const securityPanel = await view.widget();
1632-
if (securityPanel instanceof SecurityPanel) {
1633-
securityPanel.setVisibleView(cookieReportView);
1632+
if (securityPanel instanceof SecurityPanel && securityPanel.sidebar.cookieReportTreeElement) {
1633+
securityPanel.sidebar.cookieReportTreeElement.select(/* omitFocus=*/ false, /* selectedByUser=*/ true);
16341634
} else {
1635-
throw new Error('Expected securityPanel to be an instance of SecurityPanel');
1635+
throw new Error(
1636+
'Expected securityPanel to be an instance of SecurityPanel with a cookieReportTreeElement in the sidebar');
16361637
}
16371638
}
16381639
}

front_end/panels/security/SecurityPanelSidebar.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
7575
#originGroups: Map<OriginGroup, UI.TreeOutline.TreeElement>;
7676
securityOverviewElement: OriginTreeElement;
7777
readonly #cookieControlsTreeElement: CookieControlsTreeElement|undefined;
78-
readonly #cookieReportTreeElement: CookieReportTreeElement|undefined;
78+
readonly cookieReportTreeElement: CookieReportTreeElement|undefined;
7979
readonly #elementsByOrigin: Map<string, OriginTreeElement>;
8080
readonly #mainViewReloadMessage: UI.TreeOutline.TreeElement;
8181
#mainOrigin: string|null;
@@ -97,8 +97,8 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
9797
this.#cookieControlsTreeElement =
9898
new CookieControlsTreeElement(i18nString(UIStrings.flagControls), 'cookie-flag-controls');
9999
privacyTreeSection.appendChild(this.#cookieControlsTreeElement);
100-
this.#cookieReportTreeElement = new CookieReportTreeElement(i18nString(UIStrings.cookieReport), 'cookie-report');
101-
privacyTreeSection.appendChild(this.#cookieReportTreeElement);
100+
this.cookieReportTreeElement = new CookieReportTreeElement(i18nString(UIStrings.cookieReport), 'cookie-report');
101+
privacyTreeSection.appendChild(this.cookieReportTreeElement);
102102

103103
// If this if the first time this setting is set, go to the controls tool
104104
if (this.#securitySidebarLastItemSetting.get() === '') {
@@ -175,10 +175,10 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
175175
this.#cookieControlsTreeElement.select();
176176
this.#cookieControlsTreeElement.showElement();
177177
} else if (
178-
this.#cookieReportTreeElement &&
179-
this.#securitySidebarLastItemSetting.get() === this.#cookieReportTreeElement.elemId) {
180-
this.#cookieReportTreeElement.select();
181-
this.#cookieReportTreeElement.showElement();
178+
this.cookieReportTreeElement &&
179+
this.#securitySidebarLastItemSetting.get() === this.cookieReportTreeElement.elemId) {
180+
this.cookieReportTreeElement.select();
181+
this.cookieReportTreeElement.showElement();
182182
} else {
183183
this.securityOverviewElement.select();
184184
this.securityOverviewElement.showElement();

0 commit comments

Comments
 (0)