editor/libeditor/html/tests/test_bug570144.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 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=570144
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 570144</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=570144">Mozilla Bug 570144</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content">
michael@0 16 <!-- editable paragraphs in list item -->
michael@0 17 <section id="test1">
michael@0 18 <ol>
michael@0 19 <li><p contenteditable>foo</p></li>
michael@0 20 </ol>
michael@0 21 <ul>
michael@0 22 <li><p contenteditable>foo</p></li>
michael@0 23 </ul>
michael@0 24 <dl>
michael@0 25 <dt>foo</dt>
michael@0 26 <dd><p contenteditable>bar</p></dd>
michael@0 27 </dl>
michael@0 28 </section>
michael@0 29 <!-- paragraphs in editable list item -->
michael@0 30 <section id="test2">
michael@0 31 <ol>
michael@0 32 <li contenteditable><p>foo</p></li>
michael@0 33 </ol>
michael@0 34 <ul>
michael@0 35 <li contenteditable><p>foo</p></li>
michael@0 36 </ul>
michael@0 37 <dl>
michael@0 38 <dt>foo</dt>
michael@0 39 <dd contenteditable><p>bar</p></dd>
michael@0 40 </dl>
michael@0 41 </section>
michael@0 42 <!-- paragraphs in editable list -->
michael@0 43 <section id="test3">
michael@0 44 <ol contenteditable>
michael@0 45 <li><p>foo</p></li>
michael@0 46 </ol>
michael@0 47 <ul contenteditable>
michael@0 48 <li><p>foo</p></li>
michael@0 49 </ul>
michael@0 50 <dl contenteditable>
michael@0 51 <dt>foo</dt>
michael@0 52 <dd><p>bar</p></dd>
michael@0 53 </dl>
michael@0 54 </section>
michael@0 55 </div>
michael@0 56
michael@0 57 <pre id="test">
michael@0 58 <script type="application/javascript">
michael@0 59
michael@0 60 /** Test for Bug 570144 **/
michael@0 61 SimpleTest.waitForExplicitFinish();
michael@0 62 SimpleTest.waitForFocus(runTests);
michael@0 63
michael@0 64 function try2split(list) {
michael@0 65 var editor = list.hasAttribute("contenteditable")
michael@0 66 ? list : list.querySelector("*[contenteditable]");
michael@0 67 editor.focus();
michael@0 68 // put the caret at the end of the paragraph
michael@0 69 var selection = window.getSelection();
michael@0 70 if (editor.nodeName.toLowerCase() == "p")
michael@0 71 selection.selectAllChildren(editor);
michael@0 72 else
michael@0 73 selection.selectAllChildren(editor.querySelector("p"));
michael@0 74 selection.collapseToEnd();
michael@0 75 // simulate a [Return] keypress
michael@0 76 synthesizeKey("VK_RETURN", {});
michael@0 77 }
michael@0 78
michael@0 79 function testSection(element, context, shouldCreateLI, shouldCreateP) {
michael@0 80 var nbLI = shouldCreateLI ? 2 : 1; // number of expected list items
michael@0 81 var nbP = shouldCreateP ? 2 : 1; // number of expected paragraphs
michael@0 82
michael@0 83 function message(nodeName, dup) {
michael@0 84 return context + ":[Return] should " + (dup ? "" : "not ")
michael@0 85 + "create another <" + nodeName + ">."
michael@0 86 }
michael@0 87 var msgP = message("p", shouldCreateP);
michael@0 88 var msgLI = message("li", shouldCreateLI);
michael@0 89 var msgDT = message("dt", shouldCreateLI);
michael@0 90 var msgDD = message("dd", false);
michael@0 91
michael@0 92 const ol = element.querySelector("ol");
michael@0 93 try2split(ol);
michael@0 94 is(ol.querySelectorAll("li").length, nbLI, msgLI);
michael@0 95 is(ol.querySelectorAll("p").length, nbP, msgP);
michael@0 96
michael@0 97 const ul = element.querySelector("ul");
michael@0 98 try2split(ul);
michael@0 99 is(ul.querySelectorAll("li").length, nbLI, msgLI);
michael@0 100 is(ul.querySelectorAll("p").length, nbP, msgP);
michael@0 101
michael@0 102 const dl = element.querySelector("dl");
michael@0 103 try2split(dl);
michael@0 104 is(dl.querySelectorAll("dt").length, nbLI, msgDT);
michael@0 105 is(dl.querySelectorAll("dd").length, 1, msgDD);
michael@0 106 is(dl.querySelectorAll("p").length, nbP, msgP);
michael@0 107 }
michael@0 108
michael@0 109 function runTests() {
michael@0 110 testSection(document.getElementById("test1"), "editable paragraph in list item", false, false);
michael@0 111 testSection(document.getElementById("test2"), "paragraph in editable list item", false, true);
michael@0 112 testSection(document.getElementById("test3"), "paragraph in editable list", true, false);
michael@0 113 /* Note: concerning #test3, it would be preferrable that [Return] creates
michael@0 114 * another paragraph in another list item (i.e. last argument = 'true').
michael@0 115 * Currently it just creates an empty list item, which is acceptable.
michael@0 116 */
michael@0 117 SimpleTest.finish();
michael@0 118 }
michael@0 119
michael@0 120 </script>
michael@0 121 </pre>
michael@0 122 </body>
michael@0 123 </html>

mercurial