Bug 1271119 - Port test_bug1248128.html from chrome to plain; r=masayuki
authorAryeh Gregor <ayg@aryeh.name>
Mon, 31 Oct 2016 18:26:31 +0200
changeset 432280 8f480c1204e88df4803250112ed4736c65c734ee
parent 432279 62c0f7ba9e59a23fdc5900628ce59c3ac2780a70
child 432281 e688081176ae94c102b4213516a7f43cbd9455bf
push id34240
push userbmo:ttromey@mozilla.com
push dateTue, 01 Nov 2016 14:41:32 +0000
reviewersmasayuki
bugs1271119, 1248128
milestone52.0a1
Bug 1271119 - Port test_bug1248128.html from chrome to plain; r=masayuki I added an extra check to ensure that the test wasn't passing because doCommand() was throwing some unrelated exception, in case porting from chrome to plain changed behavior of doCommand(). MozReview-Commit-ID: LOo8yN8jkZo
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug1248128.html
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -7,17 +7,16 @@ support-files = green.png
 skip-if = buildapp == 'mulet'
 [test_bug599983.xul]
 skip-if = buildapp == 'mulet'
 [test_bug607584.xul]
 [test_bug616590.xul]
 [test_bug636465.xul]
 [test_bug780908.xul]
 [test_bug1102906.html]
-[test_bug1248128.html]
 [test_bug1248185.html]
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_text_input_handling.html]
 [test_dragdrop.html]
 skip-if = buildapp == 'mulet'
 [test_htmleditor_keyevent_handling.html]
 [test_set_document_title_transaction.html]
 [test_texteditor_keyevent_handling.html]
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -192,16 +192,17 @@ skip-if = toolkit == 'android' # bug 129
 skip-if = os == 'android'
 [test_bug1162952.html]
 [test_bug1181130-1.html]
 [test_bug1181130-2.html]
 [test_bug1186799.html]
 [test_bug1247483.html]
 subsuite = clipboard
 skip-if = toolkit == 'android'
+[test_bug1248128.html]
 [test_bug1250010.html]
 [test_bug1257363.html]
 [test_bug1258085.html]
 [test_bug1268736.html]
 
 [test_CF_HTML_clipboard.html]
 subsuite = clipboard
 [test_contenteditable_focus.html]
--- a/editor/libeditor/tests/test_bug1248128.html
+++ b/editor/libeditor/tests/test_bug1248128.html
@@ -1,49 +1,49 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=1248128
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 1248128</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   SimpleTest.waitForExplicitFinish();
 
   SimpleTest.waitForFocus(function() {
     var outer = document.querySelector("html");
     ok(outer.scrollTop == 0, "scrollTop is zero: got " + outer.scrollTop);
 
     var input = document.getElementById("testInput");
     input.focus();
 
     var scroll = outer.scrollTop;
     ok(scroll > 0, "element has scrolled: new value " + scroll);
 
-    const kMoveLeft = "cmd_moveLeft";
-    var controller =
-      top.document.commandDispatcher.getControllerForCommand(kMoveLeft);
-    ok((controller && controller.isCommandEnabled(kMoveLeft)),
-       "have " + kMoveLeft + " command");
-
     try {
-      controller.doCommand(kMoveLeft);
-	  ok(false, "should not be able to do kMoveLeft");
+      SpecialPowers.doCommand(window, "cmd_moveLeft");
+      ok(false, "should not be able to do kMoveLeft");
+    } catch (e) {
+      ok(true, "unable to perform kMoveLeft");
     }
-	catch (e) {
-	  ok(true, "unable to perform kMoveLeft");
-	}
 
     ok(outer.scrollTop == scroll,
        "scroll is unchanged: got " + outer.scrollTop + ", expected " + scroll);
 
+    // Make sure cmd_moveLeft isn't failing for some unrelated reason
+    synthesizeKey("a", {});
+    is(input.selectionStart, 1, "selectionStart after typing");
+    SpecialPowers.doCommand(window, "cmd_moveLeft");
+    is(input.selectionStart, 0, "selectionStart after move left");
+
     SimpleTest.finish();
   });
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1248128">Mozilla Bug 1248128</a>
 <div style="height: 2000px;"></div>
 <input type="text" id="testInput"></input>