| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 
 | <!DOCTYPE html>
<html>
  <head>
    <title>Input Time</title>
     <meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
    <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-input-element">
   <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
      <h1>Input Time</h1>
      <div style="display:none;">
              <input type="time "id="chkDefaultValue" />
              <input type="time" id="chkStep" />
              <input type="time" id="chkSetValueTest" />
              <input type="time" id="chkSupportAttribute" min="01:01:01.001" max="12:12:12.012" step="600" />
      </div>
    <div id="log">
    </div>
  <script type="text/javascript">
/* check default value */
test(function(){ assert_equals(document.getElementById("chkDefaultValue").value, "");
}, "time element of default time value");
test(function(){assert_equals(document.getElementById('chkStep').step, "");
}, "step attribute on default value check");
test(function(){assert_equals(document.getElementById('chkDefaultValue').max, "");
}, "max  attribute on default value check")
test(function(){assert_equals(document.getElementById('chkDefaultValue').max, "");
}, "min  attribute on default value check")
/* simple attribute test*/
test(function(){assert_equals(document.getElementById("chkSupportAttribute").type,"time");}
  , "type attribute support on input element");
test(function(){assert_equals(document.getElementById('chkSupportAttribute').min, "01:01:01.001")}
  , "max attribute support on input element");
test(function(){assert_equals(document.getElementById('chkSupportAttribute').max, "12:12:12.012")}
  , "min attribute support on input element");
test(function(){assert_equals(document.getElementById("chkSupportAttribute").step, "600")}
  , "step attribute support on input element");
