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

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

Issue 9284013: Extension Storage API: expose storage quota information to extensions, via: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with use-after-free fixed Created 8 years, 11 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/renderer/resources/extensions/storage_custom_bindings.js ('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 85f5e628128985966e8f47fbcd53035ee9a0eee7..72632860717dcc1355894c408b149977041f68d5 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
@@ -291,12 +291,55 @@ chrome.test.runTests([
test(stage0);
},
+
+ function quota() {
+ // Just check that the constants are defined; no need to be forced to
+ // update them here as well if/when they change.
+ chrome.test.assertTrue(chrome.storage.sync.QUOTA_BYTES > 0);
+ chrome.test.assertTrue(chrome.storage.sync.QUOTA_BYTES_PER_ITEM > 0);
+ chrome.test.assertTrue(chrome.storage.sync.MAX_ITEMS > 0);
+
+ chrome.test.assertTrue(chrome.storage.local.QUOTA_BYTES > 0);
+ chrome.test.assertEq('undefined',
+ typeof chrome.storage.local.QUOTA_BYTES_PER_ITEM);
+ chrome.test.assertEq('undefined',
+ typeof chrome.storage.local.MAX_ITEMS);
+
+ var area = chrome.storage.sync;
+ function stage0() {
+ area.getBytesInUse(null, stage1);
+ }
+ function stage1(bytesInUse) {
+ chrome.test.assertEq(0, bytesInUse);
+ area.set({ a: 42, b: 43, c: 44 }, stage2);
+ }
+ function stage2() {
+ area.getBytesInUse(null, stage3);
+ }
+ function stage3(bytesInUse) {
+ chrome.test.assertEq(9, bytesInUse);
+ area.getBytesInUse('a', stage4);
+ }
+ function stage4(bytesInUse) {
+ chrome.test.assertEq(3, bytesInUse);
+ area.getBytesInUse(['a', 'b'], stage5);
+ }
+ function stage5(bytesInUse) {
+ chrome.test.assertEq(6, bytesInUse);
+ chrome.test.succeed();
+ }
+ area.clear(stage0);
+ },
+
+ // 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;
- // Should get throttled after 1000 calls.
+ // Should get throttled after 1000 calls (though in reality will be fewer
+ // due to previous tests).
var maxRequests = 1001;
function next() {
@@ -310,4 +353,5 @@ chrome.test.runTests([
}
api.clear(next);
}
+
]);
« no previous file with comments | « chrome/renderer/resources/extensions/storage_custom_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698