Bug 333064 - Fix space insertion in copy of CJK text. r=enndeakin a=rkent CLOSED TREE (this is a branch) THUNDERBIRD470b1_2016053115_RELBRANCH
authorJorg K
Tue, 10 May 2016 05:18:00 -0400
branchTHUNDERBIRD470b1_2016053115_RELBRANCH
changeset 324509 4ebc7380df86c0e90b43328a149e911fc2e38301
parent 324508 22ab451c005d969f07ea4258807eb2a1ced01287
child 324510 86dfca096aceb2ce4cde1f64ceb945d81f2b6d3d
push id6041
push userkent@caspia.com
push dateWed, 01 Jun 2016 21:32:47 +0000
treeherdermozilla-beta@4ebc7380df86 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, rkent
bugs333064
milestone47.0
Bug 333064 - Fix space insertion in copy of CJK text. r=enndeakin a=rkent CLOSED TREE (this is a branch)
dom/base/nsCopySupport.cpp
dom/base/test/mochitest.ini
dom/base/test/test_bug333064.html
--- a/dom/base/nsCopySupport.cpp
+++ b/dom/base/nsCopySupport.cpp
@@ -166,18 +166,21 @@ SelectionCopyHelper(nsISelection *aSel, 
   }
 
   // Second, prepare the text/html flavor.
   nsAutoString textHTMLBuf;
   nsAutoString htmlParentsBuf;
   nsAutoString htmlInfoBuf;
   if (encodedTextHTML) {
     // Redo the encoding, but this time use the passed-in flags.
+    // Don't allow wrapping of CJK strings.
     mimeType.AssignLiteral(kHTMLMime);
-    rv = docEncoder->Init(domDoc, mimeType, aFlags);
+    rv = docEncoder->Init(domDoc, mimeType,
+                          aFlags |
+                          nsIDocumentEncoder::OutputDisallowLineBreaking);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = docEncoder->SetSelection(aSel);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = docEncoder->EncodeToStringWithContext(htmlParentsBuf, htmlInfoBuf,
                                                textHTMLBuf);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -424,16 +424,18 @@ skip-if = buildapp == 'b2g' || toolkit =
 [test_bug311681.xml]
 [test_bug313646.html]
 [test_bug320799.html]
 [test_bug322317.html]
 [test_bug326337.html]
 skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
 [test_bug330925.xhtml]
 [test_bug331959.html]
+[test_bug333064.html]
+skip-if = toolkit == 'android'
 [test_bug333198.html]
 [test_bug333673.html]
 [test_bug337631.html]
 [test_bug338541.xhtml]
 [test_bug338583.html]
 # b2g(https not working, bug 907770) b2g-debug(https not working, bug 907770) b2g-desktop(43 total - bug 901343, specialpowers.wrap issue createsystemxhr)
 # e10s - bug 970589, bug 1091934
 skip-if = buildapp == 'b2g' || toolkit == 'android'
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug333064.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=333064
+-->
+<head>
+  <title>Test for Bug 333064</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=333064">Mozilla Bug 333064</a>
+<p id="display"></p>
+
+<div id="display">
+</div>
+<div id="korean-text">안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안안</div>
+
+<pre id="test">
+</pre>
+
+<script class="testbody" type="application/javascript">
+
+/** Test for Bug 333064 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var div = document.getElementById("korean-text");
+  var sel = window.getSelection();
+
+  // Select text node in div.
+  var r = document.createRange();
+  r.setStart(div, 0);
+  r.setEnd(div, 1);
+  sel.addRange(r);
+
+  SimpleTest.waitForClipboard(
+    function compare(value) {
+      // Make sure we got the HTML flavour we asked for and that our
+      // string is included without additional spaces.
+      return value.includes("korean-text") && value.includes("안".repeat(160));
+    },
+    function setup() {
+      synthesizeKey("C", {accelKey: true});
+    },
+    function onSuccess() {
+      SimpleTest.finish();
+    },
+    function onFailure() {
+      SimpleTest.finish();
+    },
+    "text/html"
+  );
+});
+
+</script>
+
+</body>
+</html>