|
1 <!DOCTYPE HTML> |
|
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
3 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
5 <html> |
|
6 <!-- |
|
7 https://bugzilla.mozilla.org/show_bug.cgi?id=471722 |
|
8 --> |
|
9 |
|
10 <head> |
|
11 <title>Test for Bug 471722</title> |
|
12 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
14 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
15 </head> |
|
16 |
|
17 <body onload="doTest();"> |
|
18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=471722">Mozilla Bug 471722</a> |
|
19 <p id="display"></p> |
|
20 <div id="content" style="display: none"> |
|
21 </div> |
|
22 |
|
23 <pre id="test"> |
|
24 <script type="application/javascript"> |
|
25 |
|
26 /** Test for Bug 471722 **/ |
|
27 |
|
28 SimpleTest.waitForExplicitFinish(); |
|
29 |
|
30 function doTest() { |
|
31 var t1 = $("t1"); |
|
32 var editor = null; |
|
33 |
|
34 if (t1 instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) |
|
35 editor = SpecialPowers.wrap(t1).editor; |
|
36 ok(editor, "able to get editor for the element"); |
|
37 t1.focus(); |
|
38 t1.select(); |
|
39 |
|
40 try { |
|
41 |
|
42 // Cut the initial text in the textbox |
|
43 ok(editor.canCut(), "can cut text"); |
|
44 editor.cut(); |
|
45 is(t1.value, "", "initial text was removed"); |
|
46 |
|
47 // So now we will have emptied the textfield |
|
48 // and the editor will have created a bogus node |
|
49 // Check the transaction is in the undo stack... |
|
50 var t1Enabled = {}; |
|
51 var t1CanUndo = {}; |
|
52 editor.canUndo(t1Enabled, t1CanUndo); |
|
53 ok(t1CanUndo.value, "undo is enabled"); |
|
54 |
|
55 // Undo the cut |
|
56 editor.undo(1); |
|
57 is(t1.value, "minefield", "text reinserted"); |
|
58 |
|
59 // So now, the cut should be in the redo stack, |
|
60 // so executing the redo will clear the text once again |
|
61 // and reinsert the bogus node that was removed after undo. |
|
62 // This will require the editor to figure out that we have a |
|
63 // bogus node again... |
|
64 var t1CanRedo = {}; |
|
65 editor.canRedo(t1Enabled, t1CanRedo); |
|
66 ok(t1CanRedo.value, "redo is enabled"); |
|
67 editor.redo(1); |
|
68 |
|
69 // Did the editor notice a bogus node reappeared? |
|
70 is(t1.value, "", "editor found bogus node"); |
|
71 } catch (e) { |
|
72 ok(false, "test failed with error "+e); |
|
73 } |
|
74 SimpleTest.finish(); |
|
75 } |
|
76 </script> |
|
77 </pre> |
|
78 |
|
79 <input type="text" value="minefield" id="t1" /> |
|
80 </body> |
|
81 </html> |