Bug 572642 - Part 2: tests; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 23 Jun 2010 14:40:08 -0400
changeset 44200 b149725f51da976770d7a344b1e09c5f3d08125d
parent 44199 4e74c58e602034bc6262eb2ce638ea8246a1c5db
child 44201 b6064d9b85b3bc3c66af6ce058e195972594353b
push id14024
push usereakhgari@mozilla.com
push dateWed, 23 Jun 2010 18:58:25 +0000
treeherdermozilla-central@b149725f51da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs572642
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 572642 - Part 2: tests; r=roc
editor/libeditor/html/tests/Makefile.in
editor/libeditor/html/tests/data/cfhtml-chromium.txt
editor/libeditor/html/tests/data/cfhtml-firefox.txt
editor/libeditor/html/tests/data/cfhtml-ie.txt
editor/libeditor/html/tests/data/cfhtml-ooo.txt
editor/libeditor/html/tests/test_CF_HTML_clipboard.html
--- a/editor/libeditor/html/tests/Makefile.in
+++ b/editor/libeditor/html/tests/Makefile.in
@@ -54,19 +54,30 @@ include $(topsrcdir)/config/rules.mk
 		test_bug478725.html \
 		test_bug480972.html \
 		test_bug484181.html \
 		test_bug487524.html \
 		test_bug520189.html \
 		test_bug525389.html \
 		test_bug537046.html \
 		test_bug550434.html \
+		test_CF_HTML_clipboard.html \
 		test_contenteditable_focus.html \
 		test_htmleditor_keyevent_handling.html \
 		test_select_all_without_body.html \
 		file_select_all_without_body.html \
 		test_root_element_replacement.html \
 		$(NULL)
 
+_DATA_FILES = \
+		data/cfhtml-chromium.txt \
+		data/cfhtml-firefox.txt \
+		data/cfhtml-ie.txt \
+		data/cfhtml-ooo.txt \
+		$(NULL)
+
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 	(cd $(srcdir) && tar $(TAR_CREATE_FLAGS) - browserscope 2> /dev/null) | (cd $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) && tar -xf -)
 
