Backed out changesets 04d93fda6f3f and 89a690cd0c5f (bug 1123505) for test_copypaste.xhtml failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 09 Feb 2015 16:18:19 -0500
changeset 249658 c1e63dabd5f5e4006d7e1f916f0e969e16d4ccb8
parent 249657 f95708ec343ec4b4660fe8043800038a7c26bc1c
child 249659 b8df96693f4f09d2e588cad22d326e7c4e296fe6
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)
bugs1123505
milestone37.0a2
backs out04d93fda6f3f07140a52cdb702fa3bce03426859
89a690cd0c5feb6c96fadb4f31b595e4349a7cd5
Backed out changesets 04d93fda6f3f and 89a690cd0c5f (bug 1123505) for test_copypaste.xhtml failures.
dom/base/nsDocumentEncoder.cpp
dom/base/test/copypaste.js
dom/base/test/test_copypaste.html
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -966,17 +966,16 @@ nsDocumentEncoder::SerializeRangeToStrin
   nsINode* startParent = aRange->GetStartParent();
   NS_ENSURE_TRUE(startParent, NS_ERROR_FAILURE);
   int32_t startOffset = aRange->StartOffset();
 
   nsINode* endParent = aRange->GetEndParent();
   NS_ENSURE_TRUE(endParent, NS_ERROR_FAILURE);
   int32_t endOffset = aRange->EndOffset();
 
-  mStartDepth = mEndDepth = 0;
   mCommonAncestors.Clear();
   mStartNodes.Clear();
   mStartOffsets.Clear();
   mEndNodes.Clear();
   mEndOffsets.Clear();
 
   nsContentUtils::GetAncestors(mCommonParent, mCommonAncestors);
   nsCOMPtr<nsIDOMNode> sp = do_QueryInterface(startParent);
@@ -1067,17 +1066,16 @@ nsDocumentEncoder::EncodeToStringWithMax
   if (mSelection) {
     nsCOMPtr<nsIDOMRange> range;
     int32_t i, count = 0;
 
     rv = mSelection->GetRangeCount(&count);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIDOMNode> node, prevNode;
-    uint32_t firstRangeStartDepth = 0;
     for (i = 0; i < count; i++) {
       mSelection->GetRangeAt(i, getter_AddRefs(range));
 
       // Bug 236546: newlines not added when copying table cells into clipboard
       // Each selected cell shows up as a range containing a row with a single cell
       // get the row, compare it to previous row and emit </tr><tr> as needed
       // Bug 137450: Problem copying/pasting a table from a web page to Excel.
       // Each separate block of <tr></tr> produced above will be wrapped by the
@@ -1117,21 +1115,17 @@ nsDocumentEncoder::EncodeToStringWithMax
           NS_ENSURE_SUCCESS(rv, rv);
           prevNode = nullptr;
         }
       }
 
       nsRange* r = static_cast<nsRange*>(range.get());
       rv = SerializeRangeToString(r, output);
       NS_ENSURE_SUCCESS(rv, rv);
-      if (i == 0) {
-        firstRangeStartDepth = mStartDepth;
-      }
     }
-    mStartDepth = firstRangeStartDepth;
 
     if (prevNode) {
       nsCOMPtr<nsINode> p = do_QueryInterface(prevNode);
       rv = SerializeNodeEnd(p, output);
       NS_ENSURE_SUCCESS(rv, rv);
       mCommonAncestors.Clear();
       nsContentUtils::GetAncestors(p->GetParentNode(), mCommonAncestors);
       mDisableContextSerialize = false; 
--- a/dom/base/test/copypaste.js
+++ b/dom/base/test/copypaste.js
@@ -47,43 +47,40 @@ function testCopyPaste (isXHTML) {
 
   function copySelectionToClipboard(suppressUnicodeCheck) {
     documentViewer.copySelection();
     if (!suppressUnicodeCheck)
       ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), "check text/unicode");
     if (!suppressHTMLCheck)
       ok(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), "check text/html");
   }
