3 <script src=
"../../resources/js-test.js"></script>
6 <script type=
"text/javascript">
7 description("This tests navigator.storageQuota.requestPersistentQuota.");
12 function onrejected(error
) {
13 testFailed(error
.name
+ ": " + error
.message
);
17 // Test body functions ----------------------------------------------------
19 function runRequestQuotaTest() {
20 debug("* Requesting persistent quota.");
21 navigator
.storageQuota
.requestPersistentQuota(1024).then(function(storageInfo
) {
22 usage
= storageInfo
.usage
;
23 grantedQuota
= storageInfo
.quota
;
25 // Quota value would vary depending on the test environment.
26 shouldBeGreaterThanOrEqual("usage", "0");
27 shouldBeNonZero("grantedQuota");
33 function runRequestQuotaWithMisingArgumentTest() {
34 debug("* Requesting persistent quota with missing argument.");
35 navigator
.storageQuota
.requestPersistentQuota().then(function() {
36 testFailed('resolved unexpectedly');
38 testPassed('rejected as expected: ' + e
);
42 function runRequestQuotaWithNegativeValueTest() {
43 debug("* Requesting persistent quota with negative value.");
44 navigator
.storageQuota
.requestPersistentQuota(-1024).then(function(storageInfo
) {
45 usage
= storageInfo
.usage
;
46 grantedQuota
= storageInfo
.quota
;
48 // Quota value would vary depending on the test environment.
49 shouldBeGreaterThanOrEqual("usage", "0");
50 shouldBeZero("grantedQuota");
56 // End of test body functions ---------------------------------------------
60 runRequestQuotaWithMisingArgumentTest
,
61 runRequestQuotaWithNegativeValueTest
,
65 function runNextTest() {
66 if (testCounter
== testsList
.length
) {
67 debug("Finished running tests.");
70 testsList
[testCounter
++]();
74 if (navigator
.storageQuota
) {
75 window
.jsTestIsAsync
= true;
78 debug("This test requires navigator.storageQuota.");