Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=429659 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>nsIAccessibleImage chrome tests</title> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="common.js"></script> |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="role.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="attributes.js"></script> |
michael@0 | 19 | |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | function testCoordinates(aID, aAcc, aWidth, aHeight) |
michael@0 | 22 | { |
michael@0 | 23 | var screenX = {}, screenY = {}, windowX = {}, windowY = {}, parentX = {}, |
michael@0 | 24 | parentY = {}; |
michael@0 | 25 | |
michael@0 | 26 | // get screen coordinates. |
michael@0 | 27 | aAcc.getImagePosition( |
michael@0 | 28 | nsIAccessibleCoordinateType.COORDTYPE_SCREEN_RELATIVE, |
michael@0 | 29 | screenX, screenY); |
michael@0 | 30 | // get window coordinates. |
michael@0 | 31 | aAcc.getImagePosition( |
michael@0 | 32 | nsIAccessibleCoordinateType.COORDTYPE_WINDOW_RELATIVE, |
michael@0 | 33 | windowX, windowY); |
michael@0 | 34 | // get parent related coordinates. |
michael@0 | 35 | aAcc.getImagePosition( |
michael@0 | 36 | nsIAccessibleCoordinateType.COORDTYPE_PARENT_RELATIVE, |
michael@0 | 37 | parentX, parentY); |
michael@0 | 38 | // XXX For linked images, a negative parentY value is returned, and the |
michael@0 | 39 | // screenY coordinate is the link's screenY coordinate minus 1. |
michael@0 | 40 | // Until this is fixed, set parentY to -1 if it's negative. |
michael@0 | 41 | if (parentY.value < 0) |
michael@0 | 42 | parentY.value = -1; |
michael@0 | 43 | |
michael@0 | 44 | // See if asking image for child at image's screen coordinates gives |
michael@0 | 45 | // correct accessible. getChildAtPoint operates on screen coordinates. |
michael@0 | 46 | var tempAcc = null; |
michael@0 | 47 | try { |
michael@0 | 48 | tempAcc = aAcc.getChildAtPoint(screenX.value, screenY.value); |
michael@0 | 49 | } catch(e) {} |
michael@0 | 50 | is(tempAcc, aAcc, |
michael@0 | 51 | "Wrong accessible returned for position of " + aID + "!"); |
michael@0 | 52 | |
michael@0 | 53 | // get image's parent. |
michael@0 | 54 | var imageParentAcc = null; |
michael@0 | 55 | try { |
michael@0 | 56 | imageParentAcc = aAcc.parent; |
michael@0 | 57 | } catch(e) {} |
michael@0 | 58 | ok(imageParentAcc, "no parent accessible for " + aID + "!"); |
michael@0 | 59 | |
michael@0 | 60 | if (imageParentAcc) { |
michael@0 | 61 | // See if parent's screen coordinates plus image's parent relative |
michael@0 | 62 | // coordinates equal to image's screen coordinates. |
michael@0 | 63 | var parentAccX = {}, parentAccY = {}, parentAccWidth = {}, |
michael@0 | 64 | parentAccHeight = {}; |
michael@0 | 65 | imageParentAcc.getBounds(parentAccX, parentAccY, parentAccWidth, |
michael@0 | 66 | parentAccHeight); |
michael@0 | 67 | is(parentAccX.value + parentX.value, screenX.value, |
michael@0 | 68 | "Wrong screen x coordinate for " + aID + "!"); |
michael@0 | 69 | // XXX see bug 456344 is(parentAccY.value + parentY.value, screenY.value, |
michael@0 | 70 | // "Wrong screen y coordinate for " + aID + "!"); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | var width = {}, height = {}; |
michael@0 | 74 | aAcc.getImageSize(width, height); |
michael@0 | 75 | is(width.value, aWidth, "Wrong width for " + aID + "!"); |
michael@0 | 76 | is(height.value, aHeight, "wrong height for " + aID + "!"); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function testThis(aID, aSRC, aWidth, aHeight, |
michael@0 | 80 | aActionCount, aActionNames) |
michael@0 | 81 | { |
michael@0 | 82 | var acc = getAccessible(aID, [nsIAccessibleImage]); |
michael@0 | 83 | if (!acc) |
michael@0 | 84 | return; |
michael@0 | 85 | |
michael@0 | 86 | // Test role |
michael@0 | 87 | testRole(aID, ROLE_GRAPHIC); |
michael@0 | 88 | |
michael@0 | 89 | // test coordinates and size |
michael@0 | 90 | testCoordinates(aID, acc, aWidth, aHeight); |
michael@0 | 91 | |
michael@0 | 92 | // bug 429659: Make sure the SRC attribute is set for any image |
michael@0 | 93 | var attributes = {"src": aSRC}; |
michael@0 | 94 | testAttrs(acc, attributes, true); |
michael@0 | 95 | |
michael@0 | 96 | if (aActionCount) { |
michael@0 | 97 | is(acc.actionCount, aActionCount, |
michael@0 | 98 | "Wrong number of actions for " + aID + "!"); |
michael@0 | 99 | |
michael@0 | 100 | for (index = 0; index < aActionNames.length; index++) |
michael@0 | 101 | is(acc.getActionName(index), aActionNames[index], |
michael@0 | 102 | "Wrong action name for " + aID + ", index " + index +"!"); |
michael@0 | 103 | } |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | function doTest() |
michael@0 | 107 | { |
michael@0 | 108 | // Test non-linked image |
michael@0 | 109 | testThis("nonLinkedImage", "moz.png", 89, 38); |
michael@0 | 110 | |
michael@0 | 111 | // Test linked image |
michael@0 | 112 | testThis("linkedImage", "moz.png", 89, 38); |
michael@0 | 113 | |
michael@0 | 114 | // Image with long desc |
michael@0 | 115 | var actionNamesArray = new Array("showlongdesc"); |
michael@0 | 116 | testThis("longdesc", "moz.png", 89, 38, 1, |
michael@0 | 117 | actionNamesArray); |
michael@0 | 118 | |
michael@0 | 119 | // Image with click and long desc |
michael@0 | 120 | actionNamesArray = null; |
michael@0 | 121 | actionNamesArray = new Array("click", "showlongdesc"); |
michael@0 | 122 | testThis("clickAndLongdesc", "moz.png", |
michael@0 | 123 | 89, 38, 2, actionNamesArray); |
michael@0 | 124 | |
michael@0 | 125 | // Image with click |
michael@0 | 126 | actionNamesArray = null; |
michael@0 | 127 | actionNamesArray = new Array("click"); |
michael@0 | 128 | testThis("click", "moz.png", |
michael@0 | 129 | 89, 38, 1, actionNamesArray); |
michael@0 | 130 | |
michael@0 | 131 | // Image with long desc |
michael@0 | 132 | actionNamesArray = null; |
michael@0 | 133 | actionNamesArray = new Array("showlongdesc"); |
michael@0 | 134 | testThis("longdesc2", "moz.png", |
michael@0 | 135 | 89, 38, 1, actionNamesArray); |
michael@0 | 136 | |
michael@0 | 137 | SimpleTest.finish(); |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 141 | addA11yLoadEvent(doTest); |
michael@0 | 142 | </script> |
michael@0 | 143 | </head> |
michael@0 | 144 | <body> |
michael@0 | 145 | |
michael@0 | 146 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=429659">Mozilla Bug 429659</a> |
michael@0 | 147 | <a target="_blank" |
michael@0 | 148 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=652635" |
michael@0 | 149 | title="fall back missing @longdesc to aria-describedby pointing to a href"> |
michael@0 | 150 | Mozilla Bug 652635 |
michael@0 | 151 | </a> |
michael@0 | 152 | |
michael@0 | 153 | <p id="display"></p> |
michael@0 | 154 | <div id="content" style="display: none"></div> |
michael@0 | 155 | <pre id="test"> |
michael@0 | 156 | </pre> |
michael@0 | 157 | |
michael@0 | 158 | <br>Simple image:<br> |
michael@0 | 159 | <img id="nonLinkedImage" src="moz.png"/> |
michael@0 | 160 | <br>Linked image:<br> |
michael@0 | 161 | <a href="http://www.mozilla.org"><img id="linkedImage" src="moz.png"></a> |
michael@0 | 162 | <br>Image with longdesc:<br> |
michael@0 | 163 | <img id="longdesc" src="moz.png" longdesc="longdesc_src.html" |
michael@0 | 164 | alt="Image of Mozilla logo"/> |
michael@0 | 165 | <br>Image with click and longdesc:<br> |
michael@0 | 166 | <img id="clickAndLongdesc" src="moz.png" longdesc="longdesc_src.html" |
michael@0 | 167 | alt="Another image of Mozilla logo" onclick="alert('Clicked!');"/> |
michael@0 | 168 | |
michael@0 | 169 | <br>image described by a link to be treated as longdesc<br> |
michael@0 | 170 | <img id="longdesc2" src="moz.png" aria-describedby="describing_link" |
michael@0 | 171 | alt="Second Image of Mozilla logo"/> |
michael@0 | 172 | <a id="describing_link" href="longdesc_src.html">link to description of image</a> |
michael@0 | 173 | |
michael@0 | 174 | <br>Image with click:<br> |
michael@0 | 175 | <img id="click" src="moz.png" |
michael@0 | 176 | alt="A third image of Mozilla logo" onclick="alert('Clicked, too!');"/> |
michael@0 | 177 | |
michael@0 | 178 | </body> |
michael@0 | 179 | </html> |