Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / quota / storagequota-request-persistent-quota.html
blob942b349e866b9903b5046da5092d540917fbf55e
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body>
6 <script type="text/javascript">
7 description("This tests navigator.storageQuota.requestPersistentQuota.");
9 var usage;
10 var grantedQuota;
12 function onrejected(error) {
13 testFailed(error.name + ": " + error.message);
14 finishJSTest();
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");
29 runNextTest();
30 }, onrejected);
33 function runRequestQuotaWithMisingArgumentTest() {
34 debug("* Requesting persistent quota with missing argument.");
35 navigator.storageQuota.requestPersistentQuota().then(function() {
36 testFailed('resolved unexpectedly');
37 }, function(e) {
38 testPassed('rejected as expected: ' + e);
39 }).then(runNextTest);
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");
52 runNextTest();
53 }, onrejected);
56 // End of test body functions ---------------------------------------------
58 var testsList = [
59 runRequestQuotaTest,
60 runRequestQuotaWithMisingArgumentTest,
61 runRequestQuotaWithNegativeValueTest,
63 var testCounter = 0;
65 function runNextTest() {
66 if (testCounter == testsList.length) {
67 debug("Finished running tests.");
68 finishJSTest();
69 } else {
70 testsList[testCounter++]();
74 if (navigator.storageQuota) {
75 window.jsTestIsAsync = true;
76 runNextTest();
77 } else {
78 debug("This test requires navigator.storageQuota.");
80 </script>
81 </body>
82 </html>