summaryrefslogtreecommitdiffstats
path: root/extensions/browser/quota_service_unittest.cc
diff options
context:
space:
mode:
authorkalman <kalman@chromium.org>2014-11-04 16:18:18 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-05 00:18:35 +0000
commit2610ea15b9d6f97ab6fd399d67b2e13fb79fce56 (patch)
tree0ec223cad0715f3396a491849262f7c592010fda /extensions/browser/quota_service_unittest.cc
parent4e7e6b35fd63a90f5f93227200249ebfa61dd5a1 (diff)
downloadchromium_src-2610ea15b9d6f97ab6fd399d67b2e13fb79fce56.zip
chromium_src-2610ea15b9d6f97ab6fd399d67b2e13fb79fce56.tar.gz
chromium_src-2610ea15b9d6f97ab6fd399d67b2e13fb79fce56.tar.bz2
Allow extension function call quota to be un-throttled.
For example, previously if chrome.storage.sync.set was called more than 1000 times in an hour it would be throttled forever (until Chrome restart). Now that quota is restored every hour. BUG=406406 R=zea@chromium.org Review URL: https://codereview.chromium.org/704453002 Cr-Commit-Position: refs/heads/master@{#302716}
Diffstat (limited to 'extensions/browser/quota_service_unittest.cc')
-rw-r--r--extensions/browser/quota_service_unittest.cc37
1 files changed, 25 insertions, 12 deletions
diff --git a/extensions/browser/quota_service_unittest.cc b/extensions/browser/quota_service_unittest.cc
index b33910a..193aa34 100644
--- a/extensions/browser/quota_service_unittest.cc
+++ b/extensions/browser/quota_service_unittest.cc
@@ -287,9 +287,8 @@ TEST_F(QuotaServiceTest, MultipleFunctionsDontInterfere) {
kStartTime + TimeDelta::FromSeconds(15)));
}
-TEST_F(QuotaServiceTest, ViolatorsWillBeViolators) {
+TEST_F(QuotaServiceTest, ViolatorsWillBeForgiven) {
scoped_refptr<MockFunction> f(new TimedLimitMockFunction("foo"));
- scoped_refptr<MockFunction> g(new TimedLimitMockFunction("bar"));
base::ListValue arg;
arg.Append(new base::FundamentalValue(1));
EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg, kStartTime));
@@ -304,16 +303,30 @@ TEST_F(QuotaServiceTest, ViolatorsWillBeViolators) {
&arg,
kStartTime + TimeDelta::FromSeconds(15)));
- // We don't allow this extension to use quota limited functions even if they
- // wait a while.
- EXPECT_NE(
- "",
- service_->Assess(
- extension_a_, f.get(), &arg, kStartTime + TimeDelta::FromDays(1)));
- EXPECT_NE(
- "",
- service_->Assess(
- extension_a_, g.get(), &arg, kStartTime + TimeDelta::FromDays(1)));
+ // Waiting a while will give the extension access to the function again.
+ EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(1)));
+
+ // And lose it again soon after.
+ EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(1) +
+ TimeDelta::FromSeconds(10)));
+ EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(1) +
+ TimeDelta::FromSeconds(15)));
+
+ // Going further over quota should continue to fail within this time period,
+ // but still all restored later.
+ EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(1) +
+ TimeDelta::FromSeconds(20)));
+ EXPECT_NE("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(1) +
+ TimeDelta::FromSeconds(25)));
+
+ // Like now.
+ EXPECT_EQ("", service_->Assess(extension_a_, f.get(), &arg,
+ kStartTime + TimeDelta::FromDays(2)));
}
} // namespace extensions