OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 if (!chrome || !chrome.test) | 5 if (!chrome || !chrome.test) |
6 throw new Error('chrome.test is undefined'); | 6 throw new Error('chrome.test is undefined'); |
7 | 7 |
8 var portNumber; | 8 var portNumber; |
9 | 9 |
10 // This is a good end-to-end test for two reasons. The first is obvious - it | 10 // This is a good end-to-end test for two reasons. The first is obvious - it |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 }); | 117 }); |
118 }); | 118 }); |
119 }); | 119 }); |
120 }, | 120 }, |
121 function testLastError() { | 121 function testLastError() { |
122 chrome.runtime.setUninstallURL('chrome://newtab', function() { | 122 chrome.runtime.setUninstallURL('chrome://newtab', function() { |
123 chrome.test.assertLastError('Invalid URL: "chrome://newtab".'); | 123 chrome.test.assertLastError('Invalid URL: "chrome://newtab".'); |
124 chrome.test.succeed(); | 124 chrome.test.succeed(); |
125 }); | 125 }); |
126 }, | 126 }, |
| 127 function testStorage() { |
| 128 // Check API existence; StorageArea functions. |
| 129 chrome.test.assertTrue(!!chrome.storage); |
| 130 chrome.test.assertTrue(!!chrome.storage.local, 'no local'); |
| 131 chrome.test.assertTrue(!!chrome.storage.local.set, 'no set'); |
| 132 chrome.test.assertTrue(!!chrome.storage.local.get, 'no get'); |
| 133 // Check some properties. |
| 134 chrome.test.assertTrue(!!chrome.storage.local.QUOTA_BYTES, |
| 135 'local quota bytes'); |
| 136 chrome.test.assertFalse(!!chrome.storage.local.MAX_ITEMS, |
| 137 'local max items'); |
| 138 chrome.test.assertTrue(!!chrome.storage.sync, 'sync'); |
| 139 chrome.test.assertTrue(!!chrome.storage.sync.QUOTA_BYTES, |
| 140 'sync quota bytes'); |
| 141 chrome.test.assertTrue(!!chrome.storage.sync.MAX_ITEMS, |
| 142 'sync max items'); |
| 143 chrome.test.assertTrue(!!chrome.storage.managed, 'managed'); |
| 144 chrome.test.assertFalse(!!chrome.storage.managed.QUOTA_BYTES, |
| 145 'managed quota bytes'); |
| 146 chrome.storage.local.set({foo: 'bar'}, () => { |
| 147 chrome.storage.local.get('foo', (results) => { |
| 148 chrome.test.assertTrue(!!results, 'no results'); |
| 149 chrome.test.assertTrue(!!results.foo, 'no foo'); |
| 150 chrome.test.assertEq('bar', results.foo); |
| 151 chrome.test.succeed(); |
| 152 }); |
| 153 }); |
| 154 }, |
127 ]; | 155 ]; |
128 | 156 |
129 chrome.test.getConfig(config => { | 157 chrome.test.getConfig(config => { |
130 chrome.test.assertTrue(!!config, 'config does not exist'); | 158 chrome.test.assertTrue(!!config, 'config does not exist'); |
131 chrome.test.assertTrue(!!config.testServer, 'testServer does not exist'); | 159 chrome.test.assertTrue(!!config.testServer, 'testServer does not exist'); |
132 portNumber = config.testServer.port; | 160 portNumber = config.testServer.port; |
133 chrome.test.runTests(tests); | 161 chrome.test.runTests(tests); |
134 }); | 162 }); |
OLD | NEW |