From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../browser/states/browser_test_visibility.js | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 accessible/tests/browser/states/browser_test_visibility.js (limited to 'accessible/tests/browser/states/browser_test_visibility.js') diff --git a/accessible/tests/browser/states/browser_test_visibility.js b/accessible/tests/browser/states/browser_test_visibility.js new file mode 100644 index 0000000000..25bd903ed4 --- /dev/null +++ b/accessible/tests/browser/states/browser_test_visibility.js @@ -0,0 +1,181 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +async function runTest(browser, accDoc) { + let getAcc = id => findAccessibleChildByID(accDoc, id); + + await untilCacheOk( + () => testVisibility(getAcc("div"), false, false), + "Div should be on screen" + ); + + let input = getAcc("input_scrolledoff"); + await untilCacheOk( + () => testVisibility(input, true, false), + "Input should be offscreen" + ); + + // scrolled off item (twice) + let lastLi = getAcc("li_last"); + await untilCacheOk( + () => testVisibility(lastLi, true, false), + "Last list item should be offscreen" + ); + + // scroll into view the item + await invokeContentTask(browser, [], () => { + content.document.getElementById("li_last").scrollIntoView(true); + }); + await untilCacheOk( + () => testVisibility(lastLi, false, false), + "Last list item should no longer be offscreen" + ); + + // first item is scrolled off now (testcase for bug 768786) + let firstLi = getAcc("li_first"); + await untilCacheOk( + () => testVisibility(firstLi, true, false), + "First listitem should now be offscreen" + ); + + await untilCacheOk( + () => testVisibility(getAcc("frame"), false, false), + "iframe should initially be onscreen" + ); + + let loaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, "iframeDoc"); + await invokeContentTask(browser, [], () => { + content.document.querySelector("iframe").src = + 'data:text/html,

hi

'; + }); + + const iframeDoc = (await loaded).accessible; + await untilCacheOk( + () => testVisibility(getAcc("frame"), false, false), + "iframe outer doc should now be on screen" + ); + await untilCacheOk( + () => testVisibility(iframeDoc, false, false), + "iframe inner doc should be on screen" + ); + const iframeP = findAccessibleChildByID(iframeDoc, "p"); + await untilCacheOk( + () => testVisibility(iframeP, false, false), + "iframe content should also be on screen" + ); + + // scroll into view the div + await invokeContentTask(browser, [], () => { + content.document.getElementById("div").scrollIntoView(true); + }); + + await untilCacheOk( + () => testVisibility(getAcc("frame"), true, false), + "iframe outer doc should now be off screen" + ); + await untilCacheOk( + () => testVisibility(iframeDoc, true, false), + "iframe inner doc should now be off screen" + ); + await untilCacheOk( + () => testVisibility(iframeP, true, false), + "iframe content should now be off screen" + ); + + let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser); + // Accessibles in background tab should have offscreen state and no + // invisible state. + await untilCacheOk( + () => testVisibility(getAcc("div"), true, false), + "Accs in background tab should be offscreen but not invisible." + ); + + await untilCacheOk( + () => testVisibility(getAcc("frame"), true, false), + "iframe outer doc should still be off screen" + ); + await untilCacheOk( + () => testVisibility(iframeDoc, true, false), + "iframe inner doc should still be off screen" + ); + await untilCacheOk( + () => testVisibility(iframeP, true, false), + "iframe content should still be off screen" + ); + + BrowserTestUtils.removeTab(newTab); +} + +addAccessibleTask( + ` +
+ + + + `, + runTest, + { iframe: true, remoteIframe: true } +); + +/** + * Test div containers are reported as onscreen, even if some of their contents are + * offscreen. + */ +addAccessibleTask( + ` +
on screen
offscreen
+ `, + async function (browser, accDoc) { + const outer = findAccessibleChildByID(accDoc, "outer"); + const inner = findAccessibleChildByID(accDoc, "inner"); + const on = findAccessibleChildByID(accDoc, "on"); + const off = findAccessibleChildByID(accDoc, "off"); + + await untilCacheOk( + () => testVisibility(outer, false, false), + "outer should be on screen and visible" + ); + await untilCacheOk( + () => testVisibility(inner, false, false), + "inner should be on screen and visible" + ); + await untilCacheOk( + () => testVisibility(on, false, false), + "on should be on screen and visible" + ); + await untilCacheOk( + () => testVisibility(off, true, false), + "off should be off screen and visible" + ); + }, + { chrome: true, iframe: true, remoteIframe: true } +); + +// test dynamic translation +addAccessibleTask( + `
Hello
`, + async function (browser, accDoc) { + const container = findAccessibleChildByID(accDoc, "container"); + await untilCacheOk( + () => testVisibility(container, true, false), + "container should be off screen and visible" + ); + await invokeContentTask(browser, [], () => { + let b = content.document.getElementById("b"); + b.click(); + }); + + await waitForContentPaint(browser); + await untilCacheOk( + () => testVisibility(container, false, false), + "container should be on screen and visible" + ); + }, + { chrome: true, iframe: true, remoteIframe: true } +); -- cgit v1.2.3