 Chromium Code Reviews
 Chromium Code Reviews Issue 2631483002:
  Improve performance of time-multiple-fields-stepup-stepdown-from-renderer-hour.html  (Closed)
    
  
    Issue 2631483002:
  Improve performance of time-multiple-fields-stepup-stepdown-from-renderer-hour.html  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> | 
| 2 <html> | 2 <html> | 
| 3 <head> | 3 <head> | 
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/testharness.js"></script> | 
| 5 <script src="../../../resources/testharnessreport.js"></script> | |
| 5 <script src="../resources/common.js"></script> | 6 <script src="../resources/common.js"></script> | 
| 6 </head> | 7 </head> | 
| 7 <body> | 8 <body> | 
| 8 <script> | 9 <script> | 
| 9 description('Check stepping-up and -down for time input fields from renderer. No cases of empty initial values.'); | 10 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.
 | |
| 10 if (!window.internals) | |
| 11 testFailed('This test requires window.internals.'); | |
| 12 | 11 | 
| 13 var input = document.createElement('input'); | 12 var input = document.createElement('input'); | 
| 14 document.body.appendChild(input); | 13 document.body.appendChild(input); | 
| 15 | 14 | 
| 16 function keyDown(key, modifiers) | 15 function keyDown(key, modifiers) | 
| 17 { | 16 { | 
| 18 if (!window.eventSender) | 17 if (!window.eventSender) | 
| 19 return; | 18 return; | 
| 20 eventSender.keyDown(key, modifiers); | 19 eventSender.keyDown(key, modifiers); | 
| 21 } | 20 } | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 35 } | 34 } | 
| 36 } | 35 } | 
| 37 | 36 | 
| 38 function setInputAttributes(value, min, max, step) { | 37 function setInputAttributes(value, min, max, step) { | 
| 39 input.value = value; | 38 input.value = value; | 
| 40 maybeUpdateAttribute('min', min); | 39 maybeUpdateAttribute('min', min); | 
| 41 maybeUpdateAttribute('max', max); | 40 maybeUpdateAttribute('max', max); | 
| 42 maybeUpdateAttribute('step', step); | 41 maybeUpdateAttribute('step', step); | 
| 43 } | 42 } | 
| 44 | 43 | 
| 45 function test(value, step, min, max, keySequence) { | 44 function setupInputAndTest(value, step, min, max, keySequence) { | 
| 46 setInputAttributes(value, min, max, step); | 45 setInputAttributes(value, min, max, step); | 
| 47 for (var i = 0; i < keySequence.length; i++) | 46 for (var i = 0; i < keySequence.length; i++) | 
| 48 keyDown(keySequence[i]); | 47 keyDown(keySequence[i]); | 
| 49 return input.value; | 48 return input.value; | 
| 50 } | 49 } | 
| 51 | 50 | 
| 52 function stepUp(value, step, min, max) { | |
| 53 return test(value, step, min, max, ['ArrowUp']); | |
| 54 } | |
| 55 | |
| 56 function stepDown(value, step, min, max) { | |
| 57 return test(value, step, min, max, ['ArrowDown']); | |
| 58 } | |
| 59 | |
| 60 input.type = 'time'; | 51 input.type = 'time'; | 
| 
yosin_UTC9
2017/01/13 02:33:54
It is better to move this code fragment in to |tes
 | |
