Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 1 | // 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 Franklin | e839c0c | 2022-05-03 08:47:44 | [diff] [blame^] | 5 | import { |
| 6 | assertNotNullOrUndefined, |
| 7 | click, |
| 8 | enableExperiment, |
| 9 | getBrowserAndPages, |
| 10 | goToResource, |
| 11 | waitForAria, |
| 12 | waitForNone, |
| 13 | } from '../../shared/helper.js'; |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 14 | import {describe, it} from '../../shared/mocha-extensions.js'; |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 15 | import {toggleAccessibilityTree} from '../helpers/elements-helpers.js'; |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 16 | |
| 17 | describe('Accessibility Tree in the Elements Tab', async function() { |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 18 | it('displays the fuller accessibility tree', async () => { |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 19 | await enableExperiment('fullAccessibilityTree'); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 20 | await goToResource('elements/accessibility-simple-page.html'); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 21 | await toggleAccessibilityTree(); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 22 | await waitForAria('heading\xa0"Title" [role="treeitem"]'); |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 23 | await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]'); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 24 | }); |
| 25 | |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 26 | it('allows navigating iframes', async () => { |
| 27 | await enableExperiment('fullAccessibilityTree'); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 28 | await goToResource('elements/accessibility-iframe-page.html'); |
| 29 | await toggleAccessibilityTree(); |
Tim van der Lippe | 2d9a95c | 2022-01-04 15:18:03 | [diff] [blame] | 30 | void waitForAria('RootWebArea\xa0"Page with nested iframe" [role="treeitem"]'); |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 31 | const iframeDoc = await waitForAria( |
| 32 | 'RootWebArea\xa0"Simple page with aria labeled element"\xa0focusable:\xa0true [role="treeitem"]'); |
| 33 | assertNotNullOrUndefined(iframeDoc); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 34 | await click('.arrow-icon', {root: iframeDoc}); |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 35 | await waitForAria('link\xa0"cats"\xa0focusable:\xa0true[role="treeitem"]'); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 36 | }); |
Johan Bay | afa5441 | 2021-08-18 11:52:48 | [diff] [blame] | 37 | |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 38 | it('listens for text changes to DOM and redraws the tree', async () => { |
| 39 | await enableExperiment('fullAccessibilityTree'); |
Johan Bay | afa5441 | 2021-08-18 11:52:48 | [diff] [blame] | 40 | await goToResource('elements/accessibility-simple-page.html'); |
Johan Bay | afa5441 | 2021-08-18 11:52:48 | [diff] [blame] | 41 | await toggleAccessibilityTree(); |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 42 | 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 Bay | afa5441 | 2021-08-18 11:52:48 | [diff] [blame] | 47 | (node as HTMLElement).innerText = 'dogs'; |
| 48 | }); |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 49 | await waitForAria('link\xa0"dogs"\xa0focusable:\xa0true[role="treeitem"]'); |
| 50 | }); |
| 51 | |
Johan Bay | 0941373 | 2021-12-20 11:01:39 | [diff] [blame] | 52 | it('listens for changes to properties and redraws tree', async () => { |
Johan Bay | 5741c98 | 2021-11-22 07:36:24 | [diff] [blame] | 53 | 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 Bay | afa5441 | 2021-08-18 11:52:48 | [diff] [blame] | 74 | }); |
Johan Bay | 0bda6bd | 2021-07-30 07:10:02 | [diff] [blame] | 75 | }); |