Bug 1127835 - Part 2: Test. a=lmandel
authorMats Palmgren <mats@mozilla.com>
Mon, 02 Feb 2015 22:34:17 +0000
changeset 249678 9298e1b5ec0956342e92902fb6b2fdfcf67b0002
parent 249677 d79341adb336f254605e25aaeaf05e2b7cc413da
child 249679 43cbd2b4839484691f4f3794b9fe2de918862dc1
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslmandel
bugs1127835
milestone37.0a2
Bug 1127835 - Part 2: Test. a=lmandel
dom/base/test/copypaste.js
dom/base/test/test_copypaste.html
--- a/dom/base/test/copypaste.js
+++ b/dom/base/test/copypaste.js
@@ -312,16 +312,37 @@ if (false) {
 
     r = document.createRange();
     r.setStart(div1.childNodes[1], 0);  // the start of "after"
     r.setEnd(parent, 1);
     sel.addRange(r);
     copySelectionToClipboard(true);
     testPasteHTML('contentEditable5', '<div id="div2s"><div id="div2se1">before</div></div><div id="div2s">after</div>');
 
+    // crash test for bug 1127835
+    var e1 = document.getElementById('1127835crash1');
+    var e2 = document.getElementById('1127835crash2');
+    var e3 = document.getElementById('1127835crash3');
+    var t1 = e1.childNodes[0];
+    var t3 = e3.childNodes[0];
+    
+    var sel = window.getSelection();
+    sel.removeAllRanges();
+  
+    var r = document.createRange();
+    r.setStart(t1, 1);
+    r.setEnd(e2, 0);
+    sel.addRange(r);
+  
+    r = document.createRange();
+    r.setStart(e2, 1);
+    r.setEnd(t3, 0);
+    sel.addRange(r);
+    copySelectionToClipboard(true);
+    testPasteHTML('contentEditable6', '<span id="1127835crash1"></span><div id="1127835crash2"><div>\n</div></div><br>');
   }
 
   // ============ copy/paste test from/to a textarea
 
   var val = "1\n 2\n  3";
   textarea.value=val;
   textarea.select();
   textarea.editor.copy();
@@ -339,30 +360,32 @@ if (false) {
   testClipboardValue("text/html", "<div id=\"div13\">__</div>");
   testPasteText("__");
 
   // ============ converting cell boundaries to tabs in tables
 
   copyToClipboard($("tr1"));
   testClipboardValue("text/unicode", "foo\tbar");
 
-  // ============ spanning multiple rows
+  if (!isXHTML) {
+    // ============ spanning multiple rows
 
-  copyRangeToClipboard($("tr2"),0,$("tr3"),0);
-  testClipboardValue("text/unicode", "1\t2\n3\t4\n");
-  testClipboardValue("text/html", '<table><tbody><tr id="tr2"><tr id="tr2"><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr><tr id="tr3"></tr></tr></tbody></table>');
+    copyRangeToClipboard($("tr2"),0,$("tr3"),0);
+    testClipboardValue("text/unicode", "1\t2\n3\t4\n");
+    testClipboardValue("text/html", '<table><tbody><tr id="tr2"><tr id="tr2"><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr><tr id="tr3"></tr></tr></tbody></table>');
 
-  // ============ spanning multiple rows in multi-range selection
+    // ============ spanning multiple rows in multi-range selection
 
-  clear();
-  addRange($("tr2"),0,$("tr2"),2);
-  addRange($("tr3"),0,$("tr3"),2);
-  copySelectionToClipboard();
-  testClipboardValue("text/unicode", "1\t2\n5\t6");
-  testClipboardValue("text/html", '<table><tbody><tr id="tr2"><td>1</td><td>2</td></tr><tr id="tr3"><td>5</td><td>6</td></tr></tbody></table>');
+    clear();
+    addRange($("tr2"),0,$("tr2"),2);
+    addRange($("tr3"),0,$("tr3"),2);
+    copySelectionToClipboard();
+    testClipboardValue("text/unicode", "1\t2\n5\t6");
+    testClipboardValue("text/html", '<table><tbody><tr id="tr2"><td>1</td><td>2</td></tr><tr id="tr3"><td>5</td><td>6</td></tr></tbody></table>');
+  }
 
   // ============ manipulating Selection in oncopy
 
   copyRangeToClipboard($("div11").childNodes[0],0, $("div11").childNodes[1],2);
   testClipboardValue("text/unicode", "Xdiv11");
   testClipboardValue("text/html", "<div><p>X<span>div</span>11</p></div>");
   setTimeout(function(){testSelectionToString("div11")},0);
 
--- a/dom/base/test/test_copypaste.html
+++ b/dom/base/test/test_copypaste.html
@@ -78,16 +78,22 @@ addLoadEvent(function () testCopyPaste(f
 </div>
 
 <div id="contentEditable1" contenteditable spellcheck="false"></div>
 <div id="contentEditable2" contenteditable spellcheck="false"></div>
 <div id="contentEditable3" contenteditable spellcheck="false"></div>
 <div id="contentEditable4" contenteditable spellcheck="false"></div>
 <div id="contentEditable5" contenteditable spellcheck="false"></div>
 
+<div>
+<span id="1127835crash1">1</span><div id="1127835crash2"><div>
+</div></div><a href="http://www.mozilla.org/" id="1127835crash3">3</a>
+</div>
+<div id="contentEditable6" contenteditable spellcheck="false"></div>
+
 <div id="div6" style="display:none"></div>
 <script>
 var x = $("div6")
 x.appendChild(document.createTextNode('di'))
 x.appendChild(document.createTextNode('v6'))
 </script>
 
 <div id="div7" style="display:none">div7</div>