1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/test/test_bug595310.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=595310 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 595310</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=595310">Mozilla Bug 595310</a> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 + <input id='i' value="bar"> 1.20 + <textarea id='t'>bar</textarea> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 595310 **/ 1.26 + 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 +addLoadEvent(function() { 1.30 + // We want to compare to value="bar" and no placeholder shown. 1.31 + // That is what is currently showed. 1.32 + var s1 = snapshotWindow(window, false); 1.33 + 1.34 + var content = document.getElementById('content'); 1.35 + var i = document.getElementById('i'); 1.36 + var t = SpecialPowers.wrap(document.getElementById('t')); 1.37 + i.value = ""; i.placeholder = "foo"; 1.38 + t.value = ""; t.placeholder = "foo"; 1.39 + 1.40 + // Flushing. 1.41 + // Note: one call would have been enough actually but I didn't want to favour 1.42 + // one element... ;) 1.43 + i.getBoundingClientRect(); 1.44 + t.getBoundingClientRect(); 1.45 + 1.46 + function synthesizeDropText(aElement, aText) 1.47 + { 1.48 + var editor = SpecialPowers.wrap(aElement) 1.49 + .QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement) 1.50 + .editor 1.51 + .QueryInterface(SpecialPowers.Ci.nsIPlaintextEditor); 1.52 + 1.53 + editor.insertText(aText); 1.54 + } 1.55 + 1.56 + // We insert "bar" and we should only see "bar" now. 1.57 + synthesizeDropText(i, "bar"); 1.58 + synthesizeDropText(t, "bar"); 1.59 + 1.60 + var s2 = snapshotWindow(window, false); 1.61 + 1.62 + ok(compareSnapshots(s1, s2, true)[0], 1.63 + "When setting the value, the placeholder should disappear."); 1.64 + 1.65 + SimpleTest.finish(); 1.66 +}); 1.67 + 1.68 + 1.69 +</script> 1.70 +</pre> 1.71 +</body> 1.72 +</html>