Skip to content

Commit c1b0ea1

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
Reland "Use shadow dom for Lighthouse panel"
This is a reland of commit 465796b This CL restricts the shadow dom only to the `LighthouseStartView` instead of the whole `LighthousePanel`, which led to the regression. Original change's description: > Use shadow dom for Lighthouse panel > > This CL changes the Lighthouse panel to make use of a top level shadow > dom. Previously, styles from the Lighthouse panel were appended > to the document's adoptedStyleSheets, and thus leaking to other panels. > > Bug: 372176188 > Change-Id: I0b9695cd86839e28ea4c83ef2ad6bb290797946a > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5953314 > Reviewed-by: Ergün Erdoğmuş <[email protected]> > Commit-Queue: Kim-Anh Tran <[email protected]> Bug: 372176188 Change-Id: I9bb842949b76d2f60ea3b60bb10238727ac4a55b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5966474 Commit-Queue: Kim-Anh Tran <[email protected]> Reviewed-by: Liviu Rau <[email protected]> Reviewed-by: Ergün Erdoğmuş <[email protected]>
1 parent a9a555b commit c1b0ea1

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

front_end/panels/lighthouse/LighthouseStartView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class StartView extends UI.Widget.Widget {
6363
changeFormMode?: (mode: string) => void;
6464

6565
constructor(controller: LighthouseController, panel: LighthousePanel) {
66-
super();
66+
super(true /* useShadowDom */);
6767

6868
this.controller = controller;
6969
this.panel = panel;

front_end/ui/legacy/Panel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import {VBox} from './Widget.js';
3939
export class Panel extends VBox {
4040
protected panelName: string;
4141

42-
constructor(name: string) {
43-
super();
42+
constructor(name: string, useShadowDom?: boolean) {
43+
super(useShadowDom);
4444

4545
this.element.setAttribute('jslog', `${VisualLogging.panel().context(name).track({resize: true})}`);
4646
this.element.classList.add('panel');

front_end/ui/visual_logging/KnownContextValues.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,6 +2741,7 @@ export const knownContextValues = new Set([
27412741
'show-grid-areas',
27422742
'show-grid-areas-true',
27432743
'show-grid-line-labels',
2744+
'show-grid-line-labels-line-names',
27442745
'show-grid-track-sizes',
27452746
'show-grid-track-sizes-true',
27462747
'show-html-comments',

test/e2e/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ node_ts_library("tests") {
3535
"media",
3636
"memory",
3737
"network",
38+
"panels",
3839
"performance",
3940
"puppeteer",
4041
"quick_open",

test/e2e/panels/BUILD.gn

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2024 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("../../../scripts/build/typescript/typescript.gni")
6+
7+
node_ts_library("panels") {
8+
sources = [ "panels_test.ts" ]
9+
10+
deps = [
11+
"../../shared",
12+
"../helpers",
13+
]
14+
}

test/e2e/panels/panels_test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2024 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 {assert} from 'chai';
6+
7+
import {
8+
getBrowserAndPages,
9+
waitFor,
10+
} from '../../shared/helper.js';
11+
12+
// Ideally we want to have all panels within this list,
13+
// but introducing shadow doms for all panels currently leads
14+
// to unwanted visual side effects.
15+
const PANEL_NAMES = [
16+
'Lighthouse',
17+
];
18+
19+
import {runCommandWithQuickOpen} from '../helpers/quick_open-helpers.js';
20+
21+
describe('DevTools panels', function() {
22+
PANEL_NAMES.forEach(panel => {
23+
it(`${panel} doesn't increase number of adopted style sheets on the document`, async () => {
24+
const {frontend} = getBrowserAndPages();
25+
const previousNumStyleSheets = await frontend.evaluate(() => document.adoptedStyleSheets.length);
26+
await runCommandWithQuickOpen(`Show ${panel}`);
27+
await waitFor(`[aria-label="${panel}"]`);
28+
const nextNumStyleSheets = await frontend.evaluate(() => document.adoptedStyleSheets.length);
29+
assert.strictEqual(previousNumStyleSheets, nextNumStyleSheets);
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)