Commit 79d26a28 authored by Daniel Clark's avatar Daniel Clark Committed by Commit Bot

Fix null check preventing AXObjectCacheImpl from registering as popup document lifecycle observer

Fix the polarity on a couple of null checks that were preventing
AXObjectCacheImpl from registering as a lifecycle notification observer
for popup documents.  This failure to register was preventing AX focus
events from being fired when focus changed inside of a popup.

The week-picker-ax.html test was passing prematurely because of focus
events received when opening the popup, without validating that
additional events were fired when changing focus in the popup.  Update
that test to confirm that events are also fired for a focus change in
the popup itself.

There were a couple of analogous tests (date-picker-ax.html,
month-picker.html) that were deleted when we purged old date popup tests
in favor of new tests written for the new popup implementation
(crrev.com/c/1967608).  I don't see replacements for these in the new
tests, so this change also restores those tests, updates them for
the structure of the new form controls, and ensures that they are
checking that focus events are fired due to changes in the popups and
not just from events fired when the popups open.

Bug: 1022920
Change-Id: Ifbccaff74131031ab60d61a715475eecdca0a7a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2074815Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: Dan Clark <daniec@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#745325}
parent 4f133c58
......@@ -151,7 +151,7 @@ AXObject* AXObjectCacheImpl::Root() {
}
void AXObjectCacheImpl::InitializePopup(Document* document) {
if (!document || documents_.Contains(document) || document->View())
if (!document || documents_.Contains(document) || !document->View())
return;
documents_.insert(document);
......@@ -159,7 +159,7 @@ void AXObjectCacheImpl::InitializePopup(Document* document) {
}
void AXObjectCacheImpl::DisposePopup(Document* document) {
if (documents_.Contains(document) || document->View())
if (!documents_.Contains(document) || !document->View())
return;
document->View()->UnregisterFromLifecycleNotifications(this);
......
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../fast/forms/resources/common.js"></script>
<script src="../../../fast/forms/resources/picker-common.js"></script>
<script src="../../../fast/forms/calendar-picker/resources/calendar-picker-common.js"></script>
</head>
<body>
<input type="date" id="date1" value="2000-01-02">
<script>
async_test((t) => {
var markDirtyCounter = 0;
var focusCounter = 0;
var date1 = document.getElementById('date1');
openPicker(date1, () => {
assert_equals(focusCounter, 2, "Expected 2 Focus events from opening popup.");
assert_equals(markDirtyCounter, 3, "Expected 3 MarkDirty events from opening popup.");
console.log('Press right arrow to adjust date');
eventSender.keyDown('ArrowRight');
});
accessibilityController.setNotificationListener(function(axnode, type) {
if (type == 'Focus') {
console.log('Received Focus event: ' + accessibilityController.focusedElement.name.replace(/,/g, ''));
focusCounter++;
} else if (type == 'MarkDirty') {
console.log('Received MarkDirty event');
if (++markDirtyCounter == 4) {
assert_equals(date1.value, "2000-01-03", "Expected arrow key to change date");
console.log('Open the month switcher menu.');
setTimeout(() => { clickMonthPopupButton(); }, 0);
} else if (markDirtyCounter == 6) {
console.log('Highlighting 2000-02 in the month popup');
setTimeout(function() { eventSender.keyDown('ArrowRight'); }, 0);
} else if (markDirtyCounter == 8) {
console.log('Pressing enter to submit month switcher menu selection');
setTimeout(function() { eventSender.keyDown('Enter'); }, 0);
}
}
if (focusCounter == 7 && markDirtyCounter == 10) {
assert_equals(date1.value, "2000-02-03", "Submitting month switcher should have udpated control value");
t.done();
}
});
}, 'Tests that typing an arrow key and opening month switcher menu dispatches |Focus| and |MarkDirty| a11y events.');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../fast/forms/resources/common.js"></script>
<script src="../../../fast/forms/resources/picker-common.js"></script>
<script src="../../../fast/forms/calendar-picker/resources/calendar-picker-common.js"></script>
</head>
<body>
<input type="month" id="month1" value="2000-01">
<script>
async_test((t) => {
var markDirtyCounter = 0;
var focusCounter = 0;
accessibilityController.setNotificationListener(function(axnode, type) {
if (type == 'Focus') {
console.log('Focused: ' + accessibilityController.focusedElement.name.replace(/,/g, ''));
focusCounter++;
} else if (type == 'MarkDirty') {
console.log('Received MarkDirty');
markDirtyCounter++;
}
if (focusCounter == 3 && markDirtyCounter == 1) {
assert_equals(month1.value, "2000-05", "Arrow key in month picker should have changed value");
t.done();
}
});
var month1 = document.getElementById('month1');
function test1() {
assert_equals(focusCounter, 2, "Expected 2 Focus events from opening popup.");
assert_equals(markDirtyCounter, 1, "Expected 1 MarkDirty events from opening popup.");
eventSender.keyDown('ArrowDown');
}
openPicker(month1, test1);
}, 'Tests if typing an arrow key dispatches |Focus| and |MarkDirty| a11y events.');
</script>
</body>
</html>
......@@ -3,8 +3,8 @@
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../forms/resources/picker-common.js"></script>
<script src="resources/calendar-picker-common.js"></script>
<script src="../../../fast/forms/resources/picker-common.js"></script>
<script src="../../../fast/forms/calendar-picker/resources/calendar-picker-common.js"></script>
</head>
<body>
......@@ -21,22 +21,23 @@ async_test((t) => {
} else if (type == 'MarkDirty') {
console.log('Received MarkDirty');
markDirtyCounter++;
if (focusCounter == 2 && markDirtyCounter == 2) {
t.done();
}
}
if (focusCounter == 3 && markDirtyCounter == 4) {
t.done();
}
});
var week1 = document.getElementById('week1');
function test1() {
eventSender.keyDown('ArrowDown');
assert_equals(focusCounter, 2, "Expected 2 Focus events from opening picker");
assert_equals(markDirtyCounter, 3, "Expected 3 MarkDirty events from opening picker");
eventSender.keyDown('ArrowDown');
}
openPicker(week1, test1);
}, 'Tests if typing an arrow key dispatches |Focus| and |MarkDirty| a11y events.');
</script>
</body>
</html>
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