|
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 testingStorage() { |
|
28 return navigator.getDeviceStorage("pictures"); |
|
29 } |
|
30 |
|
31 var tests = [ |
|
32 function () { return testingStorage().addNamed(createRandomBlob('image/png'), gFileName); }, |
|
33 function () { return testingStorage().delete(gFileName); }, |
|
34 function () { return testingStorage().get(gFileName); }, |
|
35 function () { var r = testingStorage().enumerate("../"); return r; } |
|
36 ]; |
|
37 |
|
38 var gFileName = "../owned.png"; |
|
39 |
|
40 function fail(e) { |
|
41 ok(false, "addSuccess was called"); |
|
42 dump(request); |
|
43 devicestorage_cleanup(); |
|
44 } |
|
45 |
|
46 function next(e) { |
|
47 |
|
48 if (e != undefined) { |
|
49 ok(true, "addError was called"); |
|
50 ok(e.target.error.name == "SecurityError", "Error must be SecurityError"); |
|
51 } |
|
52 |
|
53 var f = tests.pop(); |
|
54 |
|
55 if (f == undefined) { |
|
56 devicestorage_cleanup(); |
|
57 return; |
|
58 } |
|
59 |
|
60 request = f(); |
|
61 request.onsuccess = fail; |
|
62 request.onerror = next; |
|
63 } |
|
64 |
|
65 next(); |
|
66 |
|
67 |
|
68 |
|
69 </script> |
|
70 </pre> |
|
71 </body> |
|
72 </html> |
|
73 |