Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=454326 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 454326</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 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=454326">Mozilla Bug 454326</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | </div> |
michael@0 | 16 | |
michael@0 | 17 | <div id="partial-text-selection">Hello Hello <div></div>World!</div> |
michael@0 | 18 | <div id="partial-element-selection"><div id="begin">Hello Hello </div><div></div><div id="end">World!</div></div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 454326 **/ |
michael@0 | 23 | |
michael@0 | 24 | function reinitPartialTextSelection() { |
michael@0 | 25 | var pts = document.getElementById("partial-text-selection"); |
michael@0 | 26 | pts.textContent = null; |
michael@0 | 27 | pts.appendChild(document.createTextNode("Hello Hello ")); |
michael@0 | 28 | pts.appendChild(document.createElement("div")); |
michael@0 | 29 | pts.appendChild(document.createTextNode("World!")); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | |
michael@0 | 33 | function doTest() { |
michael@0 | 34 | var pts = document.getElementById("partial-text-selection"); |
michael@0 | 35 | var ex = null; |
michael@0 | 36 | try { |
michael@0 | 37 | var r1 = document.createRange(); |
michael@0 | 38 | r1.setStart(pts.firstChild, 6); |
michael@0 | 39 | r1.setEnd(pts.lastChild, 6); |
michael@0 | 40 | is(r1.toString(), "Hello World!", "Wrong range!"); |
michael@0 | 41 | r1.surroundContents(document.createElement("div")); |
michael@0 | 42 | is(r1.toString(), "Hello World!", "Wrong range!"); |
michael@0 | 43 | } catch(e) { |
michael@0 | 44 | ex = e; |
michael@0 | 45 | } |
michael@0 | 46 | is(ex, null, "Unexpected exception!"); |
michael@0 | 47 | |
michael@0 | 48 | reinitPartialTextSelection(); |
michael@0 | 49 | ex = null; |
michael@0 | 50 | try { |
michael@0 | 51 | var r2 = document.createRange(); |
michael@0 | 52 | r2.setStart(pts.firstChild, 6); |
michael@0 | 53 | r2.setEnd(pts, 2); |
michael@0 | 54 | is(r2.toString(), "Hello ", "Wrong range!"); |
michael@0 | 55 | r2.surroundContents(document.createElement("div")); |
michael@0 | 56 | is(r2.toString(), "Hello ", "Wrong range!"); |
michael@0 | 57 | } catch(e) { |
michael@0 | 58 | ex = e; |
michael@0 | 59 | } |
michael@0 | 60 | is(ex, null, "Unexpected exception!"); |
michael@0 | 61 | |
michael@0 | 62 | reinitPartialTextSelection(); |
michael@0 | 63 | ex = null; |
michael@0 | 64 | try { |
michael@0 | 65 | var r3 = document.createRange(); |
michael@0 | 66 | r3.setStart(pts, 1); |
michael@0 | 67 | r3.setEnd(pts.lastChild, 6); |
michael@0 | 68 | is(r3.toString(), "World!", "Wrong range!"); |
michael@0 | 69 | r3.surroundContents(document.createElement("div")); |
michael@0 | 70 | is(r3.toString(), "World!", "Wrong range!"); |
michael@0 | 71 | } catch(e) { |
michael@0 | 72 | ex = e; |
michael@0 | 73 | } |
michael@0 | 74 | is(ex, null, "Unexpected exception!"); |
michael@0 | 75 | |
michael@0 | 76 | reinitPartialTextSelection(); |
michael@0 | 77 | ex = null; |
michael@0 | 78 | try { |
michael@0 | 79 | var r3 = document.createRange(); |
michael@0 | 80 | r3.setStart(pts.firstChild, 6); |
michael@0 | 81 | r3.setEnd(pts.firstChild.nextSibling, 0); |
michael@0 | 82 | is(r3.toString(), "Hello ", "Wrong range!"); |
michael@0 | 83 | r3.surroundContents(document.createElement("div")); |
michael@0 | 84 | is(r3.toString(), "Hello ", "Wrong range!"); |
michael@0 | 85 | } catch(e) { |
michael@0 | 86 | ex = e; |
michael@0 | 87 | is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); |
michael@0 | 88 | is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); |
michael@0 | 89 | is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); |
michael@0 | 90 | } |
michael@0 | 91 | ok(ex, "There should have been an exception!"); |
michael@0 | 92 | |
michael@0 | 93 | reinitPartialTextSelection(); |
michael@0 | 94 | ex = null; |
michael@0 | 95 | try { |
michael@0 | 96 | var r3 = document.createRange(); |
michael@0 | 97 | r3.setStart(pts.firstChild.nextSibling, 0); |
michael@0 | 98 | r3.setEnd(pts.lastChild, 6); |
michael@0 | 99 | is(r3.toString(), "World!", "Wrong range!"); |
michael@0 | 100 | r3.surroundContents(document.createElement("div")); |
michael@0 | 101 | is(r3.toString(), "World!", "Wrong range!"); |
michael@0 | 102 | } catch(e) { |
michael@0 | 103 | ex = e; |
michael@0 | 104 | is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); |
michael@0 | 105 | is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); |
michael@0 | 106 | is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); |
michael@0 | 107 | } |
michael@0 | 108 | ok(ex, "There should have been an exception!"); |
michael@0 | 109 | |
michael@0 | 110 | ex = null; |
michael@0 | 111 | try { |
michael@0 | 112 | var pes = document.getElementById("partial-element-selection"); |
michael@0 | 113 | var r4 = document.createRange(); |
michael@0 | 114 | r4.setStart(pes.firstChild.firstChild, 6); |
michael@0 | 115 | r4.setEnd(pes.lastChild.firstChild, 6); |
michael@0 | 116 | is(r4.toString(), "Hello World!", "Wrong range!"); |
michael@0 | 117 | r4.surroundContents(document.createElement("div")); |
michael@0 | 118 | is(r4.toString(), "Hello World!", "Wrong range!"); |
michael@0 | 119 | } catch(e) { |
michael@0 | 120 | ex = e; |
michael@0 | 121 | is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); |
michael@0 | 122 | is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); |
michael@0 | 123 | is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); |
michael@0 | 124 | } |
michael@0 | 125 | ok(ex, "There should have been an exception!"); |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 129 | addLoadEvent(doTest); |
michael@0 | 130 | addLoadEvent(SimpleTest.finish); |
michael@0 | 131 | </script> |
michael@0 | 132 | </pre> |
michael@0 | 133 | </body> |
michael@0 | 134 | </html> |
michael@0 | 135 |