| 61 input.focus(); | 52 input.focus(); | 
| 62 | 53 | 
| 63 debug('Hours, 1-12'); | 54 // Hours, 1-12 | 
| 64 shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00'); | 55 const tests1 = [ | 
| 65 shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00'); | 56 {'initial': '07:00', 'step': 1, 'operation': 'ArrowUp', 'expected': '08:00'}, | 
| 66 shouldBeEqualToString('stepUp("11:00", 1, null, null)', '00:00'); | 57 {'initial': '07:00', 'step': 1, 'operation': 'ArrowDown', 'expected': '06:00'} , | 
| 67 shouldBeEqualToString('stepDown("00:00", 1, null, null)', '11:00'); | 58 {'initial': '11:00', 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00'}, | 
| 68 shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00'); | 59 {'initial': '00:00', 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00'} , | 
| 69 shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00'); | 60 {'initial': '06:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00' }, | 
| 70 shouldBeEqualToString('stepUp("10:00", 7200, null, null)', '00:00'); | 61 {'initial': '06:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '04:0 0'}, | 
| 71 shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '10:00'); | 62 {'initial': '10:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '00:00' }, | 
| 72 shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00'); | 63 {'initial': '00:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '10:0 0'}, | 
| 73 shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00'); | 64 {'initial': '07:00', 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00' }, | 
| 74 shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00'); | 65 {'initial': '07:00', 'step': 7200, 'operation': 'ArrowDown', 'expected': '06:0 0'}, | 
| 75 shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00'); | 66 {'initial': '06:00', 'step': 3601, 'operation': 'ArrowUp', 'expected': '07:00' }, | 
| 76 shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00'); | 67 {'initial': '06:00', 'step': 3601, 'operation': 'ArrowDown', 'expected': '05:0 0'}, | 
| 77 shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00'); | 68 {'initial': '06:00', 'step': 0, 'operation': 'ArrowUp', 'expected': '07:00'}, | 
| 78 shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00'); | 69 {'initial': '06:00', 'step': 0, 'operation': 'ArrowDown', 'expected': '05:00'} , | 
| 79 shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00'); | 70 {'initial': '06:00', 'step': 86400, 'operation': 'ArrowUp', 'expected': '00:00 '}, | 
| 80 shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00'); | 71 {'initial': '06:00', 'step': 86400, 'operation': 'ArrowDown', 'expected': '00: 00'}, | 
| 81 shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00'); | 72 {'initial': '06:00', 'step': 36000, 'operation': 'ArrowUp', 'expected': '07:00 '}, | 
| 82 shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00'); | 73 {'initial': '06:00', 'step': 36000, 'operation': 'ArrowDown', 'expected': '05: 00'}, | 
| 83 shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00'); | 74 {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': 'ArrowUp', 'ex pected': '07:00'}, | 
| 84 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '02:00'); | 75 {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': 'ArrowDown', ' expected': '05:00'}, | 
| 85 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])' , '00:00'); | 76 {'initial': '06:00', 'step': 7200, 'operation': ['Delete', 'ArrowUp'], 'expect ed': '02:00'}, | 
| 86 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '12:00 AM'); | 77 {'initial': '06:00', 'step': 7200, 'operation': ['Delete', 'ArrowDown'], 'expe cted': '00:00', 'expectedDisplayValue': '12:00 AM'}, | 
| 87 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"]) ', '01:00'); | 78 {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': ['Delete', 'Ar rowUp'], 'expected': '01:00'}, | 
| 88 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown" ])', '11:00'); | 79 {'initial': '06:00', 'step': 7200, 'min': '01:00', 'operation': ['Delete', 'Ar rowDown'], 'expected': '11:00'}, | 
| 89 shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00'); | 80 | 
| 90 shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00'); | 81 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '18:00'}, | 
| 91 shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00'); | 82 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | 
| 92 shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00'); | 83 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowUp', 'expected': '15:00'}, | 
| 93 shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00'); | 84 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowDown', 'expected': '16:00'}, | 
| 94 shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00'); | 85 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '17:00'}, | 
| 95 shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00'); | 86 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | 
| 96 shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00'); | 87 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | 
| 97 shouldBeEqualToString('stepUp("12:00", 1, "12:00", "15:00")', '13:00'); | 88 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowDown', 'expected': '13:00'}, | 
| 98 shouldBeEqualToString('stepDown("12:00", 1, "12:00", "15:00")', '23:00'); | 89 {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | 
| 99 shouldBeEqualToString('stepUp("15:00", 1, "12:00", "15:00")', '16:00'); | 90 {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '23:00'}, | 
| 100 shouldBeEqualToString('stepDown("15:00", 1, "12:00", "15:00")', '14:00'); | 91 {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '16:00'}, | 
| 101 shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '13:00'); | 92 {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '14:00'}, | 
| 102 shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '23:00'); | 93 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | 
| 103 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | 94 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowDown', 'expected': '23:00'}, | 
| 104 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '11:00'); | 95 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | 
| 105 shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '16:00'); | 96 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '11:00'}, | 
| 106 shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '09:00'); | 97 {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '16:00'}, | 
| 107 shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "20:00")', '19:00'); | 98 {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '09:00'}, | 
| 108 shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "20:00")', '19:00'); | 99 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowUp', 'expected': '19:00'}, | 
| 109 shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "18:00")', '17:00'); | 100 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowDown', 'expected': '19:00'}, | 
| 110 shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "18:00")', '17:00'); | 101 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation' : 'ArrowUp', 'expected': '17:00'}, | 
| 111 | 102 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation' : 'ArrowDown', 'expected': '17:00'} | 
| 112 debug('Hours, 0-11'); | 103 ]; | 
| 104 | |
| 105 // Hours, 0-11 | |
| 106 const tests2 = [ | |
| 107 {'initial': "11:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00', ' expectedDisplayValue': '00:00 AM'}, | |
| 108 {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00', 'expectedDisplayValue': '11:00 AM'}, | |
| 109 {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '12:00', ' expectedDisplayValue': '00:00 PM'}, | |
| 110 {'initial': "12:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00', 'expectedDisplayValue': '11:00 PM'}, | |
| 111 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expect ed': '00:00'}, | |
| 112 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expe cted': '10:00'}, | |
| 113 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowUp"], 'expected': '01:00'}, | |
| 114 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowDown"], 'expected': '11:00'}, | |
| 115 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '18:00'}, | |
| 116 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 117 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowUp', 'expected': '15:00'}, | |
| 118 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowDown', 'expected': '16:00'}, | |
| 119 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '17:00'}, | |
| 120 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 121 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | |
| 122 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowDown', 'expected': '13:00'}, | |
| 123 {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | |
| 124 {'initial': "12:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '15:00'}, | |
| 125 {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '12:00'}, | |
| 126 {'initial': "15:00", 'step': 1, 'min': "12:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '14:00'}, | |
| 127 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | |
| 128 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowDown', 'expected': '23:00'}, | |
| 129 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | |
| 130 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '03:00'}, | |
| 131 {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '16:00'}, | |
| 132 {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '09:00'}, | |
| 133 {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowUp', 'expected': '17:00'}, | |
| 134 {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowDown', 'expected': '19:00'} | |
| 135 ]; | |
| 136 | |
| 137 // Hours, 0-23 | |
| 138 const tests3 = [ | |
| 139 {'initial': "07:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '08:00'}, | |
| 140 {'initial': "07:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '06:00'} , | |
| 141 {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00'}, | |
| 142 {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00'} , | |
| 143 {'initial': "06:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00' }, | |
| 144 {'initial': "06:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '04:0 0'}, | |
| 145 {'initial': "22:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '00:00' }, | |
| 146 {'initial': "00:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '22:0 0'}, | |
| 147 {'initial': "07:00", 'step': 7200, 'operation': 'ArrowUp', 'expected': '08:00' }, | |
| 148 {'initial': "07:00", 'step': 7200, 'operation': 'ArrowDown', 'expected': '06:0 0'}, | |
| 149 {'initial': "06:00", 'step': 3601, 'operation': 'ArrowUp', 'expected': '07:00' }, | |
| 150 {'initial': "06:00", 'step': 3601, 'operation': 'ArrowDown', 'expected': '05:0 0'}, | |
| 151 {'initial': "06:00", 'step': 0, 'operation': 'ArrowUp', 'expected': '07:00'}, | |
| 152 {'initial': "06:00", 'step': 0, 'operation': 'ArrowDown', 'expected': '05:00'} , | |
| 153 {'initial': "06:00", 'step': 86400, 'operation': 'ArrowUp', 'expected': '00:00 '}, | |
| 154 {'initial': "06:00", 'step': 86400, 'operation': 'ArrowDown', 'expected': '00: 00'}, | |
| 155 {'initial': "06:00", 'step': 36000, 'operation': 'ArrowUp', 'expected': '07:00 '}, | |
| 156 {'initial': "06:00", 'step': 36000, 'operation': 'ArrowDown', 'expected': '05: 00'}, | |
| 157 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': 'ArrowUp', 'ex pected': '07:00'}, | |
| 158 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': 'ArrowDown', ' expected': '05:00'}, | |
| 159 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expect ed': '00:00', 'expectedDisplayValue': '00:00'}, | |
| 160 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expe cted': '22:00'}, | |
| 161 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowUp"], 'expected': '01:00'}, | |
| 162 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowDown"], 'expected': '23:00'}, | |
| 163 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '18:00'}, | |
| 164 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 165 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowUp', 'expected': '15:00'}, | |
| 166 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowDown', 'expected': '16:00'}, | |
| 167 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '17:00'}, | |
| 168 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 169 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | |
| 170 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowDown', 'expected': '13:00'}, | |
| 171 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | |
| 172 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '03:00'}, | |
| 173 {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '00:00'}, | |
| 174 {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '02:00'}, | |
| 175 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowUp', 'expected': '10:00'}, | |
| 176 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowDown', 'expected': '11:00'}, | |
| 177 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | |
| 178 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '03:00'}, | |
| 179 {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '10:00'}, | |
| 180 {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '15:00'}, | |
| 181 {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowUp', 'expected': '17:00'}, | |
| 182 {'initial': "20:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowDown', 'expected': '19:00'}, | |
| 183 ]; | |
| 184 | |
| 185 // Hours, 1-24 | |
| 186 const tests4 = [ | |
| 187 {'initial': "11:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '12:00', ' expectedDisplayValue': '12:00'}, | |
| 188 {'initial': "00:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '23:00', 'expectedDisplayValue': '23:00'}, | |
| 189 {'initial': "23:00", 'step': 1, 'operation': 'ArrowUp', 'expected': '00:00', ' expectedDisplayValue': '24:00'}, | |
| 190 {'initial': "12:00", 'step': 1, 'operation': 'ArrowDown', 'expected': '11:00', 'expectedDisplayValue': '11:00'}, | |
| 191 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowUp"], 'expect ed': '02:00'}, | |
| 192 {'initial': "06:00", 'step': 7200, 'operation': ["Delete", "ArrowDown"], 'expe cted': '00:00'}, | |
| 193 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowUp"], 'expected': '01:00'}, | |
| 194 {'initial': "06:00", 'step': 7200, 'min': "01:00", 'operation': ["Delete", "Ar rowDown"], 'expected': '23:00'}, | |
| 195 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '18:00'}, | |
| 196 {'initial': "17:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 197 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowUp', 'expected': '15:00'}, | |
| 198 {'initial': "17:00", 'step': 1, 'min': "15:00", 'max': "17:00", 'operation': ' ArrowDown', 'expected': '16:00'}, | |
| 199 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowUp', 'expected': '17:00'}, | |
| 200 {'initial': "15:00", 'step': 1, 'min': "17:00", 'max': "20:00", 'operation': ' ArrowDown', 'expected': '20:00'}, | |
| 201 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowUp', 'expected': '13:00'}, | |
| 202 {'initial': "15:00", 'step': 1, 'min': "13:00", 'max': "13:00", 'operation': ' ArrowDown', 'expected': '13:00'}, | |
| 203 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | |
| 204 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '23:00'}, | |
| 205 {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '04:00'}, | |
| 206 {'initial': "03:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '02:00'}, | |
| 207 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowUp', 'expected': '10:00'}, | |
| 208 {'initial': "12:00", 'step': 1, 'min': "10:00", 'max': "12:00", 'operation': ' ArrowDown', 'expected': '11:00'}, | |
| 209 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowUp', 'expected': '01:00'}, | |
| 210 {'initial': "00:00", 'step': 1, 'min': "00:00", 'max': "03:00", 'operation': ' ArrowDown', 'expected': '23:00'}, | |
| 211 {'initial': "15:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowUp', 'expected': '10:00'}, | |
| 212 {'initial': "10:00", 'step': 1, 'min': "10:00", 'max': "15:00", 'operation': ' ArrowDown', 'expected': '15:00'}, | |
| 213 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowUp', 'expected': '19:00'}, | |
| 214 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "20:00", 'operation' : 'ArrowDown', 'expected': '19:00'}, | |
| 215 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation' : 'ArrowUp', 'expected': '17:00'}, | |
| 216 {'initial': "17:00", 'step': 7200, 'min': "17:00", 'max': "18:00", 'operation' : 'ArrowDown', 'expected': '17:00'}, | |
| 217 ]; | |
| 218 | |
| 219 function runTests(array, label) { | |
| 220 array.forEach(item => { | |
| 221 test(() => { | |
| 222 var keySequence = typeof item.operation == 'string' ? [item.operation] : i tem.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.
 | |
| 223 assert_equals(setupInputAndTest(item.initial, item.step, item.min, item.ma x, keySequence), item.expected); | |
| 224 if (item.expectedDisplayValue) | |
| 225 assert_equals(getUserAgentShadowTextContent(input), item.expectedDisplay Value); | |
| 226 }, label + ': ' + item.operation + ' to INPUT with initial-value=' + item.in itial + | |
| 
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.
 | |
| 227 ' step=' + item.step + | |
| 228 (item.min ? (' min=' + item.min) : '') + | |
| 229 (item.max ? (' max=' + item.max) : '') + | |
| 230 ' should make the value "' + item.expected + '"'); | |
| 231 }); | |
| 232 } | |
| 233 | |
| 234 runTests(tests1, 'Hours, 1-12'); | |
| 235 | |
| 113 setDateTimeFormat('KK:mm a'); | 236 setDateTimeFormat('KK:mm a'); | 
| 114 shouldBeEqualToString('stepUp("11:00", 1, null, null)', '00:00'); | 237 runTests(tests2, 'Hours, 0-11'); | 
| 115 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00 AM'); | 238 | 
| 116 shouldBeEqualToString('stepDown("00:00", 1, null, null)', '11:00'); | |
| 117 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00 AM'); | |
| 118 shouldBeEqualToString('stepUp("23:00", 1, null, null)', '12:00'); | |
| 119 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00 PM'); | |
| 120 shouldBeEqualToString('stepDown("12:00", 1, null, null)', '23:00'); | |
| 121 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00 PM'); | |
| 122 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '00:00'); | |
| 123 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])' , '10:00'); | |
| 124 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"]) ', '01:00'); | |
| 125 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown" ])', '11:00'); | |
| 126 shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00'); | |
| 127 shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00'); | |
| 128 shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00'); | |
| 129 shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00'); | |
| 130 shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00'); | |
| 131 shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00'); | |
| 132 shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 133 shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 134 shouldBeEqualToString('stepUp("12:00", 1, "12:00", "15:00")', '13:00'); | |
| 135 shouldBeEqualToString('stepDown("12:00", 1, "12:00", "15:00")', '15:00'); | |
| 136 shouldBeEqualToString('stepUp("15:00", 1, "12:00", "15:00")', '12:00'); | |
| 137 shouldBeEqualToString('stepDown("15:00", 1, "12:00", "15:00")', '14:00'); | |
| 138 shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '13:00'); | |
| 139 shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '23:00'); | |
| 140 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | |
| 141 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00'); | |
| 142 shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '16:00'); | |
| 143 shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '09:00'); | |
| 144 shouldBeEqualToString('stepUp("20:00", 7200, "17:00", "20:00")', '17:00'); | |
| 145 shouldBeEqualToString('stepDown("20:00", 7200, "17:00", "20:00")', '19:00'); | |
| 146 | |
| 147 debug('Hours, 0-23'); | |
| 148 setDateTimeFormat('HH:mm'); | 239 setDateTimeFormat('HH:mm'); | 
| 149 shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00'); | 240 runTests(tests3, 'Hours, 0-23'); | 
| 150 shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00'); | 241 | 
| 151 shouldBeEqualToString('stepUp("23:00", 1, null, null)', '00:00'); | |
| 152 shouldBeEqualToString('stepDown("00:00", 1, null, null)', '23:00'); | |
| 153 shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00'); | |
| 154 shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00'); | |
| 155 shouldBeEqualToString('stepUp("22:00", 7200, null, null)', '00:00'); | |
| 156 shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '22:00'); | |
| 157 shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00'); | |
| 158 shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00'); | |
| 159 shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00'); | |
| 160 shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00'); | |
| 161 shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00'); | |
| 162 shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00'); | |
| 163 shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00'); | |
| 164 shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00'); | |
| 165 shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00'); | |
| 166 shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00'); | |
| 167 shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00'); | |
| 168 shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00'); | |
| 169 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '00:00'); | |
| 170 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00'); | |
| 171 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])' , '22:00'); | |
| 172 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"]) ', '01:00'); | |
| 173 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown" ])', '23:00'); | |
| 174 shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00'); | |
| 175 shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00'); | |
| 176 shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00'); | |
| 177 shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00'); | |
| 178 shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00'); | |
| 179 shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00'); | |
| 180 shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 181 shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 182 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | |
| 183 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00'); | |
| 184 shouldBeEqualToString('stepUp("03:00", 1, "00:00", "03:00")', '00:00'); | |
| 185 shouldBeEqualToString('stepDown("03:00", 1, "00:00", "03:00")', '02:00'); | |
| 186 shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '10:00'); | |
| 187 shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '11:00'); | |
| 188 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | |
| 189 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '03:00'); | |
| 190 shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '10:00'); | |
| 191 shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '15:00'); | |
| 192 shouldBeEqualToString('stepUp("20:00", 7200, "17:00", "20:00")', '17:00'); | |
| 193 shouldBeEqualToString('stepDown("20:00", 7200, "17:00", "20:00")', '19:00'); | |
| 194 | |
| 195 debug('Hours, 1-24'); | |
| 196 setDateTimeFormat('kk:mm'); | 242 setDateTimeFormat('kk:mm'); | 
| 197 shouldBeEqualToString('stepUp("11:00", 1, null, null)', '12:00'); | 243 runTests(tests4, 'Hours, 1-24'); | 
| 198 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '12:00'); | |
| 199 shouldBeEqualToString('stepDown("00:00", 1, null, null)', '23:00'); | |
| 200 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:00'); | |
| 201 shouldBeEqualToString('stepUp("23:00", 1, null, null)', '00:00'); | |
| 202 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '24:00'); | |
| 203 shouldBeEqualToString('stepDown("12:00", 1, null, null)', '11:00'); | |
| 204 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '11:00'); | |
| 205 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowUp"])', '02:00'); | |
| 206 shouldBeEqualToString('test("06:00", 7200, null, null, ["Delete", "ArrowDown"])' , '00:00'); | |
| 207 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowUp"]) ', '01:00'); | |
| 208 shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["Delete", "ArrowDown" ])', '23:00'); | |
| 209 shouldBeEqualToString('stepUp("17:00", 1, "17:00", "20:00")', '18:00'); | |
| 210 shouldBeEqualToString('stepDown("17:00", 1, "17:00", "20:00")', '20:00'); | |
| 211 shouldBeEqualToString('stepUp("17:00", 1, "15:00", "17:00")', '15:00'); | |
| 212 shouldBeEqualToString('stepDown("17:00", 1, "15:00", "17:00")', '16:00'); | |
| 213 shouldBeEqualToString('stepUp("15:00", 1, "17:00", "20:00")', '17:00'); | |
| 214 shouldBeEqualToString('stepDown("15:00", 1, "17:00", "20:00")', '20:00'); | |
| 215 shouldBeEqualToString('stepUp("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 216 shouldBeEqualToString('stepDown("15:00", 1, "13:00", "13:00")', '13:00'); | |
| 217 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | |
| 218 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '23:00'); | |
| 219 shouldBeEqualToString('stepUp("03:00", 1, "00:00", "03:00")', '04:00'); | |
| 220 shouldBeEqualToString('stepDown("03:00", 1, "00:00", "03:00")', '02:00'); | |
| 221 shouldBeEqualToString('stepUp("12:00", 1, "10:00", "12:00")', '10:00'); | |
| 222 shouldBeEqualToString('stepDown("12:00", 1, "10:00", "12:00")', '11:00'); | |
| 223 shouldBeEqualToString('stepUp("00:00", 1, "00:00", "03:00")', '01:00'); | |
| 224 shouldBeEqualToString('stepDown("00:00", 1, "00:00", "03:00")', '23:00'); | |
| 225 shouldBeEqualToString('stepUp("15:00", 1, "10:00", "15:00")', '10:00'); | |
| 226 shouldBeEqualToString('stepDown("10:00", 1, "10:00", "15:00")', '15:00'); | |
| 227 shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "20:00")', '19:00'); | |
| 228 shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "20:00")', '19:00'); | |
| 229 shouldBeEqualToString('stepUp("17:00", 7200, "17:00", "18:00")', '17:00'); | |
| 230 shouldBeEqualToString('stepDown("17:00", 7200, "17:00", "18:00")', '17:00'); | |
| 231 | 244 | 
| 232 setDateTimeFormat(''); | 245 setDateTimeFormat(''); | 
| 233 debug(''); | |
| 234 document.body.removeChild(input); | 246 document.body.removeChild(input); | 
| 235 </script> | 247 </script> | 
| 236 </body> | 248 </body> | 
| 237 </html> | 249 </html> | 
| OLD | NEW |