Bug 1248128 - Test for spurious propagation of failed selection-move command to the root, causing unwanted scrolling. r=roc
authorJonathan Kew <jkew@mozilla.com>
Wed, 17 Feb 2016 12:05:10 +0000
changeset 331610 c44734ba6500fca79424cf1f2d397162bbb55127
parent 331609 12fb5bc313d7d9ffaf570db7238c95d4f0ed873b
child 331611 ee60dc3d06556a23222a8c25a93aaa818ccca9b9
push id11020
push userjolesen@mozilla.com
push dateWed, 17 Feb 2016 18:16:38 +0000
reviewersroc
bugs1248128
milestone47.0a1
Bug 1248128 - Test for spurious propagation of failed selection-move command to the root, causing unwanted scrolling. r=roc
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/test_bug1248128.html
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -23,16 +23,17 @@ skip-if = buildapp == 'mulet'
 [test_bug1053048.html]
 [test_bug1100966.html]
 [test_bug1102906.html]
 [test_bug1101392.html]
 [test_bug1140105.html]
 [test_bug1140617.xul]
 [test_bug1153237.html]
 [test_bug1154791.html]
+[test_bug1248128.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_selection_move_commands.xul]
 [test_texteditor_keyevent_handling.html]
 skip-if = (debug && os=='win') || (os == 'linux') # Bug 1116205, leaks on windows debug, fails delete key on linux
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1248128.html
@@ -0,0 +1,52 @@
+<!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 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");
+    }
+	catch (e) {
+	  ok(true, "unable to perform kMoveLeft");
+	}
+
+    ok(outer.scrollTop == scroll,
+       "scroll is unchanged: got " + outer.scrollTop + ", expected " + scroll);
+
+    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>
+<div style="height: 200px;"></div>
+</body>
+</html>