Commit 69c407cd authored by Anubha Mathur's avatar Anubha Mathur Committed by Commit Bot

DevTools: Add websql-console-a11y-test

Adds a layout test to validate accessibility in DatabaseQueryView (i.e. WebSQL console in Application panel)
Change goes along with - https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1974461


Bug: 963183
Change-Id: I7666a3ca14f446a65337d95f9c0bb0e047d4d589
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713810Reviewed-by: default avatarRobert Paveza <Rob.Paveza@microsoft.com>
Commit-Queue: Anubha Mathur <anubmat@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#728031}
parent 46947736
// 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 WebSQL console in application panel.`);
await TestRunner.loadModule('axe_core_test_runner');
await TestRunner.loadModule('application_test_runner');
// Note: every test that uses a storage API must manually clean-up state from previous tests.
await ApplicationTestRunner.resetState();
await TestRunner.showPanel('resources');
async function setPromptText(text) {
queryView._prompt.setText(text);
await queryView._enterKeyPressed(new KeyboardEvent('keydown'));
}
UI.viewManager.showView('resources');
await TestRunner.evaluateInPagePromise(
'openDatabase("inspector-test-db", "1.0", "Database for inspector test", 1024*1024)');
const parent = UI.panels.resources._sidebar._sidebarTree.rootElement();
const databaseElement = ApplicationTestRunner.findTreeElement(parent, ['Storage', 'Web SQL', 'inspector-test-db']);
databaseElement.select();
const queryView = UI.panels.resources.visibleView;
await setPromptText('CREATE TABLE table1 (id INTEGER PRIMARY KEY ASC, text_field TEXT)');
await setPromptText('INSERT INTO table1 (id, text_field) VALUES (1, "foobar")');
await setPromptText('SELECT * FROM table1');
await setPromptText('invalid input');
await AxeCoreTestRunner.runValidation(queryView.element);
TestRunner.completeTest();
})();
\ No newline at end of file
......@@ -29,16 +29,6 @@
dump(UI.panels.resources._sidebar._sidebarTree.rootElement(), '');
}
function findTreeElement(parent, path) {
if (path.length === 0)
return parent;
var child = parent.children().find(child => child.title === path[0]);
if (!child)
return null;
child.expand();
return findTreeElement(child, path.slice(1));
}
async function createTable(queryView) {
queryView._prompt.setText('CREATE TABLE table1 (id INTEGER PRIMARY KEY ASC, text_field TEXT)');
queryView._enterKeyPressed(new KeyboardEvent('keydown'));
......@@ -52,7 +42,7 @@
'openDatabase("inspector-test-db", "1.0", "Database for inspector test", 1024*1024)');
var parent = UI.panels.resources._sidebar._sidebarTree.rootElement();
var databaseElement = findTreeElement(parent, ['Storage', 'Web SQL', 'inspector-test-db']);
var databaseElement = ApplicationTestRunner.findTreeElement(parent, ['Storage', 'Web SQL', 'inspector-test-db']);
TestRunner.addResult('Found: ' + !!databaseElement);
......@@ -69,7 +59,7 @@
}
await createTable(queryView);
while (!findTreeElement(databaseElement, ['table1'])) {
while (!ApplicationTestRunner.findTreeElement(databaseElement, ['table1'])) {
databaseElement.expand();
await new Promise(resolve => setTimeout(resolve));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment