1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/text/tests/test_bug471722.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 +<html> 1.9 +<!-- 1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=471722 1.11 +--> 1.12 + 1.13 +<head> 1.14 + <title>Test for Bug 471722</title> 1.15 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.17 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.18 +</head> 1.19 + 1.20 +<body onload="doTest();"> 1.21 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=471722">Mozilla Bug 471722</a> 1.22 + <p id="display"></p> 1.23 + <div id="content" style="display: none"> 1.24 + </div> 1.25 + 1.26 + <pre id="test"> 1.27 + <script type="application/javascript"> 1.28 + 1.29 + /** Test for Bug 471722 **/ 1.30 + 1.31 + SimpleTest.waitForExplicitFinish(); 1.32 + 1.33 + function doTest() { 1.34 + var t1 = $("t1"); 1.35 + var editor = null; 1.36 + 1.37 + if (t1 instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) 1.38 + editor = SpecialPowers.wrap(t1).editor; 1.39 + ok(editor, "able to get editor for the element"); 1.40 + t1.focus(); 1.41 + t1.select(); 1.42 + 1.43 + try { 1.44 + 1.45 + // Cut the initial text in the textbox 1.46 + ok(editor.canCut(), "can cut text"); 1.47 + editor.cut(); 1.48 + is(t1.value, "", "initial text was removed"); 1.49 + 1.50 + // So now we will have emptied the textfield 1.51 + // and the editor will have created a bogus node 1.52 + // Check the transaction is in the undo stack... 1.53 + var t1Enabled = {}; 1.54 + var t1CanUndo = {}; 1.55 + editor.canUndo(t1Enabled, t1CanUndo); 1.56 + ok(t1CanUndo.value, "undo is enabled"); 1.57 + 1.58 + // Undo the cut 1.59 + editor.undo(1); 1.60 + is(t1.value, "minefield", "text reinserted"); 1.61 + 1.62 + // So now, the cut should be in the redo stack, 1.63 + // so executing the redo will clear the text once again 1.64 + // and reinsert the bogus node that was removed after undo. 1.65 + // This will require the editor to figure out that we have a 1.66 + // bogus node again... 1.67 + var t1CanRedo = {}; 1.68 + editor.canRedo(t1Enabled, t1CanRedo); 1.69 + ok(t1CanRedo.value, "redo is enabled"); 1.70 + editor.redo(1); 1.71 + 1.72 + // Did the editor notice a bogus node reappeared? 1.73 + is(t1.value, "", "editor found bogus node"); 1.74 + } catch (e) { 1.75 + ok(false, "test failed with error "+e); 1.76 + } 1.77 + SimpleTest.finish(); 1.78 + } 1.79 + </script> 1.80 + </pre> 1.81 + 1.82 + <input type="text" value="minefield" id="t1" /> 1.83 +</body> 1.84 +</html>