editor/libeditor/text/tests/test_bug471319.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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=471319
michael@0 8 -->
michael@0 9
michael@0 10 <head>
michael@0 11 <title>Test for Bug 471319</title>
michael@0 12 <script type="application/javascript"
michael@0 13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 14 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
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=471319">Mozilla Bug 471319</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;version=1.7">
michael@0 25
michael@0 26 /** Test for Bug 471319 **/
michael@0 27
michael@0 28 SimpleTest.waitForExplicitFinish();
michael@0 29
michael@0 30 function doTest() {
michael@0 31 let t1 = $("t1");
michael@0 32 let editor = null;
michael@0 33
michael@0 34 // Test 1: Undo on an empty editor - the editor should not forget about
michael@0 35 // the bogus node
michael@0 36 t1.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
michael@0 37 t1Editor = t1.editor;
michael@0 38
michael@0 39 // Did the editor recognize the new bogus node?
michael@0 40 t1Editor.undo(1);
michael@0 41 ok(!t1.value, "<br> still recognized as bogus node on undo");
michael@0 42
michael@0 43
michael@0 44 // Test 2: Redo on an empty editor - the editor should not forget about
michael@0 45 // the bogus node
michael@0 46 let t2 = $("t2");
michael@0 47 t2.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
michael@0 48 t2Editor = t2.editor;
michael@0 49
michael@0 50 // Did the editor recognize the new bogus node?
michael@0 51 t2Editor.redo(1);
michael@0 52 ok(!t2.value, "<br> still recognized as bogus node on redo");
michael@0 53
michael@0 54
michael@0 55 // Test 3: Undoing a batched transaction where both end points of the
michael@0 56 // transaction are the bogus node - the bogus node should still be
michael@0 57 // recognized as bogus
michael@0 58 t1Editor.transactionManager.beginBatch(null);
michael@0 59 t1.value = "mozilla";
michael@0 60 t1.value = "";
michael@0 61 t1Editor.transactionManager.endBatch(false);
michael@0 62 t1Editor.undo(1);
michael@0 63 ok(!t1.value,
michael@0 64 "recreated <br> from undo transaction recognized as bogus");
michael@0 65
michael@0 66
michael@0 67 // Test 4: Redoing a batched transaction where both end points of the
michael@0 68 // transaction are the bogus node - the bogus node should still be
michael@0 69 // recognized as bogus
michael@0 70 t1Editor.redo(1);
michael@0 71 ok(!t1.value,
michael@0 72 "recreated <br> from redo transaction recognized as bogus");
michael@0 73 SimpleTest.finish();
michael@0 74 }
michael@0 75 </script>
michael@0 76 </pre>
michael@0 77
michael@0 78 <input type="text" id="t1" />
michael@0 79 <input type="text" id="t2" />
michael@0 80 </body>
michael@0 81 </html>

mercurial