Skip to content

Commit 56c3499

Browse files
szuendDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[e2e] Migrate DOM warnings browsertest to e2e
The C++ browser tests are flaky enough that this simple test got disabled. Lets move it to our repo as an e2e. R=alexrudenko@chromium.org Bug: 331650494, 40694796 Change-Id: Ic91b922420160befe639546a654dfca3f9df8986 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6434120 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org>
1 parent 45aeb90 commit 56c3499

File tree

6 files changed

+49
-8
lines changed

6 files changed

+49
-8
lines changed

test/e2e/helpers/console-helpers.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,22 @@ export async function getConsoleMessages(testName: string, withAnchor = false, c
121121
return await getCurrentConsoleMessages(withAnchor, Level.All, callback);
122122
}
123123

124-
export async function getCurrentConsoleMessages(withAnchor = false, level = Level.All, callback?: () => Promise<void>) {
125-
const {frontend} = getBrowserAndPages();
124+
export async function getCurrentConsoleMessages(
125+
withAnchor = false, level = Level.All, callback?: () => Promise<void>, devToolsPage?: DevToolsPage) {
126+
devToolsPage = devToolsPage || getBrowserAndPagesWrappers().devToolsPage;
126127
const asyncScope = new AsyncScope();
127128

128-
await navigateToConsoleTab();
129+
await navigateToConsoleTab(devToolsPage);
129130

130131
// Get console messages that were logged.
131-
await waitFor(CONSOLE_MESSAGES_SELECTOR, undefined, asyncScope);
132+
await devToolsPage.waitFor(CONSOLE_MESSAGES_SELECTOR, undefined, asyncScope);
132133

133134
if (callback) {
134135
await callback();
135136
}
136137

137138
// Ensure all messages are populated.
138-
await asyncScope.exec(() => frontend.waitForFunction((selector: string) => {
139+
await asyncScope.exec(() => devToolsPage.page.waitForFunction((selector: string) => {
139140
const messages = document.querySelectorAll(selector);
140141
if (messages.length === 0) {
141142
return false;
@@ -146,12 +147,12 @@ export async function getCurrentConsoleMessages(withAnchor = false, level = Leve
146147
const selector = withAnchor ? CONSOLE_MESSAGE_TEXT_AND_ANCHOR_SELECTOR : level;
147148

148149
// FIXME(crbug/1112692): Refactor test to remove the timeout.
149-
await timeout(100);
150+
await devToolsPage.timeout(100);
150151

151-
await expectVeEvents([veImpressionForConsoleMessage()], await veRoot());
152+
await expectVeEvents([veImpressionForConsoleMessage()], await veRoot(devToolsPage), devToolsPage);
152153

153154
// Get the messages from the console.
154-
return await frontend.evaluate(selector => {
155+
return await devToolsPage.page.evaluate(selector => {
155156
return Array.from(document.querySelectorAll(selector)).map(message => message.textContent as string);
156157
}, selector);
157158
}

test/e2e/resources/console/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ copy_to_gen("console") {
2020
"data-url-exceptions.html",
2121
"document-write.html",
2222
"dom-interactions.html",
23+
"dom-warnings.html",
2324
"error-with-async-frame.html",
2425
"escaping.html",
2526
"focus-interaction.html",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<body>
3+
<form>
4+
<input id="dup" type="text" autocomplete="username">
5+
<input id="dup" type="password" autocomplete="current-password">
6+
</form>
7+
</body>

test/e2e_non_hosted/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ node_ts_library("tests") {
1616
deps = [
1717
"../conductor:implementation",
1818
"assertion",
19+
"console",
1920
"elements",
2021
"performance",
2122
"sources",

test/e2e_non_hosted/console/BUILD.gn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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("../../../scripts/build/typescript/typescript.gni")
6+
7+
ts_e2e_library("console") {
8+
sources = [ "dom-warnings_test.ts" ]
9+
deps = [ "../../e2e/helpers" ]
10+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 {assert} from 'chai';
6+
7+
import {getCurrentConsoleMessages, Level, navigateToConsoleTab} from '../../e2e/helpers/console-helpers.js';
8+
9+
describe('console', () => {
10+
// Migrated devtools_browsertest.
11+
it('shows DOM warnings', async ({devToolsPage, inspectedPage}) => {
12+
await Promise.all([
13+
inspectedPage.goToResource('console/dom-warnings.html'),
14+
navigateToConsoleTab(devToolsPage),
15+
]);
16+
17+
const messages = await getCurrentConsoleMessages(/* withAnchor */ false, Level.All, undefined, devToolsPage);
18+
19+
assert.include(messages[0], '[DOM] Found 2 elements with non-unique id #dup');
20+
});
21+
});

0 commit comments

Comments
 (0)