diff options
Diffstat (limited to 'accessible/tests/browser/windows/uia/browser_simplePatterns.js')
-rw-r--r-- | accessible/tests/browser/windows/uia/browser_simplePatterns.js | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/accessible/tests/browser/windows/uia/browser_simplePatterns.js b/accessible/tests/browser/windows/uia/browser_simplePatterns.js index f464db0e13..484d217af2 100644 --- a/accessible/tests/browser/windows/uia/browser_simplePatterns.js +++ b/accessible/tests/browser/windows/uia/browser_simplePatterns.js @@ -27,6 +27,7 @@ addUiaTask( <button id="button">button</button> <p id="p">p</p> <input id="checkbox" type="checkbox"> +<input id="radio" type="radio"> `, async function testInvoke() { await definePyVar("doc", `getDocUia()`); @@ -54,6 +55,8 @@ addUiaTask( // Check boxes expose the Toggle pattern, so they should not expose the // Invoke pattern. await testPatternAbsent("checkbox", "Invoke"); + // Ditto for radio buttons. + await testPatternAbsent("radio", "Invoke"); } } ); @@ -317,6 +320,7 @@ addUiaTask( await setUpWaitForUiaPropEvent("ValueValue", "text"); await runPython(`pattern.SetValue("after")`); await waitForUiaEvent(); + ok(true, "Got ValueValue prop change event on text"); is( await runPython(`pattern.CurrentValue`), "after", @@ -434,6 +438,7 @@ addUiaTask( await setUpWaitForUiaPropEvent("ValueValue", "ariaTextbox"); await runPython(`pattern.SetValue("after")`); await waitForUiaEvent(); + ok(true, "Got ValueValue prop change event on ariaTextbox"); is( await runPython(`pattern.CurrentValue`), "after", @@ -443,3 +448,95 @@ addUiaTask( await testPatternAbsent("button", "Value"); } ); + +async function testRangeValueProps(id, ro, val, min, max, small, large) { + await assignPyVarToUiaWithId(id); + await definePyVar("pattern", `getUiaPattern(${id}, "RangeValue")`); + ok(await runPython(`bool(pattern)`), `${id} has RangeValue pattern`); + is( + !!(await runPython(`pattern.CurrentIsReadOnly`)), + ro, + `${id} has IsReadOnly ${ro}` + ); + is(await runPython(`pattern.CurrentValue`), val, `${id} has correct Value`); + is( + await runPython(`pattern.CurrentMinimum`), + min, + `${id} has correct Minimum` + ); + is( + await runPython(`pattern.CurrentMaximum`), + max, + `${id} has correct Maximum` + ); + // IA2 doesn't support small/large change, so the IA2 -> UIA proxy can't + // either. + if (gIsUiaEnabled) { + is( + await runPython(`pattern.CurrentSmallChange`), + small, + `${id} has correct SmallChange` + ); + is( + await runPython(`pattern.CurrentLargeChange`), + large, + `${id} has correct LargeChange` + ); + } +} + +/** + * Test the RangeValue pattern. + */ +addUiaTask( + ` +<input id="range" type="range"> +<input id="rangeBig" type="range" max="1000"> +<progress id="progress" value="0.5"></progress> +<input id="numberRo" type="number" min="0" max="10" value="5" readonly> +<div id="ariaSlider" role="slider">slider</div> +<button id="button">button</button> + `, + async function testRangeValue(browser) { + await definePyVar("doc", `getDocUia()`); + await testRangeValueProps("range", false, 50, 0, 100, 1, 10); + info("SetValue on range"); + await setUpWaitForUiaPropEvent("RangeValueValue", "range"); + await runPython(`pattern.SetValue(20)`); + await waitForUiaEvent(); + ok(true, "Got RangeValueValue prop change event on range"); + is(await runPython(`pattern.CurrentValue`), 20, "range has correct Value"); + + await testRangeValueProps("rangeBig", false, 500, 0, 1000, 1, 100); + + // Gecko a11y doesn't expose progress bars as read only, but it probably + // should. + await testRangeValueProps("progress", false, 0.5, 0, 1, 0, 0.1); + info("Calling SetValue on progress"); + await testPythonRaises( + `pattern.SetValue(0.6)`, + "SetValue on progress failed" + ); + + await testRangeValueProps("numberRo", true, 5, 0, 10, 1, 1); + info("Calling SetValue on numberRo"); + await testPythonRaises( + `pattern.SetValue(6)`, + "SetValue on numberRo failed" + ); + + await testRangeValueProps("ariaSlider", false, 50, 0, 100, null, null); + info("Setting aria-valuenow on ariaSlider"); + await setUpWaitForUiaPropEvent("RangeValueValue", "ariaSlider"); + await invokeSetAttribute(browser, "ariaSlider", "aria-valuenow", "60"); + await waitForUiaEvent(); + ok(true, "Got RangeValueValue prop change event on ariaSlider"); + is( + await runPython(`pattern.CurrentValue`), + 60, + "ariaSlider has correct Value" + ); + + await testPatternAbsent("button", "RangeValue"); + } +); |