| OLD | NEW |
| 1 // Copyright (c) 2012 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 var assertEq = chrome.test.assertEq; | 5 var assertEq = chrome.test.assertEq; |
| 6 var assertTrue = chrome.test.assertTrue; | 6 var assertTrue = chrome.test.assertTrue; |
| 7 var succeed = chrome.test.succeed; | 7 var succeed = chrome.test.succeed; |
| 8 | 8 |
| 9 function test(stage0) { | 9 function test(stage0) { |
| 10 var apis = [ | 10 var apis = [ |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 355 } |
| 356 function stage2(values) { | 356 function stage2(values) { |
| 357 assertEq({ | 357 assertEq({ |
| 358 foo: 'foo', | 358 foo: 'foo', |
| 359 bar: null, | 359 bar: null, |
| 360 }, values); | 360 }, values); |
| 361 succeed(); | 361 succeed(); |
| 362 } | 362 } |
| 363 area.clear(stage0); | 363 area.clear(stage0); |
| 364 }, | 364 }, |
| 365 | |
| 366 // NOTE: throttling test must come last, since each test runs with a single | |
| 367 // quota. | |
| 368 function throttling() { | |
| 369 // Test script is as so: | |
| 370 // 1 - storage.local shouldn't be exceeded. | |
| 371 // 2 - storage.sync should be exceeded. | |
| 372 // 3 - storage.local still shouldn't be exceeded. | |
| 373 // 4 - storage.sync should still be exceeded. | |
| 374 // | |
| 375 // In general, things should get throttled after 1000 calls (though in | |
| 376 // reality will be fewer due to previous tests). | |
| 377 | |
| 378 function clearNTimes(area, n, whenDone) { | |
| 379 if (n <= 0) { | |
| 380 whenDone(); | |
| 381 } else { | |
| 382 area.clear(function() { | |
| 383 clearNTimes(area, n - 1, whenDone); | |
| 384 }); | |
| 385 } | |
| 386 } | |
| 387 | |
| 388 var local = chrome.storage.local; | |
| 389 var sync = chrome.storage.sync; | |
| 390 var test = chrome.test; | |
| 391 var quotaError = | |
| 392 "This request exceeds the MAX_WRITE_OPERATIONS_PER_HOUR quota."; | |
| 393 | |
| 394 clearNTimes(local, 1001, test.callbackPass(function() { | |
| 395 clearNTimes(sync, 1001, test.callbackFail(quotaError, function() { | |
| 396 clearNTimes(local, 1, test.callbackPass(function() { | |
| 397 clearNTimes(sync, 1, test.callbackFail(quotaError, test.succeed)); | |
| 398 })); | |
| 399 })); | |
| 400 })); | |
| 401 }, | |
| 402 ]); | 365 ]); |
| OLD | NEW |