+libs:: $(_DATA_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)/data
+
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7e02537157f8a6f5e728e9883597fc6c4dd3bc11
GIT binary patch
literal 856
zc$|Gw(QeZ)6y>>6|H1TSAmKWVHW+SKi3bo51EDc^caodL%&{%|W@-ENyGc`)PJ$?k
z<KyGwbFa^D2vIvLljX<x>?f*#U+=%&%H;T@Njjf>w#5{?zPcKjUxKO{u=tmKnGEcg
z`1R@o?Qm_#;n&@*tP#BwqC~%J+(8?omM&Dnx0#sEOC6weJ7INIquGlzStUGq&sQl=
zF8RphIh_-f5%bxm#>Q-E%v`bW$Jd;n+2p)OqgR&YM#Xru_~g9-9&z7)316_`|7MZ7
zP(a|hqa%C-$s%|a6vCPj=7MCQ%HAaJSpU9Vv(k}#sTytel3m>E1|s_o9lLXlvKQm}
zpe>nop;2bU9#znaI(3eA(AWG78bBmFWHHyan&8?3uV0W|@U^m0vUJT5cF2{{m6c4j
z=te}_qQ4%N_}z$54{a<-q1UlgW>;$*nvzc}ce-%hQMscIJsTQ?$aeOik&n%*UC;-r
zMw$Qf9wDI4|H&Hc6_7h>KLs_Cc@AX>Ii9SZF{3^JSH+(;;;H2GbqwwSI8}o6c+&B5
rXrE*a6uNEJY_Z+=0NWpAsMPsJ^plO~BQgeSlJaA$#3^-Rh~cXz+WQ~=
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cc686d85627ecf91ab899a49af1b439df537f05b
GIT binary patch
literal 266
zc$`&^yAFat5Jjy?_y?tj1)@X<ZYQz8##g_>@GuKYhBc^P?}8X*n#r8pIk^|WwiI<>
zTfVLxB}2J8?c>1i$MKfBwyo12alO@;ijd_M)N)Mv>mfO%u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cf7616efecc820cf9b1946852823303abe7ed7
GIT binary patch
literal 649
zc${rfTTj9;6!sMo{=>0P`p|WN5;8X8+$xZaZO)3}an3Rpx6W)OAsYX?yC5NGUru_y
z%ek$1Q6{<2`ik1?KFP3<bGCFewSE23xYwoP?KC&K86TJrMHpvX$Y11k+_KN}qhY_-
z)h}(&Vr!p5Z3h1Hy|b_YVM1Pp79lpXTi`}fffb=B6It~Yri4%zO)GtkHj$ck6+8Np
zGPBY!AJfO@#mYdI=Q8RtTvtJG_!&s@y(C+ir4xv@VNr5v?BoWIQRBiE%%M}AwDIWc
znoDY+8Fgu3GA}r>^FFxnHk%~kN?yb;R0aT7FNqiquF<*P3aH7beWF$;>R;B}bZ7sw
zp4i%<P!DvNBPz=lxx}~%ox6`P=I{ksSj36YU=U^ST?76xiC=Rm^GpL(8T5Z)Q%e)^
zUUAACr=f^<m5m0U`+Wmr+|(dV`FiQ(uyy_3v)ABM{Thf1Y?%n`MPML@1<jFsXe0(Y
YFCArQy5(t_>%?yiYope=zU#%s56IlAxc~qF
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
@@ -0,0 +1,152 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=572642
+-->
+<head>
+  <title>Test for Bug 572642</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=572642">Mozilla Bug 572642</a>
+<p id="display"></p>
+<div id="content">
+  <div id="editor1" contenteditable="true"></div>
+  <iframe id="editor2"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 572642 **/
+
+function copyCF_HTML(cfhtml, success, failure) {
+  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+  const Cc = Components.classes;
+  const Ci = Components.interfaces;
+  const CF_HTML = "application/x-moz-nativehtml";
+
+  var cb = Cc["@mozilla.org/widget/clipboard;1"].
+           getService(Ci.nsIClipboard);
+
+  var counter = 0;
+  function copyCF_HTML_worker(success, failure) {
+    if (++counter > 50) {
+      ok(false, "Timed out while polling clipboard for pasted data");
+      failure();
+      return;
+    }
+
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    var flavors = [CF_HTML];
+    if (!cb.hasDataMatchingFlavors(flavors, flavors.length, cb.kGlobalClipboard)) {
+      setTimeout(function() copyCF_HTML_worker(success, failure), 100);
+      return;
+    }
+
+    var trans = Cc["@mozilla.org/widget/transferable;1"].
+                createInstance(Ci.nsITransferable);
+    trans.addDataFlavor(CF_HTML);
+    cb.getData(trans, cb.kGlobalClipboard);
+    var data = {};
+    try {
+      trans.getTransferData(CF_HTML, data, {});
+      data = data.value.QueryInterface(Ci.nsISupportsCString).data;
+    } catch (e) {
+      setTimeout(function() copyCF_HTML_worker(success, failure), 100);
+      return;
+    }
+    success();
+  }
+
+  var trans = Cc["@mozilla.org/widget/transferable;1"].
+              createInstance(Ci.nsITransferable);
+  trans.addDataFlavor(CF_HTML);
+  var data = Cc["@mozilla.org/supports-cstring;1"].
+             createInstance(Ci.nsISupportsCString);
+  data.data = cfhtml;
+  trans.setTransferData(CF_HTML, data, cfhtml.length);
+  cb.setData(trans, null, cb.kGlobalClipboard);
+  copyCF_HTML_worker(success, failure);
+}
+
+function loadCF_HTMLdata(filename) {
+  var req = new XMLHttpRequest();
+  req.open("GET", filename, false);
+  req.overrideMimeType("text/plain; charset=x-user-defined");
+  req.send(null);
+  ok(req.status, 200, "Could not read the binary file " + filename);
+  return req.responseText;
+}
+
+var gTests = [
+  // Copied from Firefox
+  {fileName: "cfhtml-firefox.txt", expected: "Firefox"},
+  // Copied from OpenOffice.org
+  {fileName: "cfhtml-ooo.txt", expected: "hello"},
+  // Copied from IE
+  {fileName: "cfhtml-ie.txt", expected: "browser"},
+  // Copied from Chromium
+  {fileName: "cfhtml-chromium.txt", expected: "Pacific"},
+];
+var gTestIndex = 0;
+
+SimpleTest.waitForExplicitFinish();
+
+for (var i = 0; i < gTests.length; ++i) {
+  gTests[i].data = loadCF_HTMLdata("data/" + gTests[i].fileName);
+}
+
+function runTest() {
+  var test = gTests[gTestIndex++];
+
+  copyCF_HTML(test.data, function() {
+    // contenteditable
+    var contentEditable = document.getElementById("editor1");
+    contentEditable.innerHTML = "";
+    contentEditable.focus();
+    synthesizeKey("v", {accelKey: true});
+    isnot(contentEditable.textContent.indexOf(test.expected), -1,
+      "Paste operation for " + test.fileName + " should be successful in contenteditable");
+
+    // designMode
+    var iframe = document.getElementById("editor2");
+    iframe.addEventListener("load", function() {
+      iframe.removeEventListener("load", arguments.callee, false);
+      var doc = iframe.contentDocument;
+      var win = doc.defaultView;
+      setTimeout(function() {
+        win.addEventListener("focus", function() {
+          win.removeEventListener("focus", arguments.callee, false);
+          doc.designMode = "on";
+          synthesizeKey("v", {accelKey: true}, win);
+          isnot(doc.body.textContent.indexOf(test.expected), -1,
+            "Paste operation for " + test.fileName + " should be successful in designMode");
+
+          if (gTestIndex == gTests.length)
+            SimpleTest.finish();
+          else
+            runTest();
+        }, false);
+        win.focus();
+      }, 0);
+    }, false);
+    iframe.src = "data:text/html,";
+  }, SimpleTest.finish);
+}
+
+var isMac = ("nsILocalFileMac" in Components.interfaces);
+if (isMac)
+  SimpleTest.waitForFocus(runTest);
+else {
+  // This test is not yet supported on non-Mac platforms, see bug 574005.
+  todo(false, "Test not supported on this platform");
+  SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>