- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / settings / managed_storage / background.js
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 chrome.test.runTests([
6   function getPolicy() {
7     chrome.storage.managed.get(
8         'string-policy',
9         chrome.test.callbackPass(function(results) {
10           chrome.test.assertEq({
11             'string-policy': 'value'
12           }, results);
13         }));
14   },
15
16   function getListOfPolicies() {
17     chrome.storage.managed.get(
18         ['string-policy', 'int-policy', 'no-such-thing'],
19         chrome.test.callbackPass(function(results) {
20           chrome.test.assertEq({
21             'string-policy': 'value',
22             'int-policy': -123,
23           }, results);
24         }));
25   },
26
27   function getAllPolicies() {
28     chrome.storage.managed.get(
29         chrome.test.callbackPass(function(results) {
30           chrome.test.assertEq({
31             'string-policy': 'value',
32             'int-policy': -123,
33             'double-policy': 456e7,
34             'boolean-policy': true,
35             'list-policy': [ 'one', 'two', 'three' ],
36             'dict-policy': {
37               'list': [ { 'one': 1, 'two': 2 }, { 'three': 3} ]
38             }
39           }, results);
40         }));
41   },
42
43   function getBytesInUse() {
44     chrome.storage.managed.getBytesInUse(
45         chrome.test.callbackPass(function(bytes) {
46           chrome.test.assertEq(0, bytes);
47         }));
48   },
49
50   function writingFails() {
51     var kReadOnlyError = 'This is a read-only store.';
52     chrome.storage.managed.clear(chrome.test.callbackFail(kReadOnlyError));
53     chrome.storage.managed.remove(
54         'string-policy',
55         chrome.test.callbackFail(kReadOnlyError));
56     chrome.storage.managed.set({
57       'key': 'value'
58     }, chrome.test.callbackFail(kReadOnlyError));
59   }
60 ]);