Skip to content

Commit

Permalink
[devtools] Import web tests from devtools-frontend repo
Browse files Browse the repository at this point in the history
When we moved DevTools to it's own repository we experimented with also
moving the DevTools related web tests. This turned out to be
infeasible as we would loose a great amount of coverage.

This CL imports the tests that are found only in devtools-frontend,
after which we can remove the web tests in DevTools.

Bug: 1393314
Change-Id: I9c6470ecb580fb3c67ef8d2e94a81513c0b92c1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4055875
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1075702}
  • Loading branch information
szuend authored and Chromium LUCI CQ committed Nov 25, 2022
1 parent d4d4959 commit 45df4c5
Show file tree
Hide file tree
Showing 80 changed files with 1,549 additions and 0 deletions.
@@ -0,0 +1,4 @@
Tests accessibility of AppManifestView on application panel.
aXe violations: []


@@ -0,0 +1,29 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
await TestRunner.loadTestModule('axe_core_test_runner');

TestRunner.addResult('Tests accessibility of AppManifestView on application panel.');
const manifest = `{
"name": "TestManifest",
"short_name": "TestManifest",
"display": "standalone",
"start_url": ".",
"background_color": "#fff123",
"theme_color": "#123fff",
"description": "A test manifest.",
"icons": [{
"src": "icon.png",
"sizes": "256x256",
"type": "image/png"
}]
}`;

await TestRunner.showPanel('resources');
const manifestView = UI.panels.resources.visibleView;
await manifestView.renderManifest('test_manifest', manifest, [], []);
await AxeCoreTestRunner.runValidation(manifestView.contentElement);
TestRunner.completeTest();
})();
@@ -0,0 +1,5 @@
Tests accessibility in the Storage view using the axe-core linter.
Storage view is visible: true
aXe violations: []


@@ -0,0 +1,32 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult('Tests accessibility in the Storage view using the axe-core linter.');
await TestRunner.loadTestModule('application_test_runner');
await TestRunner.loadTestModule('axe_core_test_runner');
await ApplicationTestRunner.resetState();
await TestRunner.showPanel('resources');
await UI.viewManager.showView('resources');

const parent = UI.panels.resources.sidebar.applicationTreeElement;
const storageElement = parent.children().find(child => child.title === 'Storage');
storageElement.select();
const storageView = UI.panels.resources.visibleView;
TestRunner.addResult('Storage view is visible: ' + ApplicationTestRunner.isStorageView(storageView));

async function writeArray() {
const array = Array(1).fill(0);
const mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
await new Promise(resolve => ApplicationTestRunner.createDatabase(mainFrameId, 'Database1', resolve));
await new Promise(
resolve => ApplicationTestRunner.createObjectStore(mainFrameId, 'Database1', 'Store1', 'id', true, resolve));
await new Promise(
resolve =>
ApplicationTestRunner.addIDBValue(mainFrameId, 'Database1', 'Store1', {key: 1, value: array}, '', resolve));
}

await writeArray();
await AxeCoreTestRunner.runValidation(storageView.contentElement);
TestRunner.completeTest();
})();
@@ -0,0 +1,4 @@
Tests accessibility of ServiceWorkersView on application panel.
aXe violations: []


@@ -0,0 +1,25 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
TestRunner.addResult('Tests accessibility of ServiceWorkersView on application panel.');
await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.loadTestModule('application_test_runner');
await ApplicationTestRunner.resetState();

await TestRunner.showPanel('resources');

const scriptURL = 'http://127.0.0.1:8000/devtools/service-workers/resources/service-worker-empty.js';
const scope1 = 'http://127.0.0.1:8000/devtools/service-workers/resources/scope1/';
const scope2 = 'http://127.0.0.1:8000/devtools/service-workers/resources/scope2/';
Resources.ServiceWorkersView.setThrottleDisabledForDebugging = true;

UI.panels.resources.sidebar.serviceWorkersTreeElement.select();
ApplicationTestRunner.registerServiceWorker(scriptURL, scope1);
ApplicationTestRunner.registerServiceWorker(scriptURL, scope2);
const element = UI.panels.resources.visibleView.contentElement;

await AxeCoreTestRunner.runValidation(element);
TestRunner.completeTest();
})();
@@ -0,0 +1,10 @@
Tests accessibility in the elements.domProperties view using the axe-core linter.
aXe violations: []

