Modified: trunk/LayoutTests/ChangeLog (125746 => 125747)
--- trunk/LayoutTests/ChangeLog 2012-08-16 05:21:33 UTC (rev 125746)
+++ trunk/LayoutTests/ChangeLog 2012-08-16 05:37:03 UTC (rev 125747)
@@ -1,3 +1,17 @@
+2012-08-15 Yoshifumi Inoue <yo...@chromium.org>
+
+ [Forms] Re-factor fast/forms/number/number-wheel-event.html
+ https://bugs.webkit.org/show_bug.cgi?id=94172
+
+ Reviewed by Kent Tamura.
+
+ This patch moves test code from number-wheel-event.html to common-wheel-event.js
+ for sharing test code among input types.
+
+ * fast/forms/number/number-wheel-event.html:
+ * fast/forms/resources/common-wheel-event.js:
+ (testWheelEvent):
+
2012-08-15 Shinya Kawanaka <shin...@chromium.org>
REGRESSION (r125659): 4 HTMLMeterElement tests fail on Mac.
Modified: trunk/LayoutTests/fast/forms/number/number-wheel-event.html (125746 => 125747)
--- trunk/LayoutTests/fast/forms/number/number-wheel-event.html 2012-08-16 05:21:33 UTC (rev 125746)
+++ trunk/LayoutTests/fast/forms/number/number-wheel-event.html 2012-08-16 05:37:03 UTC (rev 125747)
@@ -2,58 +2,15 @@
<html>
<head>
<script src=""
+<script src=""
</head>
<body>
<script>
-description('Test for wheel operations for <input type=number>');
-var parent = document.createElement('div');
-document.body.appendChild(parent);
-parent.innerHTML = '<input type=number id=number value=0> <input id=another>';
-var input = document.getElementById('number');
-input.focus();
-
-function dispatchWheelEvent(element, deltaX, deltaY)
-{
- var event = document.createEvent('WheelEvent');
- var dontCare = 0;
- event.initWebKitWheelEvent(deltaX, deltaY, document.defaultView, dontCare, dontCare, dontCare, dontCare, false, false, false, false);
- element.dispatchEvent(event);
-}
-
-debug('Initial value is 0. We\'ll wheel up by 1:');
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"1"');
-
-debug('Wheel up by 100:');
-dispatchWheelEvent(input, 0, 100);
-shouldBe('input.value', '"2"');
-
-debug('Wheel down by 1:');
-dispatchWheelEvent(input, 0, -1);
-shouldBe('input.value', '"1"');
-
-debug('Wheel down by 256:');
-dispatchWheelEvent(input, 0, -256);
-shouldBe('input.value', '"0"');
-
-debug('Disabled input element:');
-input.disabled = true;
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-input.removeAttribute('disabled');
-
-debug('Read-only input element:');
-input.readOnly = true;
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-input.readOnly = false;
-
-debug('No focus:');
-document.getElementById('another').focus();
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-
-parent.parentNode.removeChild(parent);
+testWheelEvent({
+ 'inputType' : 'number',
+ 'initialValue' : '0',
+ 'stepUpValue1' : '1',
+ 'stepUpValue2' : '2' });
</script>
<script src=""
</body>
Modified: trunk/LayoutTests/fast/forms/resources/common-wheel-event.js (125746 => 125747)
--- trunk/LayoutTests/fast/forms/resources/common-wheel-event.js 2012-08-16 05:21:33 UTC (rev 125746)
+++ trunk/LayoutTests/fast/forms/resources/common-wheel-event.js 2012-08-16 05:37:03 UTC (rev 125747)
@@ -1,17 +1,3 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<script>
-description('Test for wheel operations for <input type=number>');
-var parent = document.createElement('div');
-document.body.appendChild(parent);
-parent.innerHTML = '<input type=number id=number value=0> <input id=another>';
-var input = document.getElementById('number');
-input.focus();
-
function dispatchWheelEvent(element, deltaX, deltaY)
{
var event = document.createEvent('WheelEvent');
@@ -20,41 +6,53 @@
element.dispatchEvent(event);
}
-debug('Initial value is 0. We\'ll wheel up by 1:');
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"1"');
+var input;
+function testWheelEvent(parameters)
+{
+ var inputType = parameters['inputType'];
+ var initialValue = parameters['initialValue'];
+ var stepUpValue1 = parameters['stepUpValue1'];
+ var stepUpValue2 = parameters['stepUpValue2'];
+ description('Test for wheel operations for <input type=' + inputType + '>');
+ var parent = document.createElement('div');
+ document.body.appendChild(parent);
+ parent.innerHTML = '<input type=' + inputType + ' id=test value="' + initialValue + '"> <input id=another>';
+ input = document.getElementById('test');
+ input.focus();
-debug('Wheel up by 100:');
-dispatchWheelEvent(input, 0, 100);
-shouldBe('input.value', '"2"');
+ debug('Initial value is ' + initialValue + '. We\'ll wheel up by ' + stepUpValue1 + ':');
+ dispatchWheelEvent(input, 0, 1);
+ shouldBeEqualToString('input.value', stepUpValue1);
-debug('Wheel down by 1:');
-dispatchWheelEvent(input, 0, -1);
-shouldBe('input.value', '"1"');
+ debug('Wheel up by 100:');
+ dispatchWheelEvent(input, 0, 100);
+ shouldBeEqualToString('input.value', stepUpValue2);
-debug('Wheel down by 256:');
-dispatchWheelEvent(input, 0, -256);
-shouldBe('input.value', '"0"');
+ debug('Wheel down by 1:');
+ dispatchWheelEvent(input, 0, -1);
+ shouldBeEqualToString('input.value', stepUpValue1);
-debug('Disabled input element:');
-input.disabled = true;
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-input.removeAttribute('disabled');
+ debug('Wheel down by 256:');
+ dispatchWheelEvent(input, 0, -256);
+ shouldBeEqualToString('input.value', initialValue);
-debug('Read-only input element:');
-input.readOnly = true;
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-input.readOnly = false;
+ debug('Disabled input element:');
+ input.disabled = true;
+ dispatchWheelEvent(input, 0, 1);
+ shouldBeEqualToString('input.value', initialValue);
+ input.removeAttribute('disabled');
-debug('No focus:');
-document.getElementById('another').focus();
-dispatchWheelEvent(input, 0, 1);
-shouldBe('input.value', '"0"');
-parent.parentNode.removeChild(parent);
-</script>
-<script src=""
-</body>
-</html>
+ debug('Read-only input element:');
+ input.readOnly = true;
+ dispatchWheelEvent(input, 0, 1);
+ shouldBeEqualToString('input.value', initialValue);
+ input.readOnly = false;
+
+ debug('No focus:');
+ document.getElementById('another').focus();
+ dispatchWheelEvent(input, 0, 1);
+ shouldBeEqualToString('input.value', initialValue);
+
+ parent.parentNode.removeChild(parent);
+}