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