Commit 8015227b authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Runs the "on selection removed" notification test after layout and paint

The affected test would count the number of selection changed notifications and succeed if 4 notifications had been received.
This is brittle because the test was counting both the notifications that resulted from the setup method in addition to the test itself.
To exclude the selection changed notificationsfired from the setup method, the test is mmodified so that it runs after layout and paint.
R=aboxhall@chromium.org

Bug: 639340
Change-Id: I766138415f6d36042214eeba3ada02645f54dc44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601994Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658495}
parent 0bf3efea
<!DOCTYPE html> <!DOCTYPE html>
<script src="../resources/testharness.js"></script> <script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script> <script src="../resources/testharnessreport.js"></script>
<script src="../resources/run-after-layout-and-paint.js"></script>
<div id="textbox" role="textbox" contenteditable> <div id="textbox" role="textbox" contenteditable>
<p> <p>
...@@ -10,7 +11,6 @@ ...@@ -10,7 +11,6 @@
<script> <script>
setup(() => { setup(() => {
let textbox = document.getElementById('textbox');
textbox.focus(); textbox.focus();
let selectionRange = document.createRange(); let selectionRange = document.createRange();
selectionRange.selectNodeContents(textbox); selectionRange.selectNodeContents(textbox);
...@@ -18,20 +18,11 @@ ...@@ -18,20 +18,11 @@
getSelection().addRange(selectionRange); getSelection().addRange(selectionRange);
}); });
async_test((t) => { async_test_after_layout_and_paint((t) => {
let axRoot = accessibilityController.rootElement; let axRoot = accessibilityController.rootElement;
let selectionNotificationsCounter = 0;
axRoot.addNotificationListener(t.step_func((notification) => { axRoot.addNotificationListener(t.step_func((notification) => {
if (notification == 'SelectedTextChanged' || notification == 'DocumentSelectionChanged') if (notification == 'DocumentSelectionChanged') {
++selectionNotificationsCounter;
// A selection change notification should fire four times:
// 1. When the textbox receives focus.
// 2. When the selection in removed before it's set via getSelection().removeAllRanges().
// 3. When the selection is made.
// 4. When the selection is removed.
if (selectionNotificationsCounter == 4) {
axRoot.removeNotificationListener(); axRoot.removeNotificationListener();
assert_equals(axRoot.selectionAnchorObject, null, 'selectionAnchorObject'); assert_equals(axRoot.selectionAnchorObject, null, 'selectionAnchorObject');
assert_equals(axRoot.selectionAnchorOffset, -1, 'selectionAnchorOffset'); assert_equals(axRoot.selectionAnchorOffset, -1, 'selectionAnchorOffset');
......
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