Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: third_party/WebKit/LayoutTests/accessibility/aom.html

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/accessibility/aom.html
diff --git a/third_party/WebKit/LayoutTests/accessibility/aom.html b/third_party/WebKit/LayoutTests/accessibility/aom.html
new file mode 100644
index 0000000000000000000000000000000000000000..8179eea24602a71c746ed3035a368bf30e3ac226
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/accessibility/aom.html
@@ -0,0 +1,105 @@
+<!DOCTYPE HTML>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<!--
+
+Accessibility Object Model
+Explainer: https://github.com/WICG/aom/blob/master/explainer.md
+Spec: https://wicg.github.io/aom/spec/
+
+-->
+
+<button id="button">Click Me</button>
+
+<script>
+if (window.internals)
+ internals.runtimeFlags.accessibilityObjectModelEnabled = true;
+
+test(function(t) {
aboxhall 2017/03/16 05:49:33 I imagine we'll want to split these out into separ
dmazzoni 2017/03/16 20:43:13 Agreed. For now it's simpler to have them in one p
+ var button = document.getElementById("button");
+ assert_true(button.nodeType == 1); // ELEMENT
aboxhall 2017/03/16 05:49:33 Why not just use Node.ELEMENT_NODE ? Also, could u
dmazzoni 2017/03/16 20:43:12 Done.
+ assert_true(button.accessibleNode != null);
+}, "DOM Elements have an AccessibleNode");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var staticText = button.firstChild;
+ assert_true(staticText.nodeType == 3); // TEXT
aboxhall 2017/03/16 05:49:33 Node.TEXT_NODE
dmazzoni 2017/03/16 20:43:12 Done.
+ assert_false(staticText.accessibleNode != null);
+}, "DOM Text nodes do not have an AccessibleNode.");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+
+ assert_true(aomButton.role === null);
+ assert_true(aomButton.label === null);
+ assert_true(aomButton.foo === undefined);
+ assert_true(aomButton.bar === undefined);
+}, "Supported properties on an AccessibleNode are all null by default");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+ var axButton = accessibilityController.accessibleElementById("button");
+
+ button.setAttribute("role", "checkbox");
+ button.setAttribute("aria-label", "Check Me");
+
+ assert_equals(axButton.role, "AXRole: AXCheckBox");
+ assert_equals(axButton.name, "Check Me");
+
+ assert_true(aomButton.role === null);
+ assert_true(aomButton.label === null);
+}, "AccessibleNode does not reflect ARIA attributes.");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+ var axButton = accessibilityController.accessibleElementById("button");
+
+ aomButton.role = "slider";
+ assert_equals(aomButton.role, "slider");
+ assert_equals(axButton.role, "AXRole: AXSlider");
+}, "Test setting AccessibleNode.role");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+ var axButton = accessibilityController.accessibleElementById("button");
+
+ button.removeAttribute("role");
+ aomButton.role = null;
+ assert_true(aomButton.role === null);
+ assert_equals(axButton.role, "AXRole: AXButton");
+
+ aomButton.role = "doctor";
+ assert_true(aomButton.role === null);
+ assert_equals(axButton.role, "AXRole: AXButton");
+}, "An invalid role should be ignored.");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+ var axButton = accessibilityController.accessibleElementById("button");
+
+ aomButton.role = "switch checkbox";
+ assert_equals(aomButton.role, "switch checkbox");
+ assert_equals(axButton.role, "AXRole: AXSwitch");
+
+ aomButton.role = "tickbox checkbox";
+ assert_equals(aomButton.role, "tickbox checkbox");
+ assert_equals(axButton.role, "AXRole: AXCheckBox");
+}, "Fallback roles are supported.");
+
+test(function(t) {
+ var button = document.getElementById("button");
+ var aomButton = button.accessibleNode;
+ var axButton = accessibilityController.accessibleElementById("button");
+
+ aomButton.label = "New Label";
+ assert_equals(aomButton.label, "New Label");
+ assert_equals(axButton.name, "New Label");
+}, "Test setting AccessibleNode.label");
+</script>
aboxhall 2017/03/16 05:49:33 Do we want a test asserting the precedence order o
dmazzoni 2017/03/16 20:43:11 The tests were kind of doing that implicitly. I a

Powered by Google App Engine
This is Rietveld 408576698