summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/vibration
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/vibration')
-rw-r--r--testing/web-platform/tests/vibration/META.yml3
-rw-r--r--testing/web-platform/tests/vibration/api-is-present.html26
-rw-r--r--testing/web-platform/tests/vibration/cancel-when-hidden-manual.html36
-rw-r--r--testing/web-platform/tests/vibration/cancel-with-0-manual.html30
-rw-r--r--testing/web-platform/tests/vibration/cancel-with-array-0-manual.html31
-rw-r--r--testing/web-platform/tests/vibration/cancel-with-empty-array-manual.html30
-rw-r--r--testing/web-platform/tests/vibration/cancel-with-new-manual.html31
-rw-r--r--testing/web-platform/tests/vibration/idlharness.window.js13
-rw-r--r--testing/web-platform/tests/vibration/invalid-values.html44
-rw-r--r--testing/web-platform/tests/vibration/pattern-array-extra-manual.html26
-rw-r--r--testing/web-platform/tests/vibration/pattern-array-manual.html25
-rw-r--r--testing/web-platform/tests/vibration/pattern-array-with-0-manual.html24
-rw-r--r--testing/web-platform/tests/vibration/silent-ignore.html37
-rw-r--r--testing/web-platform/tests/vibration/simple-array-manual.html22
-rw-r--r--testing/web-platform/tests/vibration/simple-scalar-manual.html24
15 files changed, 402 insertions, 0 deletions
diff --git a/testing/web-platform/tests/vibration/META.yml b/testing/web-platform/tests/vibration/META.yml
new file mode 100644
index 0000000000..411450e0b1
--- /dev/null
+++ b/testing/web-platform/tests/vibration/META.yml
@@ -0,0 +1,3 @@
+spec: https://w3c.github.io/vibration/
+suggested_reviewers:
+ - anssiko
diff --git a/testing/web-platform/tests/vibration/api-is-present.html b/testing/web-platform/tests/vibration/api-is-present.html
new file mode 100644
index 0000000000..70aa4047e1
--- /dev/null
+++ b/testing/web-platform/tests/vibration/api-is-present.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test that the vibrate() method is present (with or without vendor prefix)</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom'/>
+ <meta name='assert' content='Check that the vibrate() method is present.'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ This test checks for the presence of the <code>vibrate()</code> method, taking
+ vendor prefixes into account.
+ </p>
+ <div id='log'></div>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script>
+ test(function () {
+ assert_not_equals(undefined, navigator.vibrate, "navigator.vibrate exists");
+ }, "vibrate() is present on navigator");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/cancel-when-hidden-manual.html b/testing/web-platform/tests/vibration/cancel-when-hidden-manual.html
new file mode 100644
index 0000000000..0ae30b6235
--- /dev/null
+++ b/testing/web-platform/tests/vibration/cancel-when-hidden-manual.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<meta charset='utf-8'>
+<title>Vibration API: cancel ongoing vibrate() when hidden by switching tab/window</title>
+<link rel='author' title='Intel' href='http://www.intel.com'>
+<link rel='help' href='http://dev.w3.org/2009/dap/vibration/#vibration-interface'>
+<meta name='flags' content='interact'>
+<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'>
+<style>
+ button {
+ height: 100px;
+ width: 100px;
+ }
+</style>
+
+<h1>Description</h1>
+<p>
+ After hitting the button below, your device must vibrate for a short period of time (roughly one
+ second). If it vibrates for a longer time (roughly five seconds, it should feel somewhat long) then
+ the test has failed.
+</p>
+<button id='vib'>Vibrate!</button>
+<script>
+ var win;
+
+ if (undefined !== navigator.vibrate) {
+ document.getElementById('vib').onclick = function () {
+ navigator.vibrate(5000);
+ setTimeout(function () {
+ win = window.open('about:blank', '_blank');
+ setTimeout(function() {
+ win.close();
+ }, 100);
+ }, 1000);
+ };
+ }
+</script>
diff --git a/testing/web-platform/tests/vibration/cancel-with-0-manual.html b/testing/web-platform/tests/vibration/cancel-with-0-manual.html
new file mode 100644
index 0000000000..86981c11f8
--- /dev/null
+++ b/testing/web-platform/tests/vibration/cancel-with-0-manual.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: cancel ongoing vibrate() with 0</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ <meta name='assert' content='If pattern is 0, cancel the pre-existing instance of the processing vibration patterns algorithm'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate for a short period of time (roughly one
+ second). If it vibrates for a longer time (roughly five seconds, it should feel somewhat long) then
+ the test has failed.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate(5000);
+ setTimeout(function () {
+ navigator.vibrate(0);
+ }, 1000);
+ };
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/cancel-with-array-0-manual.html b/testing/web-platform/tests/vibration/cancel-with-array-0-manual.html
new file mode 100644
index 0000000000..9cdf282ebc
--- /dev/null
+++ b/testing/web-platform/tests/vibration/cancel-with-array-0-manual.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<meta charset='utf-8'>
+<title>Vibration API: cancel ongoing vibrate() with [0]</title>
+<link rel='author' title='Intel' href='http://www.intel.com'>
+<link rel='help' href='http://dev.w3.org/2009/dap/vibration/#vibration-interface'>
+<meta name='flags' content='interact'>
+<meta name='assert' content='If pattern contains a single entry with a value of 0, cancel the pre-existing instance of the processing vibration patterns algorithm'>
+<style>
+ button {
+ height: 100px;
+ width: 100px;
+ }
+</style>
+
+<h1>Description</h1>
+<p>
+ After hitting the button below, your device must vibrate for a short period of time (roughly one
+ second). If it vibrates for a longer time (roughly five seconds, it should feel somewhat long) then
+ the test has failed.
+</p>
+<button id='vib'>Vibrate!</button>
+<script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById('vib').onclick = function () {
+ navigator.vibrate(5000);
+ setTimeout(function () {
+ navigator.vibrate([0]);
+ }, 1000);
+ };
+ }
+</script>
diff --git a/testing/web-platform/tests/vibration/cancel-with-empty-array-manual.html b/testing/web-platform/tests/vibration/cancel-with-empty-array-manual.html
new file mode 100644
index 0000000000..8e48173e7e
--- /dev/null
+++ b/testing/web-platform/tests/vibration/cancel-with-empty-array-manual.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: cancel ongoing vibrate() with []</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ <meta name='assert' content='If pattern is an empty list, cancel the pre-existing instance of the processing vibration patterns algorithm'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate for a short period of time (roughly one
+ second). If it vibrates for a longer time (roughly five seconds, it should feel somewhat long) then
+ the test has failed.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate(5000);
+ setTimeout(function () {
+ navigator.vibrate([]);
+ }, 1000);
+ };
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/cancel-with-new-manual.html b/testing/web-platform/tests/vibration/cancel-with-new-manual.html
new file mode 100644
index 0000000000..64e6e9b548
--- /dev/null
+++ b/testing/web-platform/tests/vibration/cancel-with-new-manual.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: cancel ongoing vibrate() with a new call to vibrate</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ <meta name='assert' content='Cancel the pre-existing instance of the processing vibration patterns algorithm, if any.'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate continuously for a short period of time (roughly one
+ second), then vibrate a series of short bursts. If the initial continuously vibration is longer (roughly five
+ seconds, it should feel somewhat long) or if there is no series of short vibration bursts then the test has
+ failed.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate(5000);
+ setTimeout(function () {
+ navigator.vibrate([200, 200, 200, 200, 200, 200, 200, 200, 200]);
+ }, 1000);
+ };
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/idlharness.window.js b/testing/web-platform/tests/vibration/idlharness.window.js
new file mode 100644
index 0000000000..a3cfbc11e0
--- /dev/null
+++ b/testing/web-platform/tests/vibration/idlharness.window.js
@@ -0,0 +1,13 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+// META: timeout=long
+
+'use strict';
+
+idl_test(
+ ['vibration'],
+ ['html'],
+ idl_array => {
+ idl_array.add_objects({Navigator: ['navigator']});
+ }
+);
diff --git a/testing/web-platform/tests/vibration/invalid-values.html b/testing/web-platform/tests/vibration/invalid-values.html
new file mode 100644
index 0000000000..b5a3f39ac6
--- /dev/null
+++ b/testing/web-platform/tests/vibration/invalid-values.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<meta charset='utf-8'>
+<title>Vibration API: vibrate(invalid)</title>
+<link rel='author' title='Intel' href='http://www.intel.com'>
+<link rel='help' href='https://w3c.github.io/vibration/#vibration-interface'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<div id='log'></div>
+<script>
+ test(function() {
+ assert_implements(navigator.vibrate, 'navigator.vibrate exists');
+ assert_throws_js(TypeError, function() {
+ navigator.vibrate();
+ }, 'Argument is required, so was expecting a TypeError.');
+ }, 'Missing pattern argument');
+
+ test(function() {
+ navigator.vibrate(undefined);
+ }, 'pattern of undefined resolves to []');
+
+ test(function() {
+ navigator.vibrate(null);
+ }, 'pattern of null resolves to []');
+
+ test(function() {
+ navigator.vibrate('one');
+ }, 'pattern of empty string resolves to [""]');
+
+ test(function() {
+ navigator.vibrate('one');
+ }, 'pattern of string resolves to ["one"]');
+
+ test(function() {
+ navigator.vibrate(new String('one'));
+ }, 'pattern of String instance resolves to ["one"]');
+
+ test(function() {
+ navigator.vibrate(NaN);
+ }, 'pattern of NaN resolves to [NaN]');
+
+ test(function() {
+ navigator.vibrate({});
+ }, 'pattern of {} resolves to [{}]');
+</script>
diff --git a/testing/web-platform/tests/vibration/pattern-array-extra-manual.html b/testing/web-platform/tests/vibration/pattern-array-extra-manual.html
new file mode 100644
index 0000000000..b23323ace2
--- /dev/null
+++ b/testing/web-platform/tests/vibration/pattern-array-extra-manual.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test a pattern array parameter to vibrate() with an extra (even) item</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ <meta name='assert' content='If the length of pattern is even, then remove the last entry in pattern.'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate three times for one second, separated
+ by one second intervals.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate([1000, 1000, 1000, 1000, 1000, 1000]);
+ };
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/pattern-array-manual.html b/testing/web-platform/tests/vibration/pattern-array-manual.html
new file mode 100644
index 0000000000..0c7063f1e0
--- /dev/null
+++ b/testing/web-platform/tests/vibration/pattern-array-manual.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test a pattern array parameter to vibrate()</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate three times for one second, separated
+ by one second intervals.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate([1000, 1000, 1000, 1000, 1000]);
+ };
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/pattern-array-with-0-manual.html b/testing/web-platform/tests/vibration/pattern-array-with-0-manual.html
new file mode 100644
index 0000000000..491f2b1675
--- /dev/null
+++ b/testing/web-platform/tests/vibration/pattern-array-with-0-manual.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<meta charset='utf-8'>
+<title>Vibration API: test a pattern array with 0ms vibration and still to vibrate()</title>
+<link rel='author' title='Intel' href='http://www.intel.com'>
+<link rel='help' href='http://dev.w3.org/2009/dap/vibration/#vibration-interface'>
+<meta name='flags' content='interact'>
+<style>
+ button {
+ height: 100px;
+ width: 100px;
+ }
+</style>
+
+<h1>Description</h1>
+<p>
+ After hitting the button below, your device must vibrate continuously for about two seconds, once.
+</p>
+<button id='vib'>Vibrate!</button>
+<div id='log'></div>
+<script>
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate([0, 0, 2000]);
+ };
+</script>
diff --git a/testing/web-platform/tests/vibration/silent-ignore.html b/testing/web-platform/tests/vibration/silent-ignore.html
new file mode 100644
index 0000000000..a04c648bd1
--- /dev/null
+++ b/testing/web-platform/tests/vibration/silent-ignore.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test that calls to vibrate() are silently ignored when the device cannot vibrate</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='https://w3c.github.io/vibration/#dfn-perform-vibration'/>
+ <meta name='flags' content='dom, no-vibrator'/>
+ <meta name='assert' content='If the device does not provide a vibration mechanism, or it is disabled, the user agent must silently ignore any invocations of the vibrate() method.'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ <strong>This test is only useful on devices that do not have vibration capability</strong>.
+ If your device supports vibration, then <strong>skip</strong> this test. An implementation
+ supporting this API but running on a device that cannot vibrate must silently ignore the
+ call (we test that it doesn't throw).
+ </p>
+ <button type="button" id="button">Click here if the device doesn't support vibration</button>
+ <div id='log'></div>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src='/resources/testdriver.js'></script>
+ <script src='/resources/testdriver-vendor.js'></script>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ async_test(function (t) {
+ var target = document.getElementById('button');
+ target.addEventListener("click", t.step_func_done(function() {
+ assert_true(navigator.vibrate(1000), "vibrate() returns true when vibration is not supported");
+ }));
+ test_driver.click(target).catch(t.unreached_func("click failed"));
+ }, "Calling vibrate returns true");
+ }
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/simple-array-manual.html b/testing/web-platform/tests/vibration/simple-array-manual.html
new file mode 100644
index 0000000000..52fa99773c
--- /dev/null
+++ b/testing/web-platform/tests/vibration/simple-array-manual.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test a simple array parameter to vibrate()</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate continuously for about two seconds, once.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <div id='log'></div>
+ <script>
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate([2000]);
+ };
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/vibration/simple-scalar-manual.html b/testing/web-platform/tests/vibration/simple-scalar-manual.html
new file mode 100644
index 0000000000..16fc2a9f85
--- /dev/null
+++ b/testing/web-platform/tests/vibration/simple-scalar-manual.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <title>Vibration API: test a simple scalar parameter to vibrate()</title>
+ <link rel='author' title='Robin Berjon' href='mailto:robin@berjon.com'/>
+ <link rel='help' href='http://www.w3.org/TR/vibration/#methods'/>
+ <meta name='flags' content='dom, interact'/>
+ </head>
+ <body>
+ <h1>Description</h1>
+ <p>
+ After hitting the button below, your device must vibrate continuously for about two seconds, once.
+ </p>
+ <button id='vib'>Vibrate!</button>
+ <script>
+ if (undefined !== navigator.vibrate) {
+ document.getElementById("vib").onclick = function () {
+ navigator.vibrate(2000);
+ };
+ }
+ </script>
+ </body>
+</html>