| <!DOCTYPE HTML> |
| <html> |
| <body> |
| <script src="../resources/js-test-pre.js"></script> |
| |
| <img tabindex="0" id="svg-image" alt="interactive SVG" > |
| |
| <div id="console"></div> |
| <script> |
| |
| description("This test ensures that accessibility elements can be created out of what a remote SVG image defines.") |
| window.jsTestIsAsync = true; |
| |
| // Return the page's relative coordinates. If we rely on the x() or y() of the accessibility object, then |
| // accessibility transforms are applied that fail because there is no window available |
| function pageX(element) { |
| return element.clickPointX - element.width/2; |
| } |
| |
| function pageY(element) { |
| return element.clickPointY - element.height/2; |
| } |
| |
| function runAXTest() { |
| var container = accessibilityController.accessibleElementById("svg-image"); |
| |
| var x = pageX(container) - 1; |
| var y = pageY(container) - 1; |
| |
| debug("container location: (" + x + ", " + y + ")"); |
| |
| var face = container.childAtIndex(0); |
| debug('Face role: ' + face.role); |
| debug('Face label: ' + face.description); |
| debug('FaceX: ' + (pageX(face) - x)); |
| debug('FaceY: ' + Math.abs(pageY(face) - y)); |
| debug('<br>'); |
| |
| var eye = container.childAtIndex(1); |
| debug('Eye role: ' + eye.role); |
| debug('Eye label: ' + eye.description); |
| debug('EyeX: ' + (pageX(eye) - x)); |
| debug('EyeY: ' + Math.abs(pageY(eye) - y)); |
| debug('<br>'); |
| |
| var nose = container.childAtIndex(3); |
| debug('Nose role: ' + nose.role); |
| debug('Nose label: ' + nose.description); |
| debug('NoseX: ' + (pageX(nose) - x)); |
| debug('NoseY: ' + Math.abs(pageY(nose) - y)); |
| debug('<br>'); |
| |
| var mouth = container.childAtIndex(4); |
| debug('Mouth role: ' + mouth.role); |
| debug('Mouth label: ' + mouth.description); |
| debug('MouthX: ' + (pageX(mouth) - x)); |
| debug('MouthY: ' + Math.floor(Math.abs(pageY(mouth) - y))); |
| debug('<br>'); |
| |
| finishJSTest(); |
| } |
| |
| if (window.accessibilityController) { |
| document.getElementById("svg-image").addEventListener("load", runAXTest); |
| } |
| document.getElementById("svg-image").src = "resources/svg-face.svg"; |
| |
| </script> |
| |
| <script src="../resources/js-test-post.js"></script> |
| </body> |
| </html> |
| |