cancel-when-hidden-manual.html (1212B)
1 <!DOCTYPE html> 2 <meta charset='utf-8'> 3 <title>Vibration API: cancel ongoing vibrate() when hidden by switching tab/window</title> 4 <link rel='author' title='Intel' href='http://www.intel.com'> 5 <link rel='help' href='http://dev.w3.org/2009/dap/vibration/#vibration-interface'> 6 <meta name='flags' content='interact'> 7 <meta name='assert' content='If the visibilitychange event is dispatched at the Document in a browsing context, cancel the pre-existing instance of the processing vibration patterns algorithm'> 8 <style> 9 button { 10 height: 100px; 11 width: 100px; 12 } 13 </style> 14 15 <h1>Description</h1> 16 <p> 17 After hitting the button below, your device must vibrate for a short period of time (roughly one 18 second). If it vibrates for a longer time (roughly five seconds, it should feel somewhat long) then 19 the test has failed. 20 </p> 21 <button id='vib'>Vibrate!</button> 22 <script> 23 var win; 24 25 if (undefined !== navigator.vibrate) { 26 document.getElementById('vib').onclick = function () { 27 navigator.vibrate(5000); 28 setTimeout(function () { 29 win = window.open('about:blank', '_blank'); 30 setTimeout(function() { 31 win.close(); 32 }, 100); 33 }, 1000); 34 }; 35 } 36 </script>