editor/libeditor/base/tests/test_bug773262.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial