Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=451376 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 451376</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | |
michael@0 | 12 | <body onload="doTest()"> |
michael@0 | 13 | <a target="_blank" |
michael@0 | 14 | title="IAccessibleText::attributes provides incorrect info after a mis-spelled word" |
michael@0 | 15 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=451376">Mozilla Bug 451376</a> |
michael@0 | 16 | <p id="display"></p> |
michael@0 | 17 | <div id="content" style="display:none"> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | |
michael@0 | 21 | <div id="area"><button>btn1</button>text <button>btn2</button></div> |
michael@0 | 22 | |
michael@0 | 23 | <script class="testbody" type="text/javascript"> |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | |
michael@0 | 26 | function testRange(aRangeID, |
michael@0 | 27 | aStartNode, aStartOffset, |
michael@0 | 28 | aEndNode, aEndOffset, |
michael@0 | 29 | aBeforeRangeNode, aBeforeRangeOffset, |
michael@0 | 30 | aInRangeNode, aInRangeOffset, |
michael@0 | 31 | aAfterRangeNode, aAfterRangeOffset) |
michael@0 | 32 | { |
michael@0 | 33 | var range = document.createRange(); |
michael@0 | 34 | |
michael@0 | 35 | range.setStart(aStartNode, aStartOffset); |
michael@0 | 36 | range.setEnd(aEndNode, aEndOffset); |
michael@0 | 37 | |
michael@0 | 38 | if (aBeforeRangeNode) |
michael@0 | 39 | is(range.comparePoint(aBeforeRangeNode, aBeforeRangeOffset), -1, |
michael@0 | 40 | "Wrong result for the point before the range '" + aRangeID + "'"); |
michael@0 | 41 | if (aInRangeNode) |
michael@0 | 42 | is(range.comparePoint(aInRangeNode, aInRangeOffset), 0, |
michael@0 | 43 | "Wrong result for the point inside the range '" + aRangeID + "'"); |
michael@0 | 44 | if (aAfterRangeNode) |
michael@0 | 45 | is(range.comparePoint(aAfterRangeNode, aAfterRangeOffset), 1, |
michael@0 | 46 | "Wrong result for the point after the range '" + aRangeID + "'"); |
michael@0 | 47 | // Comparare also start and end point |
michael@0 | 48 | is(range.comparePoint(aStartNode, aStartOffset), 0, |
michael@0 | 49 | "Wrong result for the start point '" + aRangeID + "'"); |
michael@0 | 50 | is(range.comparePoint(aEndNode, aEndOffset), 0, |
michael@0 | 51 | "Wrong result for the end point '" + aRangeID + "'"); |
michael@0 | 52 | ok(range.isPointInRange(aStartNode, aStartOffset), |
michael@0 | 53 | "Wrong result for the start point '" + aRangeID + "'"); |
michael@0 | 54 | ok(range.isPointInRange(aEndNode, aEndOffset), |
michael@0 | 55 | "Wrong result for the end point '" + aRangeID + "'"); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function doTest() |
michael@0 | 59 | { |
michael@0 | 60 | var area = document.getElementById("area"); |
michael@0 | 61 | var btn1 = area.firstChild; |
michael@0 | 62 | var text = btn1.nextSibling; |
michael@0 | 63 | var btn2 = area.lastChild; |
michael@0 | 64 | |
michael@0 | 65 | testRange("range1", area, 0, area, 1, |
michael@0 | 66 | null, 0, |
michael@0 | 67 | area, 0, |
michael@0 | 68 | area, 2); |
michael@0 | 69 | |
michael@0 | 70 | testRange("range2", text, 2, text, 4, |
michael@0 | 71 | text, 0, |
michael@0 | 72 | text, 3, |
michael@0 | 73 | text, 5); |
michael@0 | 74 | |
michael@0 | 75 | testRange("range3", text, 4, area, 2, |
michael@0 | 76 | text, 0, |
michael@0 | 77 | text, 4, |
michael@0 | 78 | area, 3); |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.finish(); |
michael@0 | 81 | } |
michael@0 | 82 | </script> |
michael@0 | 83 | </pre> |
michael@0 | 84 | </body> |
michael@0 | 85 | </html> |
michael@0 | 86 |