Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / storage / quota / storageinfo-no-callbacks.html
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body>
6 <p id="description"></p>
7 <div id="console"></div>
8 <script type="text/javascript">
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 } else {
55     debug("This test requires window.webkitStorageInfo.");
56 }
57 </script>
58 </body>
59 </html>