Skip to content

Commit 941b581

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update WebAudio empty state
Before: https://i.imgur.com/5iWoTpW.png After: https://i.imgur.com/GhMYq8R.png Bug: 325443331 Change-Id: I1d9b2c13f54c74dafc81fee1dd54b2d85f2ae14c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6257650 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent ca0d440 commit 941b581

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

front_end/panels/web_audio/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ devtools_entrypoint("meta") {
6565
ts_library("unittests") {
6666
testonly = true
6767

68-
sources = [ "web_audio.test.ts" ]
68+
sources = [
69+
"WebAudioView.test.ts",
70+
"web_audio.test.ts",
71+
]
6972

7073
deps = [
7174
":bundle",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 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 Platform from '../../core/platform/platform.js';
6+
import {describeWithEnvironment} from '../../testing/EnvironmentHelpers.js';
7+
import * as UI from '../../ui/legacy/legacy.js';
8+
9+
import {WebAudioView} from './web_audio.js';
10+
11+
describeWithEnvironment('WebAudioView', () => {
12+
beforeEach(() => {
13+
UI.ActionRegistration.registerActionExtension({
14+
actionId: 'components.collect-garbage',
15+
category: UI.ActionRegistration.ActionCategory.PERFORMANCE,
16+
title: () => 'mock' as Platform.UIString.LocalizedString,
17+
toggleable: true,
18+
});
19+
sinon.stub(UI.ShortcutRegistry.ShortcutRegistry, 'instance').returns({
20+
shortcutTitleForAction: () => {},
21+
shortcutsForAction: () => [],
22+
} as unknown as UI.ShortcutRegistry.ShortcutRegistry);
23+
});
24+
25+
it('shows placeholder', () => {
26+
const view = new WebAudioView.WebAudioView();
27+
assert.exists(view.contentElement.querySelector('.empty-state'));
28+
assert.deepEqual(
29+
view.contentElement.querySelector('.empty-state-header')?.textContent, 'No web audio API usage detected');
30+
assert.deepEqual(
31+
view.contentElement.querySelector('.empty-state-description > span')?.textContent,
32+
'Open a page that uses web audio API to start monitoring.');
33+
});
34+
});

front_end/panels/web_audio/WebAudioView.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import '../../ui/legacy/legacy.js';
66

77
import type * as Common from '../../core/common/common.js';
88
import * as i18n from '../../core/i18n/i18n.js';
9+
import type * as Platform from '../../core/platform/platform.js';
910
import * as SDK from '../../core/sdk/sdk.js';
1011
import type * as Protocol from '../../generated/protocol.js';
1112
import * as UI from '../../ui/legacy/legacy.js';
@@ -18,21 +19,29 @@ import webAudioStyles from './webAudio.css.js';
1819
import {Events as ModelEvents, WebAudioModel} from './WebAudioModel.js';
1920

2021
const UIStrings = {
22+
/**
23+
*@description Text in Web Audio View if there is nothing to show.
24+
* Web Audio API is an API for controlling audio on the web.
25+
*/
26+
noWebAudio: 'No web audio API usage detected',
2127
/**
2228
*@description Text in Web Audio View
2329
*/
24-
openAPageThatUsesWebAudioApiTo: 'Open a page that uses Web Audio API to start monitoring.',
30+
openAPageThatUsesWebAudioApiTo: 'Open a page that uses web audio API to start monitoring.',
2531
};
2632
const str_ = i18n.i18n.registerUIStrings('panels/web_audio/WebAudioView.ts', UIStrings);
2733
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
2834

35+
const WEBAUDIO_EXPLANATION_URL =
36+
'https://developer.chrome.com/docs/devtools/webaudio' as Platform.DevToolsPath.UrlString;
37+
2938
export class WebAudioView extends UI.ThrottledWidget.ThrottledWidget implements
3039
SDK.TargetManager.SDKModelObserver<WebAudioModel> {
3140
private readonly contextSelector: AudioContextSelector;
3241
private readonly contentContainer: HTMLElement;
3342
private readonly detailViewContainer: HTMLElement;
3443
private graphManager: GraphVisualizer.GraphManager.GraphManager;
35-
private readonly landingPage: UI.Widget.VBox;
44+
private readonly landingPage: UI.EmptyWidget.EmptyWidget;
3645
private readonly summaryBarContainer: HTMLElement;
3746
constructor() {
3847
super(true, 1000);
@@ -60,13 +69,9 @@ export class WebAudioView extends UI.ThrottledWidget.ThrottledWidget implements
6069
this.graphManager = new GraphVisualizer.GraphManager.GraphManager();
6170

6271
// Creates the landing page.
63-
this.landingPage = new UI.Widget.VBox();
64-
this.landingPage.contentElement.classList.add('web-audio-landing-page', 'fill');
65-
this.landingPage.contentElement.appendChild(UI.Fragment.html`
66-
<div>
67-
<p>${i18nString(UIStrings.openAPageThatUsesWebAudioApiTo)}</p>
68-
</div>
69-
`);
72+
this.landingPage = new UI.EmptyWidget.EmptyWidget(
73+
i18nString(UIStrings.noWebAudio), i18nString(UIStrings.openAPageThatUsesWebAudioApiTo));
74+
this.landingPage.appendLink(WEBAUDIO_EXPLANATION_URL);
7075
this.landingPage.show(this.detailViewContainer);
7176

7277
// Creates the summary bar.

0 commit comments

Comments
 (0)