Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / quota / storagequota-query-info.html
blob983ee4d7c5446755188536b4980b8de3b8f20fae
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.queryInfo.");
9 var usage;
10 var quota;
12 function onrejected(error) {
13 testFailed(error.name + ": " + error.message);
14 finishJSTest();
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");
29 runNextTest();
30 }, onrejected);
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");
43 runNextTest();
44 }, onrejected);
47 function runQueryUnknownTest() {
48 debug("* Querying about unknown storage.");
49 navigator.storageQuota.queryInfo('unknown').then(function() {
50 testFailed('resolved unexpectedly');
51 }, function(e) {
52 testPassed('rejected as expected: ' + e);
53 }).then(runNextTest);
56 function runQueryWithMissingArgumentTest() {
57 debug("* Querying with missing storage type.");
58 navigator.storageQuota.queryInfo().then(function() {
59 testFailed('resolved unexpectedly');
60 }, function(e) {
61 testPassed('rejected as expected: ' + e);
62 }).then(runNextTest);
65 // End of test body functions ---------------------------------------------
67 var testsList = [
68 runQueryTemporaryTest,
69 runQueryPersistentTest,
70 runQueryUnknownTest,
71 runQueryWithMissingArgumentTest,
73 var testCounter = 0;
75 function runNextTest() {
76 if (testCounter == testsList.length) {
77 debug("Finished running tests.");
78 finishJSTest();
79 } else {
80 testsList[testCounter++]();
84 if (navigator.storageQuota) {
85 window.jsTestIsAsync = true;
86 runNextTest();
87 } else {
88 debug("This test requires navigator.storageQuota.");
90 </script>
91 </body>
92 </html>