editor/libeditor/html/tests/test_bug668599.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.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=668599
     5 -->
     6 <head>
     7   <title>Test for Bug 668599</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668599">Mozilla Bug 668599</a>
    14 <p id="display"></p>
    15 <div id="content">
    16   <div id="test1">
    17     block <span contenteditable>type here</span> block
    18   </div>
    19   <div id="test2">
    20     <p contenteditable>
    21       block <span>type here</span> block
    22     </p>
    23   </div>
    24 </div>
    26 <pre id="test">
    27 <script type="application/javascript">
    29 /** Test for Bug 668599 **/
    30 SimpleTest.waitForExplicitFinish();
    31 SimpleTest.waitForFocus(runTests);
    33 function select(element) {
    34   // select the element text content
    35   var userSelection = window.getSelection();
    36   window.getSelection().removeAllRanges(); 
    37   var range = document.createRange();
    38   range.setStart(element.firstChild, 0);
    39   range.setEnd(element.firstChild, element.textContent.length);
    40   userSelection.addRange(range);
    41 };
    43 function runTests() {
    44   var span = document.querySelector("#test1 span");
    46   // editable <span> => the <span> *content* should be deleted
    47   select(span);
    48   span.focus();
    49   synthesizeKey("x", {});
    50   is(span.textContent, "x", "The <span> content should have been replaced by 'x'.");
    52   // same thing, but using [Del] instead of typing some text
    53   document.execCommand("Undo", false, null);
    54   select(span);
    55   span.focus();
    56   synthesizeKey("VK_DELETE", {});
    57   is(span.textContent, "", "The <span> content should have been deleted.");
    59   // <span> in editable block => the <span> *element* should be deleted
    60   select(document.querySelector("#test2 span"));
    61   document.querySelector("#test2 [contenteditable]").focus();
    62   synthesizeKey("VK_DELETE", {});
    63   is(document.querySelector("#test2 span"), null,
    64     "The <span> element should have been deleted.");
    66   // done
    67   SimpleTest.finish();
    68 }
    70 </script>
    71 </pre>
    72 </body>
    73 </html>

mercurial