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

Unified Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2206673003: Change V8CacheOnCacheStorage tests to wait for the V8 code cache to be written. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_browsertest.cc
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
index 912a61cac113d3ad89f5ec49ab9b7ceabe3e6d40..e7c1c2cc65907945b7b0b45a23857dbff2e0c49b 100644
--- a/content/browser/service_worker/service_worker_browsertest.cc
+++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -1781,13 +1781,13 @@ class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest {
RegisterAndActivateServiceWorker();
NavigateToTestPage();
- EXPECT_EQ(0, GetSideDataSize());
+ WaitUntilSideDataSizeIs(0);
NavigateToTestPage();
- EXPECT_EQ(0, GetSideDataSize());
+ WaitUntilSideDataSizeIs(0);
NavigateToTestPage();
- EXPECT_EQ(0, GetSideDataSize());
+ WaitUntilSideDataSizeIs(0);
}
void CheckStrategyIsNormal() {
@@ -1796,17 +1796,17 @@ class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest {
NavigateToTestPage();
// fetch_event_response_via_cache.js returns |cloned_response| for the first
// load. So the V8 code cache should not be stored to the CacheStorage.
- EXPECT_EQ(0, GetSideDataSize());
+ WaitUntilSideDataSizeIs(0);
NavigateToTestPage();
// V8ScriptRunner::setCacheTimeStamp() stores 12 byte data (tag +
// timestamp).
- EXPECT_EQ(kV8CacheTimeStampDataSize, GetSideDataSize());
+ WaitUntilSideDataSizeIs(kV8CacheTimeStampDataSize);
NavigateToTestPage();
// The V8 code cache must be stored to the CacheStorage which must be bigger
// than 12 byte.
- EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize);
+ WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
}
void CheckStrategyIsAggressive() {
@@ -1815,15 +1815,15 @@ class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest {
NavigateToTestPage();
// fetch_event_response_via_cache.js returns |cloned_response| for the first
// load. So the V8 code cache should not be stored to the CacheStorage.
- EXPECT_EQ(0, GetSideDataSize());
+ WaitUntilSideDataSizeIs(0);
NavigateToTestPage();
// The V8 code cache must be stored to the CacheStorage which must be bigger
// than 12 byte.
- EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize);
+ WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
NavigateToTestPage();
- EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize);
+ WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
}
private:
@@ -1861,6 +1861,20 @@ class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest {
std::string("cache_name"), embedded_test_server()->GetURL(kScriptUrl));
}
+ void WaitUntilSideDataSizeIs(int expected_size) {
+ while (true) {
shimazu 2016/08/03 06:06:54 I feel better to have timeout not to get stuck in
horo 2016/08/03 10:33:26 The testing framework has its own timeout logic (b
shimazu 2016/08/08 02:30:44 I see, thanks!
+ if (GetSideDataSize() == expected_size)
+ return;
+ }
+ }
+
+ void WaitUntilSideDataSizeIsBiggerThan(int minimum_size) {
+ while (true) {
+ if (GetSideDataSize() > minimum_size)
+ return;
+ }
+ }
+
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerV8CacheStrategiesTest);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698