2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
8 https://bugzilla.mozilla.org/show_bug.cgi?id=886627
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" />
17 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=886627">
21 <div id=
"content" style=
"display: none"></div>
23 <script class=
"testbody" type=
"text/javascript">
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({
38 [
"device.storage.enabled", true],
39 [
"device.storage.testing", false],
40 [
"device.storage.prompt.testing", true],
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.
67 if (needAppsPermission) {
68 SpecialPowers.pushPermissions(
69 [{
"type":
"webapps-manage",
"allow": true,
"context": document }],