Bug 795418 - Test. r=mats, a=ritu
authorJorg K <jorgk@jorgk.com>
Fri, 27 Jan 2017 00:24:00 +0100
changeset 378100 cfff8883bbedcc72a58c45321222ec95d49f2a88
parent 378099 385b4f5d1c495855e16e6b62ebfb246610e7dc9a
child 378101 8a28269883ab9eb995123feb521e46402d9c3e90
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, ritu
bugs795418
milestone53.0a2
Bug 795418 - Test. r=mats, a=ritu
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug795418.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -155,16 +155,17 @@ subsuite = clipboard
 [test_bug757771.html]
 [test_bug767684.html]
 [test_bug772796.html]
 skip-if = toolkit == 'android' # bug 1309431
 [test_bug773262.html]
 [test_bug780035.html]
 [test_bug787432.html]
 [test_bug790475.html]
+[test_bug795418.html]
 [test_bug795785.html]
 [test_bug796839.html]
 [test_bug830600.html]
 subsuite = clipboard
 skip-if = e10s
 [test_bug832025.html]
 [test_bug850043.html]
 [test_bug857487.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug795418.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=795418
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 795418</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/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=795418">Mozilla Bug 795418</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+
+<div id="copySource">Copy this</div>
+<div id="editable" contenteditable><span>AB</span></div>
+
+<pre id="test">
+
+<script type="application/javascript">
+
+/** Test for Bug 795418 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var div = document.getElementById("copySource");
+  var sel = window.getSelection();
+  sel.removeAllRanges();
+
+  // Select the text from the text node in div.
+  var r = document.createRange();
+  r.setStart(div.firstChild, 0);
+  r.setEnd(div.firstChild, 9);
+  sel.addRange(r);
+
+  SimpleTest.waitForClipboard(
+    function compare(value) {
+      var theEdit = document.getElementById("editable");
+      sel.collapse(theEdit.firstChild, 1);
+
+      SpecialPowers.doCommand(window, "cmd_pasteQuote");
+      is(theEdit.innerHTML,
+        "<span>AB<blockquote type=\"cite\">Copy this</blockquote></span>",
+        "unexpected HTML for test");
+      return true;
+    },
+    function setup() {
+      synthesizeKey("C", {accelKey: true});
+    },
+    function onSuccess() {
+      SimpleTest.finish();
+    },
+    function onFailure() {
+      SimpleTest.finish();
+    },
+    "text/html"
+  );
+});
+
+</script>
+
+</pre>
+</body>
+</html>