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

Unified Diff: third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html

Issue 2631483002: Improve performance of time-multiple-fields-stepup-stepdown-from-renderer-hour.html (Closed)
Patch Set: Created 3 years, 11 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
Index: third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html
diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html
index 84fd85a3c6e7d2bf76ac946660811d86846a069c..856e1831741b1849d2e24953bf826bf9e8d88639 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-hour.html
@@ -1,14 +1,13 @@
<!DOCTYPE html>
<html>
<head>
-<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
-description('Check stepping-up and -down for time input fields from renderer. No cases of empty initial values.');
-if (!window.internals)
- testFailed('This test requires window.internals.');
+console.assert(!!window.internals, 'This test requires window.internals.');
yosin_UTC9 2017/01/13 02:33:54 We found good pattern for this: test(() => if (
tkent 2017/01/13 04:45:52 Done.
var input = document.createElement('input');
document.body.appendChild(input);
@@ -42,195 +41,208 @@ function setInputAttributes(value, min, max, step) {
maybeUpdateAttribute('step', step);
}
-function test(value, step, min, max, keySequence) {
+function setupInputAndTest(value, step, min, max, keySequence) {
setInputAttributes(value, min, max, step);
for (var i = 0; i < keySequence.length; i++)
keyDown(keySequence[i]);
return input.value;
}
-function stepUp(value, step, min, max) {
- return test(value, step, min, max, ['ArrowUp']);
-}
+input.type = 'time';
yosin_UTC9 2017/01/13 02:33:54 It is better to move this code fragment in to |tes
+input.focus();
+
+// Hours, 1-12
+const tests1 = [
+ {'initial': '07:00', 'step': 1, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': '07:00', 'step': 1, 'operation': 'ArrowDown', 'expected': '06:00'},
+ {'initial': '11:00', 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': '00:00', 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00'},
+ {'initial': '06:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': '06:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '04:00'},
+ {'initial': '10:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': '00:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '10:00'},
+ {'initial': '07:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': '07:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '06:00'},
+ {'initial': '06:00', 'step': 3601, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': '06:00', 'step': 3601, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': '06:00', 'step': 0, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': '06:00', 'step': 0, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': '06:00', 'step': 86400, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': '06:00', 'step': 86400, 'operation': 'ArrowDown', 'expected': '00:00'},
+ {'initial': '06:00', 'step': 36000, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': '06:00', 'step': 36000, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': '06:00', 'step': 7200, 'operation': ['Delete', 'ArrowUp'], 'expected': '02:00'},
+ {'initial': '06:00', 'step': 7200, 'operation': ['Delete', 'ArrowDown'], 'expected': '00:00', 'expectedDisplayValue': '12:00 AM'},
+ {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': ['Delete', 'ArrowUp'], 'expected': '01:00'},
+ {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': ['Delete', 'ArrowDown'], 'expected': '11:00'},
+
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '18:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowUp', 'expected': '15:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowDown', 'expected': '16:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowDown', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '16:00'},
+ {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '14:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '11:00'},
+ {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '16:00'},
+ {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '09:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '19:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '19:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation': 'ArrowDown', 'expected': '17:00'}
+];
+
+// Hours, 0-11
+const tests2 = [
+ {'initial': "11:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00', 'expectedDisplayValue': '00:00 AM'},
+ {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00', 'expectedDisplayValue': '11:00 AM'},
+ {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '12:00', 'expectedDisplayValue': '00:00 PM'},
+ {'initial': "12:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00', 'expectedDisplayValue': '11:00 PM'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expected': '00:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expected': '10:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowUp"], 'expected': '01:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowDown"], 'expected': '11:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '18:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowUp', 'expected': '15:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowDown', 'expected': '16:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowDown', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '15:00'},
+ {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '12:00'},
+ {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '14:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '03:00'},
+ {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '16:00'},
+ {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '09:00'},
+ {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '19:00'}
+];
-function stepDown(value, step, min, max) {
- return test(value, step, min, max, ['ArrowDown']);
+// Hours, 0-23
+const tests3 = [
+ {'initial': "07:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': "07:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '06:00'},
+ {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '04:00'},
+ {'initial': "22:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': "00:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '22:00'},
+ {'initial': "07:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00'},
+ {'initial': "07:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '06:00'},
+ {'initial': "06:00", 'step': 3601, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': "06:00", 'step': 3601, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': "06:00", 'step': 0, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': "06:00", 'step': 0, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': "06:00", 'step': 86400, 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': "06:00", 'step': 86400, 'operation': 'ArrowDown', 'expected': '00:00'},
+ {'initial': "06:00", 'step': 36000, 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': "06:00", 'step': 36000, 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': 'ArrowUp', 'expected': '07:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': 'ArrowDown', 'expected': '05:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expected': '00:00', 'expectedDisplayValue': '00:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expected': '22:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowUp"], 'expected': '01:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowDown"], 'expected': '23:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '18:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowUp', 'expected': '15:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowDown', 'expected': '16:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowDown', 'expected': '13:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '03:00'},
+ {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '00:00'},
+ {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '02:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowUp', 'expected': '10:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowDown', 'expected': '11:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '03:00'},
+ {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '10:00'},
+ {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '15:00'},
+ {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '19:00'},
+];
+
+// Hours, 1-24
+const tests4 = [
+ {'initial': "11:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '12:00', 'expectedDisplayValue': '12:00'},
+ {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00', 'expectedDisplayValue': '23:00'},
+ {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00', 'expectedDisplayValue': '24:00'},
+ {'initial': "12:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00', 'expectedDisplayValue': '11:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expected': '02:00'},
+ {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expected': '00:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowUp"], 'expected': '01:00'},
+ {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "ArrowDown"], 'expected': '23:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '18:00'},
+ {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowUp', 'expected': '15:00'},
+ {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': 'ArrowDown', 'expected': '16:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '20:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowUp', 'expected': '13:00'},
+ {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': 'ArrowDown', 'expected': '13:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '04:00'},
+ {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '02:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowUp', 'expected': '10:00'},
+ {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': 'ArrowDown', 'expected': '11:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowUp', 'expected': '01:00'},
+ {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': 'ArrowDown', 'expected': '23:00'},
+ {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowUp', 'expected': '10:00'},
+ {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': 'ArrowDown', 'expected': '15:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowUp', 'expected': '19:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation': 'ArrowDown', 'expected': '19:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation': 'ArrowUp', 'expected': '17:00'},
+ {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation': 'ArrowDown', 'expected': '17:00'},
+];
+
+function runTests(array, label) {
+ array.forEach(item => {
+ test(() => {
+ var keySequence = typeof item.operation == 'string' ? [item.operation] : item.operation;
yosin_UTC9 2017/01/13 02:33:54 It is better to use sequence of function rather th
tkent 2017/01/13 04:45:52 Unfortunately, we can't do it due to a performance
yosin_UTC9 2017/01/13 05:31:13 My main point is "avoiding data drive" instead of
tkent 2017/01/13 06:57:44 Ah, I see. The latest Patch Set follows it.
+ assert_equals(setupInputAndTest(item.initial, item.step, item.min, item.max, keySequence), item.expected);
+ if (item.expectedDisplayValue)
+ assert_equals(getUserAgentShadowTextContent(input), item.expectedDisplayValue);
+ }, label + ': ' + item.operation + ' to INPUT with initial-value=' + item.initial +
yosin_UTC9 2017/01/13 02:33:54 It is better to use template, .e.g `${label}: ${i
tkent 2017/01/13 04:45:52 Done.
+ ' step=' + item.step +
+ (item.min ? (' min=' + item.min) : '') +
+ (item.max ? (' max=' + item.max) : '') +
+ ' should make the value "' + item.expected + '"');
+ });
}
-input.type = 'time';
-input.focus();
+runTests(tests1, 'Hours, 1-12');
-debug('Hours, 1-12');
-shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00');
-shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00');
-shouldBeEqualToString('stepUp("11:00", 1, null, null)', '00:00');
-shouldBeEqualToString('stepDown("00:00", 1, null, null)', '11:00');
-shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00');
-shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00');
-shouldBeEqualToString('stepUp("10:00", 7200, null, null)', '00:00');
-shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '10:00');
-shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00');
-shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00');
-shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00');
-shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00');
-shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '02:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])', '00:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '12:00 AM');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"])', '01:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown"])', '11:00');
-shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00');
-shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00');
-shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00');
-shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepUp("12:00", 1, "12:00", "15:00")', '13:00');
-shouldBeEqualToString('stepDown("12:00", 1, "12:00", "15:00")', '23:00');
-shouldBeEqualToString('stepUp("15:00", 1, "12:00", "15:00")', '16:00');
-shouldBeEqualToString('stepDown("15:00", 1, "12:00", "15:00")', '14:00');
-shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '13:00');
-shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '23:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '11:00');
-shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '16:00');
-shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '09:00');
-shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "20:00")', '19:00');
-shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "20:00")', '19:00');
-shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "18:00")', '17:00');
-shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "18:00")', '17:00');
-
-debug('Hours, 0-11');
setDateTimeFormat('KK:mm a');
-shouldBeEqualToString('stepUp("11:00", 1, null, null)', '00:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00 AM');
-shouldBeEqualToString('stepDown("00:00", 1, null, null)', '11:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00 AM');
-shouldBeEqualToString('stepUp("23:00", 1, null, null)', '12:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00 PM');
-shouldBeEqualToString('stepDown("12:00", 1, null, null)', '23:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00 PM');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '00:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])', '10:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"])', '01:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown"])', '11:00');
-shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00');
-shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00');
-shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00');
-shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepUp("12:00", 1, "12:00", "15:00")', '13:00');
-shouldBeEqualToString('stepDown("12:00", 1, "12:00", "15:00")', '15:00');
-shouldBeEqualToString('stepUp("15:00", 1, "12:00", "15:00")', '12:00');
-shouldBeEqualToString('stepDown("15:00", 1, "12:00", "15:00")', '14:00');
-shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '13:00');
-shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '23:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00');
-shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '16:00');
-shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '09:00');
-shouldBeEqualToString('stepUp("20:00", 7200, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("20:00", 7200, "17:00", "20:00")', '19:00');
-
-debug('Hours, 0-23');
+runTests(tests2, 'Hours, 0-11');
+
setDateTimeFormat('HH:mm');
-shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00');
-shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00');
-shouldBeEqualToString('stepUp("23:00", 1, null, null)', '00:00');
-shouldBeEqualToString('stepDown("00:00", 1, null, null)', '23:00');
-shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00');
-shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00');
-shouldBeEqualToString('stepUp("22:00", 7200, null, null)', '00:00');
-shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '22:00');
-shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00');
-shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00');
-shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00');
-shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00');
-shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00');
-shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00');
-shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '00:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])', '22:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"])', '01:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown"])', '23:00');
-shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00');
-shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00');
-shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00');
-shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00');
-shouldBeEqualToString('stepUp("03:00", 1, "00:00", "03:00")', '00:00');
-shouldBeEqualToString('stepDown("03:00", 1, "00:00", "03:00")', '02:00');
-shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '10:00');
-shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '11:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00');
-shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '10:00');
-shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '15:00');
-shouldBeEqualToString('stepUp("20:00", 7200, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("20:00", 7200, "17:00", "20:00")', '19:00');
-
-debug('Hours, 1-24');
+runTests(tests3, 'Hours, 0-23');
+
setDateTimeFormat('kk:mm');
-shouldBeEqualToString('stepUp("11:00", 1, null, null)', '12:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '12:00');
-shouldBeEqualToString('stepDown("00:00", 1, null, null)', '23:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:00');
-shouldBeEqualToString('stepUp("23:00", 1, null, null)', '00:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '24:00');
-shouldBeEqualToString('stepDown("12:00", 1, null, null)', '11:00');
-shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '02:00');
-shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])', '00:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"])', '01:00');
-shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown"])', '23:00');
-shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00');
-shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00');
-shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00');
-shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00');
-shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00');
-shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '23:00');
-shouldBeEqualToString('stepUp("03:00", 1, "00:00", "03:00")', '04:00');
-shouldBeEqualToString('stepDown("03:00", 1, "00:00", "03:00")', '02:00');
-shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '10:00');
-shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '11:00');
-shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00');
-shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '23:00');
-shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '10:00');
-shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '15:00');
-shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "20:00")', '19:00');
-shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "20:00")', '19:00');
-shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "18:00")', '17:00');
-shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "18:00")', '17:00');
+runTests(tests4, 'Hours, 1-24');
setDateTimeFormat('');
-debug('');
document.body.removeChild(input);
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698