editor/libeditor/html/tests/test_bug410986.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=410986
     5 -->
     6 <head>
     7   <title>Test for Bug 410986</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=410986">Mozilla Bug 410986</a>
    14 <p id="display"></p>
    15 <div id="content">
    16   <div id="contents"><span style="color: green;">green text</span></div>
    17   <div id="editor" contenteditable="true"></div>
    18 </div>
    19 <pre id="test">
    20 <script type="application/javascript">
    22 /** Test for Bug 410986 **/
    24 var gPasteEvents = 0;
    25 document.getElementById("editor").addEventListener("paste", function() {
    26   ++gPasteEvents;
    27 }, false);
    29 SimpleTest.waitForExplicitFinish();
    30 SimpleTest.waitForFocus(function() {
    31   getSelection().selectAllChildren(document.getElementById("contents"));
    32   SimpleTest.waitForClipboard("green text",
    33     function() {
    34       synthesizeKey("C", {accelKey: true});
    35     },
    36     function() {
    37       var ed = document.getElementById("editor");
    38       ed.focus();
    39       if (navigator.platform.indexOf("Mac") >= 0) {
    40         synthesizeKey("V", {accelKey: true, shiftKey: true, altKey: true});
    41       } else {
    42         synthesizeKey("V", {accelKey: true, shiftKey: true});
    43       }
    44       is(ed.innerHTML, "green text", "Content should be pasted in plaintext format");
    45       is(gPasteEvents, 1, "One paste event must be fired");
    47       ed.innerHTML = "";
    48       ed.blur();
    49       getSelection().selectAllChildren(document.getElementById("contents"));
    50       SimpleTest.waitForClipboard("green text",
    51         function() {
    52           synthesizeKey("C", {accelKey: true});
    53         },
    54         function() {
    55           var ed = document.getElementById("editor");
    56           ed.focus();
    57           synthesizeKey("V", {accelKey: true});
    58           isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
    59                 "Content should be pasted in HTML format");
    60           is(gPasteEvents, 2, "Two paste events must be fired");
    62           SimpleTest.finish();
    63         },
    64         function() {
    65           ok(false, "Failed to copy the second item to the clipboard");
    66           SimpleTest.finish();
    67         }
    68       );
    69     },
    70     function() {
    71       ok(false, "Failed to copy the first item to the clipboard");
    72       SimpleTest.finish();
    73     }
    74   );
    75 });
    77 </script>
    78 </pre>
    79 </body>
    80 </html>

mercurial