tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug773262.html (2248B)


      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");
     17 
     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");
     26 
     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");
     34 
     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 }
     43 
     44 SimpleTest.waitForExplicitFinish();
     45 addLoadEvent(function() {
     46  var doc = document.querySelector("iframe").contentDocument;
     47 
     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");
     52 
     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");
     60 
     61  SimpleTest.finish();
     62 });
     63 </script>