invalid-values.html (1318B)
1 <!DOCTYPE html> 2 <meta charset='utf-8'> 3 <title>Vibration API: vibrate(invalid)</title> 4 <link rel='author' title='Intel' href='http://www.intel.com'> 5 <link rel='help' href='https://w3c.github.io/vibration/#vibration-interface'> 6 <script src='/resources/testharness.js'></script> 7 <script src='/resources/testharnessreport.js'></script> 8 <div id='log'></div> 9 <script> 10 test(function() { 11 assert_implements(navigator.vibrate, 'navigator.vibrate exists'); 12 assert_throws_js(TypeError, function() { 13 navigator.vibrate(); 14 }, 'Argument is required, so was expecting a TypeError.'); 15 }, 'Missing pattern argument'); 16 17 test(function() { 18 navigator.vibrate(undefined); 19 }, 'pattern of undefined resolves to []'); 20 21 test(function() { 22 navigator.vibrate(null); 23 }, 'pattern of null resolves to []'); 24 25 test(function() { 26 navigator.vibrate('one'); 27 }, 'pattern of empty string resolves to [""]'); 28 29 test(function() { 30 navigator.vibrate('one'); 31 }, 'pattern of string resolves to ["one"]'); 32 33 test(function() { 34 navigator.vibrate(new String('one')); 35 }, 'pattern of String instance resolves to ["one"]'); 36 37 test(function() { 38 navigator.vibrate(NaN); 39 }, 'pattern of NaN resolves to [NaN]'); 40 41 test(function() { 42 navigator.vibrate({}); 43 }, 'pattern of {} resolves to [{}]'); 44 </script>