|
1 <!-- |
|
2 Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 --> |
|
5 <!DOCTYPE HTML> |
|
6 <html> <!-- |
|
7 https://bugzilla.mozilla.org/show_bug.cgi?id=717103 |
|
8 --> |
|
9 <head> |
|
10 <title>Test for the device storage API </title> |
|
11 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
12 <script type="text/javascript" src="devicestorage_common.js"></script> |
|
13 |
|
14 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
15 </head> |
|
16 <body> |
|
17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a> |
|
18 <p id="display"></p> |
|
19 <div id="content" style="display: none"> |
|
20 |
|
21 </div> |
|
22 <pre id="test"> |
|
23 <script class="testbody" type="text/javascript"> |
|
24 |
|
25 devicestorage_setup(); |
|
26 |
|
27 function freeSpaceSuccess(e) { |
|
28 ok(e.target.result > 0, "free bytes should exist and be greater than zero"); |
|
29 devicestorage_cleanup(); |
|
30 } |
|
31 |
|
32 function freeSpaceError(e) { |
|
33 ok(false, "freeSpaceError was called"); |
|
34 devicestorage_cleanup(); |
|
35 } |
|
36 |
|
37 var storage = navigator.getDeviceStorage("pictures"); |
|
38 |
|
39 function addError(e) { |
|
40 ok(false, "addError was called : " + e.target.error.name); |
|
41 devicestorage_cleanup(); |
|
42 } |
|
43 |
|
44 function addSuccess(e) { |
|
45 request = storage.freeSpace(); |
|
46 ok(request, "Should have a non-null request"); |
|
47 |
|
48 request.onsuccess = freeSpaceSuccess; |
|
49 request.onerror = freeSpaceError; |
|
50 } |
|
51 |
|
52 var prefix = "devicestorage/" + randomFilename(12); |
|
53 request = storage.addNamed(createRandomBlob('image/png'), prefix + "/a/b.png"); |
|
54 request.onsuccess = addSuccess; |
|
55 request.onerror = addError; |
|
56 |
|
57 </script> |
|
58 </pre> |
|
59 </body> |
|
60 </html> |
|
61 |