blob: a2974d9a30952c26ac27a112df92b0f7f46e5f9d [file] [log] [blame]
Johan Bay0bda6bd2021-07-30 07:10:021// Copyright 2021 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
Jack Frankline839c0c2022-05-03 08:47:445import {
6 assertNotNullOrUndefined,
7 click,
8 enableExperiment,
9 getBrowserAndPages,
10 goToResource,
11 waitForAria,
12 waitForNone,
13} from '../../shared/helper.js';
Johan Bay0bda6bd2021-07-30 07:10:0214import {describe, it} from '../../shared/mocha-extensions.js';
Johan Bay5741c982021-11-22 07:36:2415import {toggleAccessibilityTree} from '../helpers/elements-helpers.js';
Johan Bay0bda6bd2021-07-30 07:10:0216
17describe('Accessibility Tree in the Elements Tab', async function() {
Johan Bay0bda6bd2021-07-30 07:10:0218 it('displays the fuller accessibility tree', async () => {
Johan Bay5741c982021-11-22 07:36:2419 await enableExperiment('fullAccessibilityTree');
Johan Bay0bda6bd2021-07-30 07:10:0220 await goToResource('elements/accessibility-simple-page.html');
Johan Bay0bda6bd2021-07-30 07:10:0221 await toggleAccessibilityTree();
Johan Bay0bda6bd2021-07-30 07:10:0222 await waitForAria('heading\xa0"Title" [role="treeitem"]');
Johan Bay5741c982021-11-22 07:36:2423 await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]');
Johan Bay0bda6bd2021-07-30 07:10:0224 });
25
Johan Bay5741c982021-11-22 07:36:2426 it('allows navigating iframes', async () => {
27 await enableExperiment('fullAccessibilityTree');
Johan Bay0bda6bd2021-07-30 07:10:0228 await goToResource('elements/accessibility-iframe-page.html');
29 await toggleAccessibilityTree();
Tim van der Lippe2d9a95c2022-01-04 15:18:0330 void waitForAria('RootWebArea\xa0"Page with nested iframe" [role="treeitem"]');
Johan Bay5741c982021-11-22 07:36:2431 const iframeDoc = await waitForAria(
32 'RootWebArea\xa0"Simple page with aria labeled element"\xa0focusable:\xa0true [role="treeitem"]');
33 assertNotNullOrUndefined(iframeDoc);
Johan Bay0bda6bd2021-07-30 07:10:0234 await click('.arrow-icon', {root: iframeDoc});
Johan Bay5741c982021-11-22 07:36:2435 await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]');
Johan Bay0bda6bd2021-07-30 07:10:0236 });
Johan Bayafa54412021-08-18 11:52:4837
Johan Bay5741c982021-11-22 07:36:2438 it('listens for text changes to DOM and redraws the tree', async () => {
39 await enableExperiment('fullAccessibilityTree');
Johan Bayafa54412021-08-18 11:52:4840 await goToResource('elements/accessibility-simple-page.html');
Johan Bayafa54412021-08-18 11:52:4841 await toggleAccessibilityTree();
Johan Bay5741c982021-11-22 07:36:2442 const {target} = getBrowserAndPages();
43 await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]');
44 const link = await target.waitForSelector('aria/cats [role="link"]');
45 assertNotNullOrUndefined(link);
46 await link.evaluate(node => {
Johan Bayafa54412021-08-18 11:52:4847 (node as HTMLElement).innerText = 'dogs';
48 });
Johan Bay5741c982021-11-22 07:36:2449 await waitForAria('link\xa0"dogs"\xa0focusable:\xa0true[role="treeitem"]');
50 });
51
Johan Bay09413732021-12-20 11:01:3952 it('listens for changes to properties and redraws tree', async () => {
Johan Bay5741c982021-11-22 07:36:2453 await enableExperiment('fullAccessibilityTree');
54 await goToResource('elements/accessibility-simple-page.html');
55 await toggleAccessibilityTree();
56 const {target} = getBrowserAndPages();
57 const link = await target.waitForSelector('aria/cats [role="link"]');
58 assertNotNullOrUndefined(link);
59 await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]');
60 await link.evaluate(node => node.setAttribute('aria-label', 'birds'));
61 await waitForAria('link\xa0"birds"\xa0focusable:\xa0true[role="treeitem"]');
62 });
63
64 it('listen for removed nodes and redraw tree', async () => {
65 await enableExperiment('fullAccessibilityTree');
66 await goToResource('elements/accessibility-simple-page.html');
67 await toggleAccessibilityTree();
68 const {target} = getBrowserAndPages();
69 const link = await target.waitForSelector('aria/cats [role="link"]');
70 assertNotNullOrUndefined(link);
71 await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]');
72 await link.evaluate(node => node.remove());
73 await waitForNone('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]', undefined, undefined, 'aria');
Johan Bayafa54412021-08-18 11:52:4874 });
Johan Bay0bda6bd2021-07-30 07:10:0275});