OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 function test(stage0) { | 5 function test(stage0) { |
6 var apis = [ | 6 var apis = [ |
7 chrome.experimental.storage.sync, | 7 chrome.storage.sync, |
8 chrome.experimental.storage.local | 8 chrome.storage.local |
9 ]; | 9 ]; |
10 apis.forEach(function(api) { | 10 apis.forEach(function(api) { |
11 api.succeed = chrome.test.callbackPass(api.clear.bind(api)); | 11 api.succeed = chrome.test.callbackPass(api.clear.bind(api)); |
12 stage0.call(api); | 12 stage0.call(api); |
13 }); | 13 }); |
14 } | 14 } |
15 | 15 |
16 chrome.test.runTests([ | 16 chrome.test.runTests([ |
17 function getWhenEmpty() { | 17 function getWhenEmpty() { |
18 function stage0() { | 18 function stage0() { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 'baz': {} | 287 'baz': {} |
288 }, settings); | 288 }, settings); |
289 this.succeed(); | 289 this.succeed(); |
290 } | 290 } |
291 test(stage0); | 291 test(stage0); |
292 }, | 292 }, |
293 | 293 |
294 function throttling() { | 294 function throttling() { |
295 // We can only really test one of the namespaces since they will all get | 295 // We can only really test one of the namespaces since they will all get |
296 // throttled together. | 296 // throttled together. |
297 var api = chrome.experimental.storage.sync; | 297 var api = chrome.storage.sync; |
298 | 298 |
299 // Should get throttled after 1000 calls. | 299 // Should get throttled after 1000 calls. |
300 var maxRequests = 1001; | 300 var maxRequests = 1001; |
301 | 301 |
302 function next() { | 302 function next() { |
303 api.clear((--maxRequests > 0) ? next : done); | 303 api.clear((--maxRequests > 0) ? next : done); |
304 } | 304 } |
305 function done() { | 305 function done() { |
306 chrome.test.assertEq( | 306 chrome.test.assertEq( |
307 "This request exceeds available quota.", | 307 "This request exceeds available quota.", |
308 chrome.extension.lastError.message); | 308 chrome.extension.lastError.message); |
309 chrome.test.succeed(); | 309 chrome.test.succeed(); |
310 } | 310 } |
311 api.clear(next); | 311 api.clear(next); |
312 } | 312 } |
313 ]); | 313 ]); |
OLD | NEW |