Tests accessibility in the performance.monitor view using the axe-core linter.
aXe violations: []

Tests accessibility in the sensors view using the axe-core linter.
aXe violations: []


@@ -0,0 +1,35 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
await TestRunner.loadTestModule('axe_core_test_runner');
const locationsToTest =
[
// elements
'elements.domProperties',
// Performance Monitor
'performance.monitor',
// Sensors
'sensors',
];

// TODO(crbug.com/1004940): exclude scrollable-region-focusable for performance.monitor only
const NO_SCROLLABLE_REGION_FOCUSABLE_RULESET = {
'scrollable-region-focusable': { enabled: false, },
};

for (const location of locationsToTest) {
await loadViewAndTestElementViolations(location);
}

TestRunner.completeTest();

async function loadViewAndTestElementViolations(view) {
TestRunner.addResult(`Tests accessibility in the ${view} view using the axe-core linter.`);
await UI.viewManager.showView(view);
const widget = await UI.viewManager.view(view).widget();
const ruleset = view === 'performance.monitor' ? NO_SCROLLABLE_REGION_FOCUSABLE_RULESET : {};
await AxeCoreTestRunner.runValidation(widget.element, ruleset);
}
})();
@@ -0,0 +1,6 @@
Tests accessibility in the Changes drawer.
Showing the Changes drawer.
Running aXe on the Changes drawer.
aXe violations: []


@@ -0,0 +1,26 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
TestRunner.addResult('Tests accessibility in the Changes drawer.');
await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.loadLegacyModule('changes');

const diff = [
{0: Diff.Diff.Operation.Insert, 1: ['line 1 inserted']},
{0: Diff.Diff.Operation.Delete, 1: ['line 2 deleted']},
];
const uiSourceCodeMock = {mimeType: () => {}};

TestRunner.addResult('Showing the Changes drawer.');
await UI.viewManager.showView('changes.changes');
const changesWidget = await UI.viewManager.view('changes.changes').widget();
changesWidget.selectedUISourceCode = uiSourceCodeMock;
changesWidget.renderDiffRows(diff);

TestRunner.addResult('Running aXe on the Changes drawer.');
await AxeCoreTestRunner.runValidation(changesWidget.contentElement);

TestRunner.completeTest();
})();
@@ -0,0 +1,4 @@
Tests accessibility in the console using the axe-core linter.
aXe violations: []


@@ -0,0 +1,15 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
await TestRunner.loadTestModule('axe_core_test_runner');
TestRunner.addResult(
'Tests accessibility in the console using the axe-core linter.');

await UI.viewManager.showView('console');
const widget = await UI.viewManager.view('console').widget();

await AxeCoreTestRunner.runValidation(widget.element);
TestRunner.completeTest();
})();
@@ -0,0 +1,5 @@
Tests accessibility in DOM breakpoints using the axe-core linter.
Test DOM breakpoint container with multiple breakpoints.
aXe violations: []


@@ -0,0 +1,27 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(
'Tests accessibility in DOM breakpoints using the axe-core linter.');

await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.loadTestModule('elements_test_runner');
await TestRunner.showPanel('elements');
UI.panels.elements.sidebarPaneView.tabbedPane().selectTab('elements.domBreakpoints', true);

await TestRunner.navigatePromise(
'../../sources/debugger-breakpoints/resources/dom-breakpoints.html');

const rootElement = await ElementsTestRunner.nodeWithIdPromise('rootElement');

// Add Dom breakpoints and then test
TestRunner.domDebuggerModel.setDOMBreakpoint(rootElement, Protocol.DOMDebugger.DOMBreakpointType.SubtreeModified);
TestRunner.domDebuggerModel.setDOMBreakpoint(rootElement, Protocol.DOMDebugger.DOMBreakpointType.AttributeModified);
TestRunner.addResult(
'Test DOM breakpoint container with multiple breakpoints.');

const widget = UI.panels.elements.sidebarPaneView.tabbedPane().visibleView;
await AxeCoreTestRunner.runValidation(widget.element);
TestRunner.completeTest();
})();
@@ -0,0 +1,8 @@
Tests accessibility in DOM eventlistener pane using axe-core linter.
Running the axe-core linter on tree element.
aXe violations: []

Running the axe-core linter on toolbar.
aXe violations: []


