OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 </head> | 4 </head> |
5 <body> | 5 <body> |
6 <script type="text/javascript"> | 6 <script type="text/javascript"> |
7 description("This tests navigator.storageQuota.requestPersistentQuota."); | 7 description("This tests navigator.storageQuota.requestPersistentQuota."); |
8 | 8 |
| 9 var info; |
9 var usage; | 10 var usage; |
10 var grantedQuota; | 11 var grantedQuota; |
11 | 12 |
12 function onrejected(error) { | 13 function onrejected(error) { |
13 testFailed(error.name + ": " + error.message); | 14 testFailed(error.name + ": " + error.message); |
14 finishJSTest(); | 15 finishJSTest(); |
15 } | 16 } |
16 | 17 |
17 // Test body functions ---------------------------------------------------- | 18 // Test body functions ---------------------------------------------------- |
18 | 19 |
19 function runRequestQuotaTest() { | 20 function runRequestQuotaTest() { |
20 debug("* Requesting persistent quota."); | 21 debug("* Requesting persistent quota."); |
21 navigator.storageQuota.requestPersistentQuota(1024).then(function(storageInf
o) { | 22 navigator.storageQuota.requestPersistentQuota(1024).then(function(storageInf
o) { |
| 23 |
| 24 info = storageInfo; |
| 25 shouldBe("info.__proto__", "Object.prototype"); |
| 26 |
22 usage = storageInfo.usage; | 27 usage = storageInfo.usage; |
23 grantedQuota = storageInfo.quota; | 28 grantedQuota = storageInfo.quota; |
24 | 29 |
25 // Quota value would vary depending on the test environment. | 30 // Quota value would vary depending on the test environment. |
26 shouldBeGreaterThanOrEqual("usage", "0"); | 31 shouldBeGreaterThanOrEqual("usage", "0"); |
27 shouldBeNonZero("grantedQuota"); | 32 shouldBeNonZero("grantedQuota"); |
28 | 33 |
29 runNextTest(); | 34 runNextTest(); |
30 }, onrejected); | 35 }, onrejected); |
31 } | 36 } |
32 | 37 |
33 function runRequestQuotaWithMisingArgumentTest() { | 38 function runRequestQuotaWithMisingArgumentTest() { |
34 debug("* Requesting persistent quota with missing argument."); | 39 debug("* Requesting persistent quota with missing argument."); |
35 navigator.storageQuota.requestPersistentQuota().then(function() { | 40 navigator.storageQuota.requestPersistentQuota().then(function() { |
36 testFailed('resolved unexpectedly'); | 41 testFailed('resolved unexpectedly'); |
37 }, function(e) { | 42 }, function(e) { |
38 testPassed('rejected as expected: ' + e); | 43 testPassed('rejected as expected: ' + e); |
39 }).then(runNextTest); | 44 }).then(runNextTest); |
40 } | 45 } |
41 | 46 |
42 function runRequestQuotaWithNegativeValueTest() { | 47 function runRequestQuotaWithNegativeValueTest() { |
43 debug("* Requesting persistent quota with negative value."); | 48 debug("* Requesting persistent quota with negative value."); |
44 navigator.storageQuota.requestPersistentQuota(-1024).then(function(storageIn
fo) { | 49 navigator.storageQuota.requestPersistentQuota(-1024).then(function(storageIn
fo) { |
| 50 info = storageInfo; |
| 51 shouldBe("info.__proto__", "Object.prototype"); |
| 52 |
45 usage = storageInfo.usage; | 53 usage = storageInfo.usage; |
46 grantedQuota = storageInfo.quota; | 54 grantedQuota = storageInfo.quota; |
47 | 55 |
48 // Quota value would vary depending on the test environment. | 56 // Quota value would vary depending on the test environment. |
49 shouldBeGreaterThanOrEqual("usage", "0"); | 57 shouldBeGreaterThanOrEqual("usage", "0"); |
50 shouldBeZero("grantedQuota"); | 58 shouldBeZero("grantedQuota"); |
51 | 59 |
52 runNextTest(); | 60 runNextTest(); |
53 }, onrejected); | 61 }, onrejected); |
54 } | 62 } |
(...skipping 18 matching lines...) Expand all Loading... |
73 | 81 |
74 if (navigator.storageQuota) { | 82 if (navigator.storageQuota) { |
75 window.jsTestIsAsync = true; | 83 window.jsTestIsAsync = true; |
76 runNextTest(); | 84 runNextTest(); |
77 } else { | 85 } else { |
78 debug("This test requires navigator.storageQuota."); | 86 debug("This test requires navigator.storageQuota."); |
79 } | 87 } |
80 </script> | 88 </script> |
81 </body> | 89 </body> |
82 </html> | 90 </html> |
OLD | NEW |