| OLD | NEW |
| 1 <!DOCTYPE html> | 1 importScripts("/resources/testharness.js"); |
| 2 <title>navigator.storage methods return promises that are fulfilled</title> | |
| 3 <script src="/resources/testharness.js"></script> | |
| 4 <script src="/resources/testharnessreport.js"></script> | |
| 5 <script> | |
| 6 | 2 |
| 7 test(function() { assert_true(!!navigator.storage); }, | 3 test(function() { assert_true(!!navigator.storage); }, |
| 8 "These tests requires navigator.storage"); | 4 "These worker tests require navigator.storage"); |
| 9 | 5 |
| 10 promise_test(function() { | 6 test(function() { assert_false(navigator.storage.requestPersistent); }, |
| 11 var promise = navigator.storage.requestPersistent(); | 7 "navigator.storage.requestPersistent should not exist in workers"); |
| 12 assert_true(promise instanceof Promise, | |
| 13 "navigator.storage.requestPersistent() returned a Promise.") | |
| 14 return promise.then(function (result) { | |
| 15 // Layout tests get canned results, not the value per spec. So testing | |
| 16 // their values here would only be testing our test plumbing. But we can | |
| 17 // test that the type of the returned value is correct. | |
| 18 assert_equals(typeof result, "boolean", result + " should be boolean"); | |
| 19 }); | |
| 20 }, "navigator.storage.requestPersistent returns a promise that resolves."); | |
| 21 | 8 |
| 22 promise_test(function() { | 9 promise_test(function() { |
| 23 var promise = navigator.storage.persistentPermission(); | 10 var promise = navigator.storage.persistentPermission(); |
| 24 assert_true(promise instanceof Promise, | 11 assert_true(promise instanceof Promise, |
| 25 "navigator.storage.persistentPermission() returned a Promise.") | 12 "navigator.storage.persistentPermission() returned a Promise.") |
| 26 return promise.then(function (result) { | 13 return promise.then(function (result) { |
| 27 // See comment above about why the result value isn't being tested here. | 14 // Layout tests get canned results, not the value per spec. So testing |
| 15 // their values here would only be testing our test plumbing. But we can |
| 16 // test that the type of the returned value is correct. |
| 28 assert_equals(typeof result, "string", result + " should be a string"); | 17 assert_equals(typeof result, "string", result + " should be a string"); |
| 29 assert_greater_than(result.length, 0, "result should have length >0"); | 18 assert_greater_than(result.length, 0, "result should have length >0"); |
| 30 }); | 19 }); |
| 31 }, "navigator.storage.persistentPermission returns a promise that resolves."); | 20 }, "navigator.storage.persistentPermission returns a promise that resolves."); |
| 32 | 21 |
| 33 </script> | 22 done(); |
| OLD | NEW |