Bug 1271119 - Port test_bug646194.xul from chrome to mochitest; r?masayuki draft
authorAryeh Gregor <ayg@aryeh.name>
Tue, 30 Aug 2016 18:40:55 +0300
changeset 430256 951f83592036410b29cb89a08832b800c2423ec4
parent 430255 1e236ced983c072155a6c499c88798b6f762145b
child 430257 08735488b9e61cc2a87e7e1ded752a5d39c496bd
push id33788
push userayg@aryeh.name
push dateThu, 27 Oct 2016 12:44:14 +0000
reviewersmasayuki
bugs1271119, 646194
milestone52.0a1
Bug 1271119 - Port test_bug646194.xul from chrome to mochitest; r?masayuki MozReview-Commit-ID: Lx05BEKQiwO
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug646194.html
editor/libeditor/tests/test_bug646194.xul
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -11,17 +11,16 @@ support-files = spellcheck.js
 [test_bug569988.html]
 skip-if = buildapp == 'mulet'
 [test_bug599983.xul]
 skip-if = buildapp == 'mulet'
 [test_bug607584.xul]
 [test_bug616590.xul]
 [test_bug635636.html]
 [test_bug636465.xul]
-[test_bug646194.xul]
 [test_bug780908.xul]
 [test_bug830600.html]
 subsuite = clipboard
 [test_bug1053048.html]
 [test_bug1100966.html]
 [test_bug1102906.html]
 [test_bug1101392.html]
 subsuite = clipboard
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -114,16 +114,17 @@ skip-if = toolkit == 'android' #TIMED_OU
 skip-if = toolkit == 'android' #bug 957797
 [test_bug625452.html]
 [test_bug629845.html]
 [test_bug638596.html]
 [test_bug640321.html]
 skip-if = android_version == '18' # bug 1147989
 [test_bug641466.html]
 [test_bug645914.html]
+[test_bug646194.html]
 [test_bug668599.html]
 [test_bug674770-1.html]
 subsuite = clipboard
 skip-if = toolkit == 'android'
 [test_bug674770-2.html]
 subsuite = clipboard
 skip-if = toolkit == 'android'
 [test_bug674861.html]
rename from editor/libeditor/tests/test_bug646194.xul
rename to editor/libeditor/tests/test_bug646194.html
--- a/editor/libeditor/tests/test_bug646194.xul
+++ b/editor/libeditor/tests/test_bug646194.html
@@ -1,63 +1,38 @@
-<?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=646194
--->
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="Mozilla Bug 646194" 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=646194"
-     target="_blank">Mozilla Bug 646194</a>
-  <p/>
-  <iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
-  <p/>
-  <pre id="test">
-  </pre>
-  </body>
-  <script class="testbody" type="application/javascript">
-  <![CDATA[
-
+<!doctype html>
+<title>Mozilla Bug 646194</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=646194"
+   target="_blank">Mozilla Bug 646194</a>
+<iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"></iframe>
+<script>
 SimpleTest.expectAssertions(1);
 
 function runTest() {
-  function doCommand(aCmd) {
-    var controller = top.document.commandDispatcher
-                     .getControllerForCommand(aCmd);
-    ok((controller && controller.isCommandEnabled(aCmd)), "command available");
-    controller.doCommand(aCmd);
-  }
-
   var i = document.getElementById("i");
   i.focus();
   var win = i.contentWindow;
   var doc = i.contentDocument;
   var t = doc.getElementById("t");
   t.focus();
   // put the caret at the end
   win.getSelection().collapse(t.firstChild, 11);
 
   // Simulate pression Option+Delete on Mac
   // We do things this way because not every platform can invoke this
   // command using the available key bindings.
-  doCommand("cmd_wordPrevious");
-  doCommand("cmd_wordPrevious");
-  doCommand("cmd_deleteWordBackward");
-  doCommand("cmd_deleteWordBackward");
+  SpecialPowers.doCommand(window, "cmd_wordPrevious");
+  SpecialPowers.doCommand(window, "cmd_wordPrevious");
+  SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
+  SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
 
   // If we reach here, we haven't crashed.  Phew!
   // But let's check the value too, now that we're here.
   is(t.textContent, "me now", "The command has worked correctly");
 
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
-]]>
+addLoadEvent(runTest);
 </script>
-</window>