layout/reftests/selection/dom-mutations-ref.html

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html class="reftest-wait">
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=619273
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 619273</title>
michael@0 8 <script type="application/javascript;version=1.7">
michael@0 9 /** Test DOM mutations inside selection **/
michael@0 10 function createDOM(doc) {
michael@0 11 let s = doc.createElement('span');
michael@0 12 s.appendChild(doc.createTextNode('|'))
michael@0 13 let s2 = doc.createElement('span');
michael@0 14 s2.appendChild(doc.createTextNode('z'))
michael@0 15 s.appendChild(s2)
michael@0 16 return s;
michael@0 17 }
michael@0 18
michael@0 19 var tests_done = 0;
michael@0 20 var tests = [
michael@0 21 function(win,doc,sel) {
michael@0 22 doc.body.innerHTML = '.I<br>B<br>C|z'
michael@0 23 let a = doc.body.firstChild;
michael@0 24 let r = doc.createRange();
michael@0 25 r.setStart(a, 1);
michael@0 26 r.setEnd(a, 2);
michael@0 27 sel.addRange(r);
michael@0 28 },
michael@0 29 function(win,doc,sel) {
michael@0 30 doc.body.innerHTML = '.I<br>B<br>C|z'
michael@0 31 let a = doc.body.firstChild;
michael@0 32 let r = doc.createRange();
michael@0 33 r.setStart(doc.firstChild, 0);
michael@0 34 r.setEnd(a, 2);
michael@0 35 sel.addRange(r);
michael@0 36 },
michael@0 37 function(win,doc,sel) {
michael@0 38 doc.body.innerHTML = 'I<br>.B<br>C|z'
michael@0 39 let a = doc.body.firstChild;
michael@0 40 let b = doc.body.childNodes[2];
michael@0 41 let c = doc.body.childNodes[4];
michael@0 42 let r = doc.createRange();
michael@0 43 r.setStart(a, 0);
michael@0 44 r.setEnd(c, 1);
michael@0 45 sel.addRange(r);
michael@0 46 },
michael@0 47 function(win,doc,sel) {
michael@0 48 doc.body.innerHTML = 'I<br>.B<br>C|z'
michael@0 49 let b = doc.body.childNodes[2];
michael@0 50 let c = doc.body.childNodes[4];
michael@0 51 let r = doc.createRange();
michael@0 52 r.setStart(doc.body, 0);
michael@0 53 r.setEnd(c, 1);
michael@0 54 sel.addRange(r);
michael@0 55 },
michael@0 56 function(win,doc,sel) {
michael@0 57 doc.body.innerHTML = 'I<br>.B<br>C|z'
michael@0 58 let b = doc.body.childNodes[2];
michael@0 59 let c = doc.body.childNodes[4];
michael@0 60 let r = doc.createRange();
michael@0 61 r.setStart(doc, 0);
michael@0 62 r.setEnd(c, 1);
michael@0 63 sel.addRange(r);
michael@0 64 },
michael@0 65 function(win,doc,sel) {
michael@0 66 doc.body.innerHTML = 'I<br>B<br>.C|z'
michael@0 67 let a = doc.body.firstChild;
michael@0 68 let c = doc.body.childNodes[4];
michael@0 69 let r = doc.createRange();
michael@0 70 r.setStart(a, 0);
michael@0 71 r.setEnd(c, 2);
michael@0 72 sel.addRange(r);
michael@0 73 },
michael@0 74
michael@0 75 function(win,doc,sel) {
michael@0 76 doc.body.innerHTML = '|z|zI<br>B<br>C'
michael@0 77 let a = doc.body.firstChild;
michael@0 78 let r = doc.createRange();
michael@0 79 r.setStart(a, 4);
michael@0 80 r.setEnd(a, 5);
michael@0 81 sel.addRange(r);
michael@0 82 },
michael@0 83 function(win,doc,sel) {
michael@0 84 doc.body.innerHTML = '|z|zI<br>B<br>C'
michael@0 85 let a = doc.body.firstChild;
michael@0 86 let r = doc.createRange();
michael@0 87 r.setStart(doc.firstChild, 0);
michael@0 88 r.setEnd(a, 5);
michael@0 89 sel.addRange(r);
michael@0 90 },
michael@0 91 function(win,doc,sel) {
michael@0 92 doc.body.innerHTML = 'I<br>|z|zB<br>C'
michael@0 93 let a = doc.body.firstChild;
michael@0 94 let b = doc.body.childNodes[2];
michael@0 95 let c = doc.body.childNodes[4];
michael@0 96 let r = doc.createRange();
michael@0 97 r.setStart(a, 0);
michael@0 98 r.setEnd(c, 1);
michael@0 99 sel.addRange(r);
michael@0 100 },
michael@0 101 function(win,doc,sel) {
michael@0 102 doc.body.innerHTML = 'I<br>|z|zB<br>C'
michael@0 103 let b = doc.body.childNodes[2];
michael@0 104 let c = doc.body.childNodes[4];
michael@0 105 let r = doc.createRange();
michael@0 106 r.setStart(doc.body, 0);
michael@0 107 r.setEnd(c, 1);
michael@0 108 sel.addRange(r);
michael@0 109 },
michael@0 110 function(win,doc,sel) {
michael@0 111 doc.body.innerHTML = 'I<br>|z|zB<br>C'
michael@0 112 let b = doc.body.childNodes[2];
michael@0 113 let c = doc.body.childNodes[4];
michael@0 114 let r = doc.createRange();
michael@0 115 r.setStart(doc, 0);
michael@0 116 r.setEnd(c, 1);
michael@0 117 sel.addRange(r);
michael@0 118 },
michael@0 119 function(win,doc,sel) {
michael@0 120 doc.body.innerHTML = 'I<br>B<br>|z|zC'
michael@0 121 let a = doc.body.firstChild;
michael@0 122 let c = doc.body.childNodes[4];
michael@0 123 let r = doc.createRange();
michael@0 124 r.setStart(a, 0);
michael@0 125 r.setEnd(c, 5);
michael@0 126 sel.addRange(r);
michael@0 127 },
michael@0 128
michael@0 129 function(win,doc,sel) {
michael@0 130 doc.body.innerHTML = '<br>B<br>CI'
michael@0 131 },
michael@0 132 function(win,doc,sel) {
michael@0 133 doc.body.innerHTML = '<br>B<br>C'
michael@0 134 },
michael@0 135 function(win,doc,sel) {
michael@0 136 doc.body.innerHTML = 'I<br>B<br>C'
michael@0 137 let a = doc.body.firstChild;
michael@0 138 let c = doc.body.childNodes[4];
michael@0 139 let r = doc.createRange();
michael@0 140 r.setStart(a, 0);
michael@0 141 r.setEnd(c, 1);
michael@0 142 sel.addRange(r);
michael@0 143 },
michael@0 144
michael@0 145 function(win,doc,sel) {
michael@0 146 doc.body.innerHTML = 'I|z'
michael@0 147 let a = doc.body.firstChild;
michael@0 148 let r = doc.createRange();
michael@0 149 r.setStart(a, 1);
michael@0 150 r.setEnd(a, 2);
michael@0 151 sel.addRange(r);
michael@0 152 },
michael@0 153
michael@0 154 function(win,doc,sel) {
michael@0 155 doc.body.innerHTML = 'Iz|'
michael@0 156 let a = doc.body.firstChild;
michael@0 157 let r = doc.createRange();
michael@0 158 r.setStart(a, 1);
michael@0 159 r.setEnd(a, 2);
michael@0 160 sel.addRange(r);
michael@0 161
michael@0 162 document.body.appendChild(document.createTextNode('I'));
michael@0 163 document.body.appendChild(document.createTextNode(' '));
michael@0 164 document.body.appendChild(createDOM(document));
michael@0 165 },
michael@0 166 ]
michael@0 167
michael@0 168 function runTestInIframe(run,t) {
michael@0 169 let f = document.createElement('iframe');
michael@0 170 f.setAttribute('frameborder','0');
michael@0 171 f.setAttribute('height','100');
michael@0 172 f.setAttribute('width','200');
michael@0 173 f.src = 'data:text/html,<body style="margin:0;padding:0;font-family:monospace">';
michael@0 174 f.onload = function () {
michael@0 175 try {
michael@0 176 run(f.contentWindow, f.contentDocument, f.contentWindow.getSelection());
michael@0 177 } finally { ++tests_done; }
michael@0 178 }
michael@0 179 return f;
michael@0 180 }
michael@0 181
michael@0 182 var id;
michael@0 183 function checkFinished() {
michael@0 184 if (window.frames.length == tests_done) {
michael@0 185 clearInterval(id);
michael@0 186 document.documentElement.className = "";
michael@0 187 }
michael@0 188 }
michael@0 189
michael@0 190 function runTest() {
michael@0 191 for (let i=0; i < tests.length; ++i) {
michael@0 192 let t = tests[i];
michael@0 193 document.body.appendChild(runTestInIframe(t));
michael@0 194 }
michael@0 195 id = setInterval(checkFinished,500);
michael@0 196 }
michael@0 197 </script>
michael@0 198 </head>
michael@0 199 <body onload="runTest()"></body>
michael@0 200 </html>

mercurial