Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger.html

Issue 196933006: Do not dispatch 'change' events during pressing spin buttons for input[type=number]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test code updated Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger.html
diff --git a/LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger.html b/LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger.html
new file mode 100644
index 0000000000000000000000000000000000000000..f06d9d27c4b22f11e74c899a926e9c7ee6fd4dab
--- /dev/null
+++ b/LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger.html
@@ -0,0 +1,55 @@
+<!DOCTYPE>
+<html>
+<body>
+<script src="../../../resources/js-test.js"></script>
+<script src="../resources/common.js"></script>
+<input type="number" id="num1" onchange="handleChangeEvent(this);" oninput="handleInputEvent(this);">
+<script>
+var changeEventCounter = 0;
+var inputEventCounter = 0;
+
+function handleChangeEvent(element) {
+ ++changeEventCounter;
+}
+
+function handleInputEvent(element) {
+ ++inputEventCounter;
+}
+
+var numberInput1= document.getElementById('num1');
+numberInput1.focus();
+debug('Should not trigger any event');
+hoverOverElement(numberInput1);
+shouldBe('inputEventCounter', '0');
+shouldBe('changeEventCounter', '0');
+
+numberInput1.value = 0;
+eventSender.mouseMoveTo(numberInput1.offsetLeft + numberInput1.offsetWidth - 10, numberInput1.offsetTop + numberInput1.offsetHeight / 4);
+eventSender.mouseDown();
+debug('Input event is triggered but no change event is triggered on mouse down');
+shouldBe('inputEventCounter', '1');
+shouldBe('changeEventCounter', '0');
+shouldBeEqualToString('numberInput1.value', '1');
+eventSender.mouseUp();
+debug('Change events occurs on mouse up');
+shouldBe('inputEventCounter', '1');
+shouldBe('changeEventCounter', '1');
+shouldBeEqualToString('numberInput1.value', '1');
+
+debug('Pressed more than once, still events are triggered');
+eventSender.mouseMoveTo(numberInput1.offsetLeft + numberInput1.offsetWidth - 10, numberInput1.offsetTop + numberInput1.offsetHeight / 4);
+eventSender.mouseDown();
+eventSender.mouseUp();
+shouldBe('inputEventCounter', '2');
+shouldBe('changeEventCounter', '2');
+shouldBeEqualToString('numberInput1.value', '2');
+
+debug('When moving away from field, it should not trigger event, only on value change');
+numberInput1.blur();
+shouldBe('inputEventCounter', '2');
+shouldBe('changeEventCounter', '2');
+shouldBeEqualToString('numberInput1.value', '2');
+
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/number/number-spinbutton-changeevent-trigger-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698