Bug 1271119 - Port test_bug1140617.xul from chrome to plain; r?masayuki draft
authorAryeh Gregor <ayg@aryeh.name>
Tue, 30 Aug 2016 21:32:20 +0300
changeset 430258 a378994edab26d2d01a10d9a55fc58d6c0455188
parent 430257 08735488b9e61cc2a87e7e1ded752a5d39c496bd
child 430259 ff33ea4ad7b88c58078cc05ba7e044d4b515dbd5
push id33788
push userayg@aryeh.name
push dateThu, 27 Oct 2016 12:44:14 +0000
reviewersmasayuki
bugs1271119, 1140617
milestone52.0a1
Bug 1271119 - Port test_bug1140617.xul from chrome to plain; r?masayuki Possible issue: the previous version saved document.popupNode and restored it after copying the image, and the new version does not (because I don't know how). The test seems to pass anyway. MozReview-Commit-ID: 7g0JCYxI7x8
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug1140617.html
editor/libeditor/tests/test_bug1140617.xul
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -18,18 +18,16 @@ skip-if = buildapp == 'mulet'
 [test_bug636465.xul]
 [test_bug780908.xul]
 [test_bug830600.html]
 subsuite = clipboard
 [test_bug1053048.html]
 [test_bug1100966.html]
 [test_bug1102906.html]
 [test_bug1140105.html]
-[test_bug1140617.xul]
-subsuite = clipboard
 [test_bug1153237.html]
 [test_bug1154791.html]
 [test_bug1248128.html]
 [test_bug1248185.html]
 [test_bug1250010.html]
 [test_bug1257363.html]
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_text_input_handling.html]
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -176,16 +176,19 @@ skip-if = toolkit == 'android' # bug 105
 [test_keypress_untrusted_event.html]
 [test_root_element_replacement.html]
 [test_select_all_without_body.html]
 [test_spellcheck_pref.html]
 skip-if = toolkit == 'android'
 [test_bug1068979.html]
 subsuite = clipboard
 [test_bug1109465.html]
+[test_bug1140617.html]
+subsuite = clipboard
+skip-if = toolkit == 'android' # bug 1299578
 [test_bug1162952.html]
 [test_bug1186799.html]
 [test_bug1181130-1.html]
 [test_bug1181130-2.html]
 [test_backspace_vs.html]
 [test_css_chrome_load_access.html]
 skip-if = toolkit == 'android' # chrome urls not available due to packaging
 [test_bug1247483.html]
rename from editor/libeditor/tests/test_bug1140617.xul
rename to editor/libeditor/tests/test_bug1140617.html
--- a/editor/libeditor/tests/test_bug1140617.xul
+++ b/editor/libeditor/tests/test_bug1140617.html
@@ -1,70 +1,37 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin"
-                 type="text/css"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
-                 type="text/css"?>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1140617
--->
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="Mozilla Bug 1140617" onload="runTest();">
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-
-  <body xmlns="http://www.w3.org/1999/xhtml">
-  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1140617"
-     target="_blank">Mozilla Bug 1140617</a>
-  <p/>
-  <iframe id="i1" width="200" height="100" src="about:blank" /><br />
-  <img id="i" src="green.png" />
-  <p/>
-  <pre id="test">
-  </pre>
-  </body>
-  <script class="testbody" type="application/javascript">
-  <![CDATA[
-
+<!doctype html>
+<title>Mozilla Bug 1140617</title>
+<link rel=stylesheet href="/tests/SimpleTest/test.css">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1140617"
+   target="_blank">Mozilla Bug 1140617</a>
+<iframe id="i1" width="200" height="100" src="about:blank"></iframe>
+<img id="i" src="green.png">
+<script>
 function runTest() {
-  function pasteIntoAndCheck() {
-    var e = document.getElementById('i1');
-    var doc = e.contentDocument;
-    doc.designMode = "on";
-    doc.defaultView.focus();
-    var selection = doc.defaultView.getSelection();
-    selection.removeAllRanges();
-    selection.selectAllChildren(doc.body);
-    selection.collapseToEnd();
-
-    doc.execCommand("fontname", false, "Arial");
-    doc.execCommand("bold", false, null);
-    doc.execCommand("insertText", false, "12345");
-    doc.execCommand("paste", false, null);
-    doc.execCommand("insertText", false, "a");
+  SpecialPowers.setCommandNode(window, document.getElementById("i"));
+  SpecialPowers.doCommand(window, "cmd_copyImageContents");
 
-    is(doc.queryCommandValue("fontname"), "Arial", "Arial expected");
-    is(doc.queryCommandState("bold"), true, "Bold expected");
-  }
-
-  function copyToClipBoard() {
-    var tmpNode = document.popupNode;
-    document.popupNode = document.getElementById("i");
+  var e = document.getElementById('i1');
+  var doc = e.contentDocument;
+  doc.designMode = "on";
+  doc.defaultView.focus();
+  var selection = doc.defaultView.getSelection();
+  selection.removeAllRanges();
+  selection.selectAllChildren(doc.body);
+  selection.collapseToEnd();
 
-    const kCmd = "cmd_copyImageContents";
-    var controller = top.document.commandDispatcher
-                     .getControllerForCommand(kCmd);
-    ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
-    controller.doCommand(kCmd);
+  doc.execCommand("fontname", false, "Arial");
+  doc.execCommand("bold", false, null);
+  doc.execCommand("insertText", false, "12345");
+  doc.execCommand("paste", false, null);
+  doc.execCommand("insertText", false, "a");
 
-    document.popupNode = tmpNode;
-  }
-
-  copyToClipBoard();
-  pasteIntoAndCheck();
+  is(doc.queryCommandValue("fontname"), "Arial", "Arial expected");
+  is(doc.queryCommandState("bold"), true, "Bold expected");
 
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
-]]>
+addLoadEvent(runTest);
 </script>
-</window>