1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/test/test_bug903715.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=903715 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 903715</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=903715">Mozilla Bug 903715</a> 1.18 +<p id="display"></p> 1.19 +<div id="content"> 1.20 + <form id="form" action="/"> 1.21 + <select id="select" name="select"> 1.22 + <option>1</option> 1.23 + <option>2</option> 1.24 + <option>3</option> 1.25 + <option>4</option> 1.26 + <option>5</option> 1.27 + <option>6</option> 1.28 + <option>7</option> 1.29 + <option>8</option> 1.30 + <option>9</option> 1.31 + </select> 1.32 + <input id="input-text" name="text" value="some text"> 1.33 + <input id="input-submit" type="submit"> 1.34 + </form> 1.35 +</div> 1.36 +<pre id="test"> 1.37 +</pre> 1.38 +<script type="application/javascript"> 1.39 +SimpleTest.waitForExplicitFinish(); 1.40 +SimpleTest.waitForFocus(runTests, window); 1.41 + 1.42 +function runTests() 1.43 +{ 1.44 + var form = document.getElementById("form"); 1.45 + form.addEventListener("keypress", function (aEvent) { 1.46 + ok(false, "keypress event shouldn't be fired when the preceding keydown event caused closing the dropdown of the select element"); 1.47 + }, true); 1.48 + form.addEventListener("submit", function (aEvent) { 1.49 + ok(false, "submit shouldn't be performed by the Enter key press on the select element"); 1.50 + aEvent.preventDefault(); 1.51 + }, true); 1.52 + var select = document.getElementById("select"); 1.53 + select.addEventListener("change", function (aEvent) { 1.54 + var input = document.getElementById("input-text"); 1.55 + input.focus(); 1.56 + input.select(); 1.57 + }, false); 1.58 + 1.59 + select.focus(); 1.60 + 1.61 + select.addEventListener("popupshowing", function (aEvent) { 1.62 + setTimeout(function () { 1.63 + synthesizeKey("VK_DOWN", { }); 1.64 + select.addEventListener("popuphiding", function (aEvent) { 1.65 + setTimeout(function () { 1.66 + // Enter key should cause closing the dropdown of the select element 1.67 + // and keypress event shouldn't be fired on the input element because 1.68 + // which shouldn't cause sumbmitting the form contents. 1.69 + ok(true, "Test passes if there is no error"); 1.70 + SimpleTest.finish(); 1.71 + }, 100); 1.72 + }, false); 1.73 + // Close dropdown. 1.74 + synthesizeKey("VK_RETURN", { }); 1.75 + }, 100); 1.76 + }, false); 1.77 + 1.78 + // Open dropdown. 1.79 + synthesizeKey("VK_DOWN", { altKey: true }); 1.80 +} 1.81 +</script> 1.82 +</body> 1.83 +</html>