-  function clear(node, suppressUnicodeCheck) {
+  function copyToClipboard(node, suppressUnicodeCheck) {
     textarea.blur();
     clipboard.emptyClipboard(1);
     var sel = window.getSelection();
     sel.removeAllRanges();
-  }
-  function copyToClipboard(node, suppressUnicodeCheck) {
-    clear();
     var r = document.createRange();
     r.selectNode(node);
     window.getSelection().addRange(r);
     copySelectionToClipboard(suppressUnicodeCheck);
   }
-  function addRange(startNode,startIndex,endNode,endIndex) {
+  function copyRangeToClipboard(startNode,startIndex,endNode,endIndex,suppressUnicodeCheck) {
+    textarea.blur();
+    clipboard.emptyClipboard(1);
     var sel = window.getSelection();
+    sel.removeAllRanges();
     var r = document.createRange();
     r.setStart(startNode,startIndex)
     r.setEnd(endNode,endIndex)
-    sel.addRange(r);
-  }
-  function copyRangeToClipboard(startNode,startIndex,endNode,endIndex,suppressUnicodeCheck) {
-    clear();
-    addRange(startNode,startIndex,endNode,endIndex);
+    window.getSelection().addRange(r);
     copySelectionToClipboard(suppressUnicodeCheck);
   }
   function copyChildrenToClipboard(id) {
-    clear();
+    textarea.blur();
+    clipboard.emptyClipboard(1);
     window.getSelection().selectAllChildren(document.getElementById(id));
     copySelectionToClipboard();
   }
   function getClipboardData(mime) {
     var transferable = SpecialPowers.Cc['@mozilla.org/widget/transferable;1']
                                     .createInstance(SpecialPowers.Ci.nsITransferable);
     transferable.init(getLoadContext());
     transferable.addDataFlavor(mime);
@@ -103,22 +100,16 @@ function testCopyPaste (isXHTML) {
     return data.value;
   }
   function testPasteText(expected) {
     textarea.value="";
     textarea.focus();
     textarea.editor.paste(1);
     is(textarea.value, expected, "value of the textarea after the paste");
   }
-  function testPasteHTML(id, expected) {
-    var contentEditable = $(id);
-    contentEditable.focus();
-    synthesizeKey("v", {accelKey: 1});
-    is(contentEditable.innerHTML, expected, id+".innerHtml after the paste");
-  }
   function testSelectionToString(expected) {
     is(window.getSelection().toString().replace(/\r\n/g,"\n"), expected, "Selection.toString");
   }
   function testInnerHTML(id, expected) {
     var value = document.getElementById(id).innerHTML;
     is(value, expected, id + ".innerHTML");
   }
   function testEmptyChildren(id) {
@@ -225,105 +216,16 @@ if (false) {
   testSelectionToString("");
 
   copyRangeToClipboard($("div10").childNodes[0],0, $("div10").childNodes[0],1,suppressUnicodeCheckIfHidden);
   testSelectionToString("");
 
   copyRangeToClipboard($("div10").childNodes[1],0, $("div10").childNodes[1],1,suppressUnicodeCheckIfHidden);
   testSelectionToString("");
 
-  if (!isXHTML) {
-    // ============ copy/paste multi-range selection (bug 1123505)
-    // with text start node
-    var sel = window.getSelection();
-    sel.removeAllRanges();
-    var r = document.createRange();
-    var ul = $('ul1');
-    var parent = ul.parentNode;
-    r.setStart(parent, 0);
-    r.setEnd(parent.firstChild, 15);  // the end of "Copy..."
-    sel.addRange(r);
-
-    r = document.createRange();
-    r.setStart(ul, 1);  // before the space inside the UL
-    r.setEnd(parent, 2);  // after the UL
-    sel.addRange(r);
-    copySelectionToClipboard(true);
-    testPasteHTML('contentEditable1', 'Copy1then Paste');
-
-    // with text end node
-    var sel = window.getSelection();
-    sel.removeAllRanges();
-    var r = document.createRange();
-    var ul = $('ul2');
-    var parent = ul.parentNode;
-    r.setStart(parent, 0);
-    r.setEnd(ul, 1);  // after the space
-    sel.addRange(r);
-
-    r = document.createRange();
-    r.setStart(parent.childNodes[1], 0);  // the start of "Copy..."
-    r.setEnd(parent, 2);
-    sel.addRange(r);
-    copySelectionToClipboard(true);
-    testPasteHTML('contentEditable2', 'Copy2then Paste');
-
-    // with text end node and non-empty start
-    var sel = window.getSelection();
-    sel.removeAllRanges();
-    var r = document.createRange();
-    var ul = $('ul3');
-    var parent = ul.parentNode;
-    r.setStart(parent, 0);
-    r.setEnd(ul, 1);  // after the space
-    sel.addRange(r);
-
-    r = document.createRange();
-    r.setStart(parent.childNodes[1], 0);  // the start of "Copy..."
-    r.setEnd(parent, 2);
-    sel.addRange(r);
-    copySelectionToClipboard(true);
-    testPasteHTML('contentEditable3', '<ul id="ul3"><li>\n<br></li></ul>Copy3then Paste');
-
-    // with elements of different depth
-    var sel = window.getSelection();
-    sel.removeAllRanges();
-    var r = document.createRange();
-    var div1 = $('div1s');
-    var parent = div1.parentNode;
-    r.setStart(parent, 0);
-    r.setEnd(document.getElementById('div1se1'), 1);  // after the "inner" DIV
-    sel.addRange(r);
-
-    r = document.createRange();
-    r.setStart(div1.childNodes[1], 0);  // the start of "after"
-    r.setEnd(parent, 1);
-    sel.addRange(r);
-    copySelectionToClipboard(true);
-    testPasteHTML('contentEditable4', '<div id="div1s"><div id="div1se1">before</div></div><div id="div1s">after</div>');
-
-    // with elements of different depth, and a text node at the end
-    var sel = window.getSelection();
-    sel.removeAllRanges();
-    var r = document.createRange();
-    var div1 = $('div2s');
-    var parent = div1.parentNode;
-    r.setStart(parent, 0);
-    r.setEnd(document.getElementById('div2se1'), 1);  // after the "inner" DIV
-    sel.addRange(r);
-
-    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>');
-
-  }
-
   // ============ copy/paste test from/to a textarea
 
   var val = "1\n 2\n  3";
   textarea.value=val;
   textarea.select();
   textarea.editor.copy();
   
   textarea.value="";
@@ -339,31 +241,16 @@ 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
-
-  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
-
-  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);
 
   setTimeout(function(){
--- a/dom/base/test/test_copypaste.html
+++ b/dom/base/test/test_copypaste.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 -->
 <head>
   <title>Test for copy/paste</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <script type="text/javascript" src="copypaste.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=524975">Mozilla Bug </a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
@@ -59,35 +58,16 @@ addLoadEvent(function () testCopyPaste(f
 <div id="div4">
   T<textarea>t t t</textarea>
 </div>
 
 <div id="div5">
   T<textarea>     </textarea>
 </div>
 
-<div>Copy1then Paste<ul id="ul1"><li>LI</li>
-</ul></div>
-
-<div><ul id="ul2">
-<li>LI</li></ul>Copy2then Paste</div>
-
-<div><ul id="ul3"><li>
-<li>LI</li></ul>Copy3then Paste</div>
-
-<div><div id="div1s"><div id="div1se1">before<div>inner</div></div>after</div></div>
-<div><div id="div2s"><div id="div2se1">before<div>inner</div></div>after</div>
-</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 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>
@@ -101,13 +81,12 @@ x.appendChild(document.createTextNode('1
 </script>
 
 <div id="div11" oncopy="modifySelection('X')"><span>div</span>11</div>
 <div id="div12" oncopy="modifySelection('X<b style=\'display:none\'>Y</b>')"><span>div</span>12</div>
 
 <div id="div13">_<noscript>FAIL</noscript>_</div>
 
 <table><tr id=tr1><td>foo</td><td>bar</td></tr></table>
-<table><tr id=tr2><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr><tr id=tr3><td>5</td><td>6</td></tr></table>
 
 </div>
 </body>
 </html>