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

Unified Diff: LayoutTests/fast/svg/tabindex-focus.html

Issue 166163005: [SVG2] Add tabindex handling in svg. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/svg/custom/focus-ring-2.svg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/svg/tabindex-focus.html
diff --git a/LayoutTests/fast/svg/tabindex-focus.html b/LayoutTests/fast/svg/tabindex-focus.html
new file mode 100644
index 0000000000000000000000000000000000000000..f80ce72d29c776467448d0e11b5ec452cde6c35d
--- /dev/null
+++ b/LayoutTests/fast/svg/tabindex-focus.html
@@ -0,0 +1,205 @@
+<!doctype html>
+<title>Tabindex on svg elements tests</title>
+<script src=../../resources/testharness.js></script>
+<script src=../../resources/testharnessreport.js></script>
+<body>
+<div id="testcontainer"><svg id="testroot" width="1" height="1"/></div>
+<div id=log></div>
+<script>
+var svg = document.getElementById("testroot");
+function isFocusable(elm) {
+ switch (elm.nodeName) {
+ case "a":
+ return elm.hasAttributeNS("http://www.w3.org/1999/xlink", "href");
+ default:
+ return false;
+ }
+}
+function isFocusableWithTabindex(elm) {
+ switch (elm.nodeName) {
+ case "a":
+ case "circle":
+ case "ellipse":
+ case "foreignObject":
+ case "g":
+ case "image":
+ case "line":
+ case "path":
+ case "polygon":
+ case "polyline":
+ case "rect":
+ case "svg":
+ case "switch":
+ case "text":
+ return true;
+ case "textPath":
+ //case "tref": /* not supported */
+ case "tspan":
+ // only if inside a <text> element
+ return elm.parentNode.nodeName == "text";
+ case "use":
+ return true;
+ default:
+ return false;
+ }
+}
+function createSvg() {
+ var svgelements = [
+ "a",
+ "altGlyph",
+ "altGlyphDef",
+ "altGlyphItem",
+ "animate",
+ "animateColor",
+ "animateMotion",
+ "animateTransform",
+ "circle",
+ "clipPath",
+ "color-profile",
+ "cursor",
+ "definition-src",
+ "defs",
+ "desc",
+ "ellipse",
+ "feBlend",
+ "feColorMatrix",
+ "feComponentTransfer",
+ "feComposite",
+ "feConvolveMatrix",
+ "feDiffuseLighting",
+ "feDisplacementMap",
+ "feDistantLight",
+ "feFlood",
+ "feFuncA",
+ "feFuncB",
+ "feFuncG",
+ "feFuncR",
+ "feGaussianBlur",
+ "feImage",
+ "feMerge",
+ "feMergeNode",
+ "feMorphology",
+ "feOffset",
+ "fePointLight",
+ "feSpecularLighting",
+ "feSpotLight",
+ "feTile",
+ "feTurbulence",
+ "filter",
+ "font",
+ "font-face",
+ "font-face-format",
+ "font-face-name",
+ "font-face-src",
+ "font-face-uri",
+ "foreignObject",
+ "g",
+ "glyph",
+ "glyphRef",
+ "hkern",
+ "image",
+ "line",
+ "linearGradient",
+ "marker",
+ "mask",
+ "metadata",
+ "missing-glyph",
+ "mpath",
+ "path",
+ "pattern",
+ "polygon",
+ "polyline",
+ "radialGradient",
+ "rect",
+ "script",
+ "set",
+ "stop",
+ "style",
+ "svg",
+ "switch",
+ "symbol",
+ "text",
+ "textPath",
+ "title",
+ "tref",
+ "tspan",
+ "use",
+ "view",
+ "vkern"];
+ for (var i = 0; i < svgelements.length; i++) {
+ svg.appendChild(document.createElementNS("http://www.w3.org/2000/svg", svgelements[i]));
+ }
+}
+
+function setupTextContentElements() {
+ // specialcases for the text content elements
+
+ // cleanup any old content
+ while(svg.firstChild)
+ svg.removeChild(svg.firstChild);
+
+ var textContentChildElements = ["textPath", "tref", "tspan"];
+ for (var i = 0; i < textContentChildElements.length; i++) {
+ var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
+ text.appendChild(document.createElementNS("http://www.w3.org/2000/svg", textContentChildElements[i]));
+ svg.appendChild(text);
+ }
+}
+
+setup(createSvg);
+var element = svg.firstElementChild;
+while(element) {
+ test(function() {
+ try {
+ element.focus();
+ assert_equals(document.activeElement, isFocusable(element) ? element : document.body);
+ }
+ finally {
+ document.body.focus();
+ }
+ }, element.nodeName + ".focus() without tabindex set.");
+ test(function() {
+ try {
+ element.setAttribute("tabindex", "1");
+ element.focus();
+ assert_equals(document.activeElement, isFocusableWithTabindex(element) ? element : document.body);
+ element.removeAttribute("tabindex");
+ }
+ finally {
+ document.body.focus();
+ }
+ }, element.nodeName + ".focus() with tabindex set.");
+
+ element.parentNode.removeChild(element);
+ element = svg.firstElementChild;
+}
+
+setupTextContentElements();
+var element = svg.firstElementChild;
+while(element) {
+ test(function() {
+ try {
+ element.firstElementChild.focus();
+ assert_equals(document.activeElement, isFocusable(element.firstElementChild) ? element.firstElementChild : document.body);
+ }
+ finally {
+ document.body.focus();
+ }
+ }, element.firstElementChild.nodeName + ".focus() without tabindex set.");
+ test(function() {
+ try {
+ element.firstElementChild.setAttribute("tabindex", "1");
+ element.firstElementChild.focus();
+ assert_equals(document.activeElement, isFocusableWithTabindex(element.firstElementChild) ? element.firstElementChild : document.body);
+ element.firstElementChild.removeAttribute("tabindex");
+ }
+ finally {
+ document.body.focus();
+ }
+ }, element.firstElementChild.nodeName + ".focus() with tabindex set.");
+
+ element.parentNode.removeChild(element);
+ element = svg.firstElementChild;
+}
+</script>
+</body>
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/svg/custom/focus-ring-2.svg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698