/* check step up and down */
var _StepTest = document.getElementById("chkStep");
test(function(){ assert_true(typeof(_StepTest.stepUp) ==="function" ) }   , "stepUp function support on input Element");
test(function(){ assert_true(typeof(_StepTest.stepDown) ==="function" ) } , "stepDown function support on input Element");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "12:01",
      "12:01:00",
      "12:01:00.0",
      "12:01:00.00",
      "12:01:00.000"],
    "a valid time string representing 1 minute after noon");
} , "stepUp step value empty on default step value ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "11:59",
      "11:59:00",
      "11:59:00.0",
      "11:59:00.00",
      "11:59:00.000"],
    "a valid time string representing 1 minute before noon");
}, "stepDown step value empty default step value");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "-600";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "12:01",
      "12:01:00",
      "12:01:00.0",
      "12:01:00.00",
      "12:01:00.000"],
    "a valid time string representing 1 minute after noon");
},"stepUp on step value minus");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "-600";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "11:59",
      "11:59:00",
      "11:59:00.0",
      "11:59:00.00",
      "11:59:00.000"],
    "a valid time string representing 1 minute before noon");
},"stepDown on step value minus");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "0";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "12:01",
      "12:01:00",
      "12:01:00.0",
      "12:01:00.00",
      "12:01:00.000"],
    "a valid time string representing 1 minute after noon");
} , "stepUp on step value zero ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "0";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "11:59",
      "11:59:00",
      "11:59:00.0",
      "11:59:00.00",
      "11:59:00.000"],
    "a valid time string representing 1 minute before noon");
} , "stepDown on step value zero ");
test(function(){
  _StepTest.value = "00:00";
  _StepTest.step = "86399";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "23:59:59",
      "23:59:59.0",
      "23:59:59.00",
      "23:59:59.000"],
    "a valid time string representing 1 second before midnight");
} , "stepUp on step value 24 hour");
test(function(){
  _StepTest.value = "23:59:59";
  _StepTest.step = "86399";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "00:00",
      "00:00:00",
      "00:00:00.0",
      "00:00:00.00",
      "00:00:00.000"],
    "a valid time string representing midnight");
} , "stepDown on step value 24 hour ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "3600";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "13:00",
      "13:00:00",
      "13:00:00.0",
      "13:00:00.00",
      "13:00:00.000"],
    "a valid time string representing 1pm");
} , "stepUp on step value hour  ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "3600";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "11:00",
      "11:00:00",
      "11:00:00.0",
      "11:00:00.00",
      "11:00:00.000"],
    "a valid time string representing 11am");
} , "stepDown on step value hour ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "1";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "12:00:01",
      "12:00:01.0",
      "12:00:01.00",
      "12:00:01.000"],
    "a valid time string representing 1 second after noon");
} , "stepUp on step value second ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "1";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "11:59:59",
      "11:59:59.0",
      "11:59:59.00",
      "11:59:59.000"],
    "a valid time string representing 1 second before noon");
} , "stepDown on step value second ");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "0.001";
  _StepTest.stepUp();
  assert_equals(_StepTest.value, "12:00:00.001");
} , "stepUp on step value with fractional seconds");
test(function(){
  _StepTest.value = "12:00";
  _StepTest.step = "0.001";
  _StepTest.stepDown();
  assert_equals(_StepTest.value, "11:59:59.999");
} , "stepDown on step value with fractional seconds");
test(function(){
  _StepTest.value = "13:00:00";
  _StepTest.step = "1";
  _StepTest.stepUp(2);
  assert_in_array(
    _StepTest.value,
    [
      "13:00:02",
      "13:00:02.0",
      "13:00:02.00",
      "13:00:02.000"],
    "a valid time string representing 2 seconds after 1pm");
}, "stepUp argument 2 times");
test(function(){
  _StepTest.value = "13:00:00";
  _StepTest.step = "1";
  _StepTest.stepDown(2);
  assert_in_array(
    _StepTest.value,
    [
      "12:59:58",
      "12:59:58.0",
      "12:59:58.00",
      "12:59:58.000"],
    "a valid time string representing 2 seconds before 1pm");
}, "stepDown argument 2 times");
test(function(){
  _StepTest.max = "15:00";
  this.add_cleanup(function() { _StepTest.max = ""; });
  _StepTest.value = "15:00";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "15:00",
      "15:00:00",
      "15:00:00.0",
      "15:00:00.00",
      "15:00:00.000"],
    "a valid time string representing 3pm");
} , "stepUp stop because it exceeds the maximum value");
test(function(){
  _StepTest.min = "13:00";
  this.add_cleanup(function() { _StepTest.min = ""; });
  _StepTest.value = "13:00";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "13:00",
      "13:00:00",
      "13:00:00.0",
      "13:00:00.00",
      "13:00:00.000"],
    "a valid time string representing 1pm");
} , "stepDown stop so lower than the minimum value");
test(function(){
  _StepTest.max = "15:01";
  this.add_cleanup(function() { _StepTest.max = ""; });
  _StepTest.value = "15:00";
  _StepTest.step = "120";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "15:01",
      "15:01:00",
      "15:01:00.0",
      "15:01:00.00",
      "15:01:00.000"],
    "a valid time string representing 1 minute after 3pm");
} , "stop at border on stepUp");
test(function(){
  _StepTest.min = "12:59";
  this.add_cleanup(function() { _StepTest.min = ""; });
  _StepTest.value = "13:00";
  _StepTest.step = "120";
  _StepTest.stepDown();
  assert_in_array(
    _StepTest.value,
    [
      "12:59",
      "12:59:00",
      "12:59:00.0",
      "12:59:00.00",
      "12:59:00.000"],
    "a valid time string representing 1 minute before 2pm");
} , "stop at border on stepDown");
test(function(){
  _StepTest.value = "";
  _StepTest.step = "60";
  _StepTest.stepUp();
  assert_in_array(
    _StepTest.value,
    [
      "00:01",
      "00:01:00",
      "00:01:00.0",
      "00:01:00.00",
      "00:01:00.000"],
    "a valid time string representing 1 minute after midnight");
} , " empty value of stepUp");
/* set value test */
test(function(){
  var _time = document.getElementById("chkSetValueTest");
  _time.value = "12:00:00.000";
  assert_equals(_time.value, "12:00:00.000");
  _time.value = "hh:mi:ss.sss";
  assert_equals(_time.value, "");
}, "set value on not time format value");
  </script>
  </body>
</html>
 |