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 navigator
.storageQuota
.queryInfo('unknown').then(function() {
50 testFailed('resolved unexpectedly');
52 testPassed('rejected as expected: ' + e
);
56 function runQueryWithMissingArgumentTest() {
57 debug("* Querying with missing storage type.");
58 navigator
.storageQuota
.queryInfo().then(function() {
59 testFailed('resolved unexpectedly');
61 testPassed('rejected as expected: ' + e
);
65 // End of test body functions ---------------------------------------------
68 runQueryTemporaryTest
,
69 runQueryPersistentTest
,
71 runQueryWithMissingArgumentTest
,
75 function runNextTest() {
76 if (testCounter
== testsList
.length
) {
77 debug("Finished running tests.");
80 testsList
[testCounter
++]();
84 if (navigator
.storageQuota
) {
85 window
.jsTestIsAsync
= true;
88 debug("This test requires navigator.storageQuota.");