|
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 <!-- |
|
8 https://bugzilla.mozilla.org/show_bug.cgi?id=786922 |
|
9 --> |
|
10 <head> |
|
11 <title>Test for basic sanity of the device storage API </title> |
|
12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <script type="text/javascript" src="devicestorage_common.js"></script> |
|
14 |
|
15 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
16 </head> |
|
17 <body> |
|
18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=786922">Mozilla Bug 786922</a> |
|
19 <p id="display"></p> |
|
20 <div id="content" style="display: none"> |
|
21 |
|
22 </div> |
|
23 <pre id="test"> |
|
24 <script class="testbody" type="text/javascript"> |
|
25 |
|
26 |
|
27 devicestorage_setup(); |
|
28 |
|
29 function add(storage, mime) { |
|
30 dump("adding: " + mime + "\n"); |
|
31 return navigator.getDeviceStorage(storage).add(createRandomBlob(mime)); |
|
32 } |
|
33 |
|
34 var tests = [ |
|
35 function () { return add("pictures", "image/png")}, |
|
36 function () { return add("videos", "video/webm")}, |
|
37 function () { return add("music", "audio/wav")}, |
|
38 function () { return add("sdcard", "maple/cookies")}, |
|
39 ]; |
|
40 |
|
41 function fail(e) { |
|
42 ok(false, "onerror was called"); |
|
43 devicestorage_cleanup(); |
|
44 } |
|
45 |
|
46 function next(e) { |
|
47 |
|
48 if (e != undefined) |
|
49 ok(true, "addError was called"); |
|
50 |
|
51 var f = tests.pop(); |
|
52 |
|
53 if (f == undefined) { |
|
54 devicestorage_cleanup(); |
|
55 return; |
|
56 } |
|
57 |
|
58 request = f(); |
|
59 request.onsuccess = next; |
|
60 request.onerror = fail; |
|
61 } |
|
62 |
|
63 next(); |
|
64 |
|
65 </script> |
|
66 </pre> |
|
67 </body> |
|
68 </html> |
|
69 |