layout/forms/test/test_bug595310.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=595310
     5 -->
     6 <head>
     7   <title>Test for Bug 595310</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.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=595310">Mozilla Bug 595310</a>
    14 <p id="display"></p>
    15 <div id="content">
    16   <input id='i' value="bar">
    17   <textarea id='t'>bar</textarea>
    18 </div>
    19 <pre id="test">
    20 <script type="application/javascript">
    22 /** Test for Bug 595310 **/
    24 SimpleTest.waitForExplicitFinish();
    26 addLoadEvent(function() {
    27   // We want to compare to value="bar" and no placeholder shown.
    28   // That is what is currently showed.
    29   var s1 = snapshotWindow(window, false);
    31   var content = document.getElementById('content');
    32   var i = document.getElementById('i');
    33   var t = SpecialPowers.wrap(document.getElementById('t'));
    34   i.value = ""; i.placeholder = "foo";
    35   t.value = ""; t.placeholder = "foo";
    37   // Flushing.
    38   // Note: one call would have been enough actually but I didn't want to favour
    39   // one element... ;)
    40   i.getBoundingClientRect();
    41   t.getBoundingClientRect();
    43   function synthesizeDropText(aElement, aText)
    44   {
    45     var editor = SpecialPowers.wrap(aElement)
    46                               .QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement)
    47                               .editor
    48                               .QueryInterface(SpecialPowers.Ci.nsIPlaintextEditor);
    50     editor.insertText(aText);
    51   }
    53   // We insert "bar" and we should only see "bar" now.
    54   synthesizeDropText(i, "bar");
    55   synthesizeDropText(t, "bar");
    57   var s2 = snapshotWindow(window, false);
    59   ok(compareSnapshots(s1, s2, true)[0],
    60      "When setting the value, the placeholder should disappear.");
    62   SimpleTest.finish();
    63 });
    66 </script>
    67 </pre>
    68 </body>
    69 </html>

mercurial