@@ -0,0 +1,33 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
// axe-core issue #1444 -- role="tree" requires children with role="treeitem",
// but it is reasonable to have trees with no leaves.
const NO_REQUIRED_CHILDREN_RULESET = {
'aria-required-children': {
enabled: false,
},
};
const DEFAULT_RULESET = { };

TestRunner.addResult(
'Tests accessibility in DOM eventlistener pane using axe-core linter.');

await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.loadTestModule('sources_test_runner');
const view = 'elements.eventListeners';
const widget = await UI.viewManager.view(view).widget();
await UI.viewManager.showView(view);

const treeElement = widget.element;
TestRunner.addResult('Running the axe-core linter on tree element.');
await AxeCoreTestRunner.runValidation(treeElement, NO_REQUIRED_CHILDREN_RULESET);

const toolbarElement = treeElement.parentElement.querySelector('.toolbar');
TestRunner.addResult('Running the axe-core linter on toolbar.');
await AxeCoreTestRunner.runValidation(toolbarElement, DEFAULT_RULESET);

TestRunner.completeTest();
})();
@@ -0,0 +1,21 @@

Running: testElementsDomTree
Tests accessibility in the DOM tree using the axe-core linter
aXe violations: []


Running: testElementsDomBreadcrumbs
Tests accessibility in the DOM breadcrumbs using the axe-core linter
aXe violations: []


Running: testElementsStylesPane
Tests accessibility of the Styles pane using the axe-core linter
aXe violations: []


Running: testElementsComputedStylesPane
Tests accessibility in the Computed Styles pane using the axe-core linter
aXe violations: []


@@ -0,0 +1,63 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
// axe-core issue #1444 -- role="tree" requires children with role="treeitem",
// but it is reasonable to have trees with no leaves.
const NO_REQUIRED_CHILDREN_RULESET = {
'aria-required-children': {
enabled: false,
},
};
const DEFAULT_RULESET = {};
await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.loadTestModule('elements_test_runner');
const tests = [
testElementsDomTree,
testElementsDomBreadcrumbs,
testElementsStylesPane,
testElementsComputedStylesPane,
];

async function testElementsDomTree() {
TestRunner.addResult('Tests accessibility in the DOM tree using the axe-core linter');
const view = 'elements';
await UI.viewManager.showView(view);
const widget = await UI.viewManager.view(view).widget();
const element = widget.element.querySelector('#elements-content');

await AxeCoreTestRunner.runValidation(element, NO_REQUIRED_CHILDREN_RULESET);
}

async function testElementsDomBreadcrumbs() {
TestRunner.addResult('Tests accessibility in the DOM breadcrumbs using the axe-core linter');
const view = 'elements';
await UI.viewManager.showView(view);
const widget = await UI.viewManager.view(view).widget();
const element = widget.element.querySelector('#elements-crumbs');

await AxeCoreTestRunner.runValidation(element, DEFAULT_RULESET);
}

async function testElementsStylesPane() {
TestRunner.addResult('Tests accessibility of the Styles pane using the axe-core linter');
await UI.viewManager.showView('elements');
const panel = Elements.ElementsPanel.instance();
const element = panel.stylesWidget.element;

await AxeCoreTestRunner.runValidation(element, NO_REQUIRED_CHILDREN_RULESET);
}

async function testElementsComputedStylesPane() {
TestRunner.addResult('Tests accessibility in the Computed Styles pane using the axe-core linter');
await UI.viewManager.showView('elements');
await ElementsTestRunner.showComputedStyles();
const panel = Elements.ElementsPanel.instance();
const element = panel.computedStyleWidget.element;

await AxeCoreTestRunner.runValidation(element, DEFAULT_RULESET);
}

TestRunner.runAsyncTestSuite(tests);
})();
@@ -0,0 +1,5 @@
Tests accessibility in the lighthouse start view using the axe-core linter.

aXe violations: []


@@ -0,0 +1,14 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(async function() {
TestRunner.addResult('Tests accessibility in the lighthouse start view using the axe-core linter.\n');
await TestRunner.loadTestModule('axe_core_test_runner');
await TestRunner.showPanel('lighthouse');

const widget = await UI.viewManager.view('lighthouse').widget();
await AxeCoreTestRunner.runValidation(widget.contentElement);

TestRunner.completeTest();
})();
@@ -0,0 +1,4 @@
Tests accessibility in heap profiler using the axe-core linter.
aXe violations: []


0 comments on commit 45df4c5

Please sign in to comment.