editor/libeditor/html/tests/test_bug697842.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>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=697842
     5 -->
     6 <head>
     7   <title>Test for Bug 697842</title>
     8   <script type="application/javascript" src="/MochiKit/packed.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    11   <link rel="stylesheet" type="text/css"
    12           href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    13 </head>
    14 <body>
    15 <div id="display">
    16   <p id="editor" contenteditable style="min-height: 1.5em;"></p>
    17 </div>
    18 <div id="content" style="display: none">
    20 </div>
    21 <pre id="test">
    22 </pre>
    24 <script class="testbody" type="application/javascript">
    26 /** Test for Bug 697842 **/
    27 SimpleTest.waitForExplicitFinish();
    28 SimpleTest.waitForFocus(runTests);
    30 function runTests()
    31 {
    32   var editor = document.getElementById("editor");
    33   editor.focus();
    35   SimpleTest.executeSoon(function() {
    36     var composingString = "";
    38     function handler(aEvent) {
    39       if (aEvent.type != "text") {
    40         is(aEvent.data, composingString, "mismatch composition string");
    41       }
    42       aEvent.stopPropagation();
    43       aEvent.preventDefault();
    44     }
    46     editor.addEventListener("compositionstart", handler, true);
    47     editor.addEventListener("compositionend", handler, true);
    48     editor.addEventListener("compositionupdate", handler, true);
    49     editor.addEventListener("text", handler, true);
    51     // start composition
    52     synthesizeComposition({ type: "compositionstart" });
    54     // input first character
    55     composingString = "\u306B";
    56     synthesizeComposition({ type: "compositionupdate", data: composingString });
    57     synthesizeText(
    58       { "composition":
    59         { "string": composingString,
    60           "clauses":
    61           [
    62             { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
    63           ]
    64         },
    65         "caret": { "start": 1, "length": 0 }
    66       });
    68     // input second character
    69     composingString = "\u306B\u3085";
    70     synthesizeComposition({ type: "compositionupdate", data: composingString });
    71     synthesizeText(
    72       { "composition":
    73         { "string": composingString,
    74           "clauses":
    75           [
    76             { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
    77           ]
    78         },
    79         "caret": { "start": 2, "length": 0 }
    80       });
    82     // convert them
    83     synthesizeText(
    84       { "composition":
    85         { "string": composingString,
    86           "clauses":
    87           [
    88             { "length": 2,
    89               "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
    90           ]
    91         },
    92         "caret": { "start": 2, "length": 0 }
    93       });
    95     // commit
    96     synthesizeText(
    97       { "composition":
    98         { "string": composingString,
    99           "clauses":
   100           [
   101             { "length": 0, "attr": 0 }
   102           ]
   103         },
   104         "caret": { "start": 2, "length": 0 }
   105       });
   107     synthesizeComposition({ type: "compositionend", data: composingString });
   109     is(editor.innerHTML, composingString,
   110        "editor has unexpected result");
   112     editor.removeEventListener("compositionstart", handler, true);
   113     editor.removeEventListener("compositionend", handler, true);
   114     editor.removeEventListener("compositionupdate", handler, true);
   115     editor.removeEventListener("text", handler, true);
   117     SimpleTest.finish();
   118   });
   119 }
   122 </script>
   123 </body>
   125 </html>

mercurial