Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8836)

Unified Diff: chrome/test/data/extensions/api_test/settings/simple_test/background.js

Issue 10232004: Only apply extension throttling quota to sync, not local. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/settings/settings_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/settings/simple_test/background.js
diff --git a/chrome/test/data/extensions/api_test/settings/simple_test/background.js b/chrome/test/data/extensions/api_test/settings/simple_test/background.js
index 72632860717dcc1355894c408b149977041f68d5..848419576aa733b55804a9a873e3ac064725c823 100644
--- a/chrome/test/data/extensions/api_test/settings/simple_test/background.js
+++ b/chrome/test/data/extensions/api_test/settings/simple_test/background.js
@@ -334,24 +334,36 @@ chrome.test.runTests([
// NOTE: throttling test must come last, since each test runs with a single
// quota.
function throttling() {
- // We can only really test one of the namespaces since they will all get
- // throttled together.
- var api = chrome.storage.sync;
+ // Test script is as so:
+ // 1 - storage.local shouldn't be exceeded.
+ // 2 - storage.sync should be exceeded.
+ // 3 - storage.local still shouldn't be exceeded.
+ // 4 - storage.sync should still be exceeded.
+ //
+ // In general, things should get throttled after 1000 calls (though in
+ // reality will be fewer due to previous tests).
- // Should get throttled after 1000 calls (though in reality will be fewer
- // due to previous tests).
- var maxRequests = 1001;
-
- function next() {
- api.clear((--maxRequests > 0) ? next : done);
- }
- function done() {
- chrome.test.assertEq(
- "This request exceeds available quota.",
- chrome.extension.lastError.message);
- chrome.test.succeed();
+ function clearNTimes(area, n, whenDone) {
+ if (n <= 0) {
+ whenDone();
+ } else {
+ area.clear(function() {
+ clearNTimes(area, n - 1, whenDone);
+ });
+ }
}
- api.clear(next);
- }
+ var local = chrome.storage.local;
+ var sync = chrome.storage.sync;
+ var test = chrome.test;
+ var quotaError = "This request exceeds available quota.";
+
+ clearNTimes(local, 1001, test.callbackPass(function() {
+ clearNTimes(sync, 1001, test.callbackFail(quotaError, function() {
Matt Perry 2012/04/27 18:48:03 could you do sync and local in parallel?
not at google - send to devlin 2012/04/29 23:58:03 hm, not sure, I definitely wanted to test those 4
+ clearNTimes(local, 1, test.callbackPass(function() {
+ clearNTimes(sync, 1, test.callbackFail(quotaError, test.succeed));
+ }));
+ }));
+ }));
+ }
]);
« no previous file with comments | « chrome/browser/extensions/settings/settings_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698