Continued unreviewed hacking on this test because that's my full time job now.
[WebKit-https.git] / LayoutTests / storage / storageinfo-no-callbacks.html
1 <html>
2 <head>
3 <script src="../resources/js-test-pre.js"></script>
4 </head>
5 <body>
6 <p id="description"></p>
7 <div id="console"></div>
8 <script>
9 description("This tests webkitStorageInfo methods do not crash when they are not given optional callbacks parameters.");
10
11 var testFinished = false;
12 var numberOfExpectedCallbacks = 0;
13
14 function callback()
15 {
16     testPassed("storageInfo callback called.");
17     --numberOfExpectedCallbacks;
18     checkCompleted();
19 }
20
21 function checkCompleted()
22 {
23     if (numberOfExpectedCallbacks == 0 && testFinished)
24         finishJSTest();
25 }
26
27 function isValidStorageType(type)
28 {
29     return (type == webkitStorageInfo.TEMPORARY || type == webkitStorageInfo.PERSISTENT);
30 }
31
32 function callStorageInfoMethodsWithFewerParameters(type)
33 {
34     webkitStorageInfo.requestQuota(type, 0);
35     webkitStorageInfo.queryUsageAndQuota(type);
36     if (isValidStorageType(type))
37         ++numberOfExpectedCallbacks;
38     webkitStorageInfo.requestQuota(type, 0, callback);
39     if (isValidStorageType(type))
40         ++numberOfExpectedCallbacks;
41     webkitStorageInfo.queryUsageAndQuota(type, callback);
42 }
43
44 if (window.webkitStorageInfo) {
45     window.jsTestIsAsync = true;
46
47     // Any of the following attempts should not cause crashing.
48     callStorageInfoMethodsWithFewerParameters(webkitStorageInfo.TEMPORARY);
49     callStorageInfoMethodsWithFewerParameters(webkitStorageInfo.PERSISTENT);
50     callStorageInfoMethodsWithFewerParameters(10);
51
52     testFinished = true;
53     checkCompleted();
54
55 } else
56     debug("This test requires window.webkitStorageInfo.");
57
58 window.successfullyParsed = true;
59
60 </script>
61 <script src="../resources/js-test-post.js"></script>
62 </body>
63 </html>