editor/libeditor/base/tests/test_bug773262.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.

     1 <!doctype html>
     2 <!--
     3 https://bugzilla.mozilla.org/show_bug.cgi?id=773262
     4 -->
     5 <title>Test for Bug 773262</title>
     6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
     7 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
     8 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=773262">Mozilla Bug 773262</a></p>
     9 <iframe></iframe>
    10 <script>
    11 function runTest(doc, desc) {
    12   is(doc.queryCommandEnabled("undo"), false,
    13      desc + ": Undo shouldn't be enabled yet");
    14   is(doc.queryCommandEnabled("redo"), false,
    15      desc + ": Redo shouldn't be enabled yet");
    16   is(doc.body.innerHTML, "<p>Hello</p>", desc + ": Wrong initial innerHTML");
    18   doc.getSelection().selectAllChildren(doc.body.firstChild);
    19   doc.execCommand("bold");
    20   is(doc.queryCommandEnabled("undo"), true,
    21      desc + ": Undo should be enabled after bold");
    22   is(doc.queryCommandEnabled("redo"), false,
    23      desc + ": Redo still shouldn't be enabled");
    24   is(doc.body.innerHTML, "<p><b>Hello</b></p>",
    25      desc + ": Wrong innerHTML after bold");
    27   doc.execCommand("undo");
    28   is(doc.queryCommandEnabled("undo"), false,
    29      desc + ": Undo should be disabled again");
    30   is(doc.queryCommandEnabled("redo"), true,
    31      desc + ": Redo should be enabled now");
    32   is(doc.body.innerHTML, "<p>Hello</p>",
    33      desc + ": Wrong innerHTML after undo");
    35   doc.execCommand("redo");
    36   is(doc.queryCommandEnabled("undo"), true,
    37      desc + ": Undo should be enabled after redo");
    38   is(doc.queryCommandEnabled("redo"), false,
    39      desc + ": Redo should be disabled again");
    40   is(doc.body.innerHTML, "<p><b>Hello</b></p>",
    41      desc + ": Wrong innerHTML after redo");
    42 }
    44 SimpleTest.waitForExplicitFinish();
    45 addLoadEvent(function() {
    46   var doc = document.querySelector("iframe").contentDocument;
    48   // First turn on designMode and run the test like that, as a sanity check.
    49   doc.body.innerHTML = "<p>Hello</p>";
    50   doc.designMode = "on";
    51   runTest(doc, "1");
    53   // Now to test the actual bug: repeat all the above, but with designMode
    54   // toggled.  This should clear the undo history, so everything should be
    55   // exactly as before.
    56   doc.designMode = "off";
    57   doc.body.innerHTML = "<p>Hello</p>";
    58   doc.designMode = "on";
    59   runTest(doc, "2");
    61   SimpleTest.finish();
    62 });
    63 </script>

mercurial