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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/settings/settings_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 function test(stage0) { 5 function test(stage0) {
6 var apis = [ 6 var apis = [
7 chrome.storage.sync, 7 chrome.storage.sync,
8 chrome.storage.local 8 chrome.storage.local
9 ]; 9 ];
10 apis.forEach(function(api) { 10 apis.forEach(function(api) {
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 function stage5(bytesInUse) { 327 function stage5(bytesInUse) {
328 chrome.test.assertEq(6, bytesInUse); 328 chrome.test.assertEq(6, bytesInUse);
329 chrome.test.succeed(); 329 chrome.test.succeed();
330 } 330 }
331 area.clear(stage0); 331 area.clear(stage0);
332 }, 332 },
333 333
334 // NOTE: throttling test must come last, since each test runs with a single 334 // NOTE: throttling test must come last, since each test runs with a single
335 // quota. 335 // quota.
336 function throttling() { 336 function throttling() {
337 // We can only really test one of the namespaces since they will all get 337 // Test script is as so:
338 // throttled together. 338 // 1 - storage.local shouldn't be exceeded.
339 var api = chrome.storage.sync; 339 // 2 - storage.sync should be exceeded.
340 // 3 - storage.local still shouldn't be exceeded.
341 // 4 - storage.sync should still be exceeded.
342 //
343 // In general, things should get throttled after 1000 calls (though in
344 // reality will be fewer due to previous tests).
340 345
341 // Should get throttled after 1000 calls (though in reality will be fewer 346 function clearNTimes(area, n, whenDone) {
342 // due to previous tests). 347 if (n <= 0) {
343 var maxRequests = 1001; 348 whenDone();
349 } else {
350 area.clear(function() {
351 clearNTimes(area, n - 1, whenDone);
352 });
353 }
354 }
344 355
345 function next() { 356 var local = chrome.storage.local;
346 api.clear((--maxRequests > 0) ? next : done); 357 var sync = chrome.storage.sync;
347 } 358 var test = chrome.test;
348 function done() { 359 var quotaError = "This request exceeds available quota.";
349 chrome.test.assertEq( 360
350 "This request exceeds available quota.", 361 clearNTimes(local, 1001, test.callbackPass(function() {
351 chrome.extension.lastError.message); 362 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
352 chrome.test.succeed(); 363 clearNTimes(local, 1, test.callbackPass(function() {
353 } 364 clearNTimes(sync, 1, test.callbackFail(quotaError, test.succeed));
354 api.clear(next); 365 }));
366 }));
367 }));
355 } 368 }
356
357 ]); 369 ]);
OLDNEW
« 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