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
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -19,17 +19,16 @@ skip-if = buildapp == 'mulet'
[test_bug780908.xul]
[test_bug830600.html]
subsuite = clipboard
[test_bug1053048.html]
[test_bug1100966.html]
[test_bug1102906.html]
[test_bug1140105.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]
[test_dragdrop.html]
skip-if = buildapp == 'mulet'
[test_htmleditor_keyevent_handling.html]
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -190,11 +190,12 @@ skip-if = toolkit == 'android' # bug 129
[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]
subsuite = clipboard
skip-if = toolkit == 'android'
+[test_bug1248128.html]
[test_bug1258085.html]
[test_bug1268736.html]
[test_selection_move_commands.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>