Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / devicestorage / test / test_dirs.html
blob55650a9ee3584e74de99bada84f7d609f2e2bcb7
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=886627
9 -->
10 <head>
11 <title>Test for 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 <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=886627">
18 Mozilla Bug 886627
19 </a>
20 <p id="display"></p>
21 <div id="content" style="display: none"></div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
25 /**
26 * Test that common device storage directories are available.
28 * This test differs from other device storage tests in that other tests use a
29 * "testing mode", which relocates the device storage directories to a testing
30 * directory. On the other hand, this test turns off testing mode to makes sure
31 * that the normal, non-testing directories also work properly.
34 SimpleTest.waitForExplicitFinish();
36 SpecialPowers.pushPrefEnv({
37 'set': [
38 ["device.storage.enabled", true],
39 ["device.storage.testing", false],
40 ["device.storage.prompt.testing", true],
42 }, function() {
43 ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
44 ok(!navigator.getDeviceStorage("nonexistent-type"), "Should not have nonexistent storage");
46 ok(navigator.getDeviceStorage("pictures"), "Should have pictures storage");
47 ok(navigator.getDeviceStorage("videos"), "Should have videos storage");
48 ok(navigator.getDeviceStorage("music"), "Should have music storage");
50 // Need special permission to access "apps". We always have the permission in B2G
51 // mochitests, but on other platforms, we need to manually add the permission.
52 var needAppsPermission = false;;
53 if (!SpecialPowers.testPermission(
54 "webapps-manage", SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document)) {
55 ok(!navigator.getDeviceStorage("apps"), "Should not have apps storage without permission");
56 needAppsPermission = true;
59 var testFunction = function() {
60 ok(navigator.getDeviceStorage("apps"), "Should have apps storage with permission");
61 ok(navigator.getDeviceStorage("sdcard"), "Should have sdcard storage");
62 ok(navigator.getDeviceStorage("crashes"), "Should have crashes storage");
63 // The test harness reverts our pref changes automatically.
64 SimpleTest.finish();
67 if (needAppsPermission) {
68 SpecialPowers.pushPermissions(
69 [{ "type":"webapps-manage", "allow": true, "context": document }],
70 testFunction);
71 } else {
72 testFunction();
74 });
76 </script>
77 </pre>
78 </body>
79 </html>