1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/text/tests/test_bug625452.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=625452 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 625452</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=625452">Mozilla Bug 625452</a> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 +<input> 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 + 1.24 +/** Test for Bug 625452 **/ 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 +addLoadEvent(function() { 1.27 + var i = document.querySelector("input"); 1.28 + var inputCount = 0; 1.29 + i.addEventListener("input", function() inputCount++, false); 1.30 + 1.31 + // test cut 1.32 + i.focus(); 1.33 + i.value = "foo bar"; 1.34 + i.selectionStart = 0; 1.35 + i.selectionEnd = 4; 1.36 + synthesizeKey("X", {accelKey: true}); 1.37 + is(i.value, "bar", "Cut should work correctly"); 1.38 + is(inputCount, 1, "input event should be raised correctly"); 1.39 + 1.40 + // test undo 1.41 + synthesizeKey("Z", {accelKey: true}); 1.42 + is(i.value, "foo bar", "Undo should work correctly"); 1.43 + is(inputCount, 2, "input event should be raised correctly"); 1.44 + 1.45 + // test redo 1.46 + synthesizeKey("Z", {accelKey: true, shiftKey: true}); 1.47 + is(i.value, "bar", "Redo should work correctly"); 1.48 + is(inputCount, 3, "input event should be raised correctly"); 1.49 + 1.50 + // test delete 1.51 + i.selectionStart = 0; 1.52 + i.selectionEnd = 2; 1.53 + synthesizeKey("VK_DELETE", {}); 1.54 + is(i.value, "r", "Delete should work correctly"); 1.55 + is(inputCount, 4, "input event should be raised correctly"); 1.56 + 1.57 + // test DeleteSelection(eNone) 1.58 + i.value = "retest"; // the "r" common prefix is crucial here 1.59 + is(inputCount, 4, "input event should not have been raised"); 1.60 + 1.61 + // paste is tested in test_bug596001.html 1.62 + 1.63 + SimpleTest.finish(); 1.64 +}); 1.65 + 1.66 +</script> 1.67 +</pre> 1.68 +</body> 1.69 +</html>