3 <script src="../../resources/js-test.js"></script>
6 <script type="text/javascript">
7 description("This tests navigator.storageQuota.queryInfo.");
12 function onrejected(error) {
13 testFailed(error.name + ": " + error.message);
17 // Test body functions ----------------------------------------------------
19 function runQueryTemporaryTest() {
20 debug("* Querying about temporary storage.");
21 navigator.storageQuota.queryInfo("temporary").then(function(storageInfo) {
22 usage = storageInfo.usage;
23 quota = storageInfo.quota;
25 // Quota value would vary depending on the test environment.
26 shouldBeGreaterThanOrEqual("usage", "0");
27 shouldBeGreaterThanOrEqual("quota", "usage");
33 function runQueryPersistentTest() {
34 debug("* Querying about persistent storage.");
35 navigator.storageQuota.queryInfo("persistent").then(function(storageInfo) {
36 usage = storageInfo.usage;
37 quota = storageInfo.quota;
39 // Quota value would vary depending on the test environment.
40 shouldBeGreaterThanOrEqual("usage", "0");
41 shouldBeGreaterThanOrEqual("quota", "usage");
47 function runQueryUnknownTest() {
48 debug("* Querying about unknown storage.");
49 shouldThrow("navigator.storageQuota.queryInfo('unknown')");
53 function runQueryWithMissingArgumentTest() {
54 debug("* Querying with missing storage type.");
55 shouldThrow("navigator.storageQuota.queryInfo()");
59 // End of test body functions ---------------------------------------------
62 runQueryTemporaryTest,
63 runQueryPersistentTest,
65 runQueryWithMissingArgumentTest,
69 function runNextTest() {
70 if (testCounter == testsList.length) {
71 debug("Finished running tests.");
74 testsList[testCounter++]();
78 if (navigator.storageQuota) {
79 window.jsTestIsAsync = true;
82 debug("This test requires navigator.storageQuota.");