Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / number / number-spinbutton-gets-disabled-or-readonly.html
blobeeb27e6e8b590e7e5600c6fdd55b9ca0b396b748
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <input id="readonlyNumber" type="number" onmouseup="mouseupEventOnReadonlyNumber()" />
8 <input id="disabledNumber" type="number" onmouseup="mouseupEventOnDisabledNumber()" />
9 <p>
10 This tests if the value of a number input form does not continue
11 to increase/decrease in the following scenario.<br/>
12 (1) Click the spin button of the input form.<br/>
13 (2) Hook the 'mouseup' event and disable the input form.<br/>
14 (3) Enable the input form after some delay.<br/>
15 To run this test manually, input any value in the input form
16 and then click the spin-down button.
17 At this point, click the spin-down button quickly and
18 do not move the cursor from the spin-down button after the click.
19 If the value decreases by just 1, this test passes.
20 </p>
21 <div id="console"></div>
22 <script>
23 var testInputs;
24 var testDelays;
25 var input;
26 var delay;
27 window.jsTestIsAsync = true;
29 if (window.testRunner && window.eventSender) {
30 testInputs = [document.getElementById("readonlyNumber"), document.getElementById("disabledNumber")];
31 setTimeout(function() {
32 nextInputTest();
33 }, 0);
36 function nextInputTest() {
37 if (testInputs.length == 0) {
38 finishJSTest();
39 } else {
40 input = testInputs.shift();
41 input.focus();
42 testDelays = [1, 10, 100];
43 debug("");
44 debug("Test on a " + (input.id == "readonlyNumber" ? "readonly" : "disabled") + " number input form:");
45 nextDelayTest();
49 function nextDelayTest() {
50 if (testDelays.length == 0) {
51 nextInputTest();
52 } else {
53 delay = testDelays.shift();
54 initializeInputAttributes(input, 1234567);
55 debug("delay = " + delay + " ms");
56 clickSpinDownButton(input);
57 setTimeout(function() {
58 shouldBeEqualToString('input.value', "1234566");
59 nextDelayTest();
60 }, 500);
64 function mouseupEventOnReadonlyNumber() {
65 input.readOnly = true;
66 setTimeout(function() {
67 input.readOnly = false;
68 }, delay);
71 function mouseupEventOnDisabledNumber() {
72 input.disabled = true;
73 setTimeout(function() {
74 input.disabled = false;
75 }, delay);
78 function initializeInputAttributes(input, value) {
79 input.value = value;
80 input.disabled = false;
81 input.readOnly = false;
84 function clickSpinDownButton(input) {
85 var x = input.offsetLeft + input.offsetWidth - 6;
86 var y = input.offsetTop + input.offsetHeight - 6;
87 eventSender.mouseMoveTo(x, y);
88 eventSender.mouseDown();
89 eventSender.mouseUp();
91 </script>
92 </body>
93 </html>