| <!DOCTYPE html> |
| <meta charset="utf-8"> |
| <title>WakeLockType Test</title> |
| <link rel="help" href="https://w3c.github.io/wake-lock/"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| |
| <script> |
| |
| test(() => { |
| const wakeLock = new WakeLock("screen"); |
| assert_equals(wakeLock.type, "screen"); |
| }, "Test that wakeLock.type is 'screen' when screen wake lock is invoked"); |
| |
| test(() => { |
| const wakeLock = new WakeLock("system"); |
| assert_equals(wakeLock.type, "system"); |
| }, "Test that wakeLock.type is 'system' when system wake lock is invoked"); |
| |
| test(() => { |
| assert_throws(new TypeError(), () => new WakeLock()); |
| }, "'TypeError' is thrown when set an empty wake lock type"); |
| |
| test(() => { |
| const invalidTypes = [ |
| "invalid", |
| null, |
| 123, |
| {}, |
| "", |
| true |
| ]; |
| invalidTypes.map(invalidType => { |
| assert_throws(new TypeError(), () => new WakeLock(invalidType)); |
| }) |
| }, "'TypeError' is thrown when set an invalid wake lock type"); |
| |
| </script> |