diff options
author | yosin@chromium.org <yosin@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-08-16 05:37:03 +0000 |
---|---|---|
committer | yosin@chromium.org <yosin@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-08-16 05:37:03 +0000 |
commit | af81dee663bb457ac971ca1ac4959d04b46e34ef (patch) | |
tree | 1d315ccae36217cc05c23245032e4c67c48f2c06 | |
parent | e7fd7ff301ff6a11a60d1e2c0d68cb0ea6813852 (diff) | |
download | chromium_src-af81dee663bb457ac971ca1ac4959d04b46e34ef.zip chromium_src-af81dee663bb457ac971ca1ac4959d04b46e34ef.tar.gz chromium_src-af81dee663bb457ac971ca1ac4959d04b46e34ef.tar.bz2 |
[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):
git-svn-id: svn://svn.chromium.org/blink/trunk@125747 bbb929c8-8fbe-4397-9dbb-9b2b20218538
3 files changed, 70 insertions, 101 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog index 3ece301..75bc8a7 100644 --- a/third_party/WebKit/LayoutTests/ChangeLog +++ b/third_party/WebKit/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2012-08-15 Yoshifumi Inoue <yosin@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 <shinyak@chromium.org> REGRESSION (r125659): 4 HTMLMeterElement tests fail on Mac. diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-wheel-event.html b/third_party/WebKit/LayoutTests/fast/forms/number/number-wheel-event.html index a47d64e..73a8425 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-wheel-event.html +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-wheel-event.html @@ -2,58 +2,15 @@ <html> <head> <script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../resources/common-wheel-event.js"></script> </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="../../../fast/js/resources/js-test-post.js"></script> </body> diff --git a/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js b/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js index a47d64e..224e6a9 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js +++ b/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js @@ -1,17 +1,3 @@ -<!DOCTYPE html> -<html> -<head> -<script src="../../../fast/js/resources/js-test-pre.js"></script> -</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 @@ function dispatchWheelEvent(element, deltaX, deltaY) 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); -</script> -<script src="../../../fast/js/resources/js-test-post.js"></script> -</body> -</html> +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('Initial value is ' + initialValue + '. We\'ll wheel up by ' + stepUpValue1 + ':'); + dispatchWheelEvent(input, 0, 1); + shouldBeEqualToString('input.value', stepUpValue1); + + debug('Wheel up by 100:'); + dispatchWheelEvent(input, 0, 100); + shouldBeEqualToString('input.value', stepUpValue2); + + debug('Wheel down by 1:'); + dispatchWheelEvent(input, 0, -1); + shouldBeEqualToString('input.value', stepUpValue1); + + debug('Wheel down by 256:'); + dispatchWheelEvent(input, 0, -256); + shouldBeEqualToString('input.value', initialValue); + + debug('Disabled input element:'); + input.disabled = true; + dispatchWheelEvent(input, 0, 1); + shouldBeEqualToString('input.value', initialValue); + input.removeAttribute('disabled'); + + + 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); +} |