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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest { 1774 class ServiceWorkerV8CacheStrategiesTest : public ServiceWorkerBrowserTest {
1775 public: 1775 public:
1776 ServiceWorkerV8CacheStrategiesTest() {} 1776 ServiceWorkerV8CacheStrategiesTest() {}
1777 ~ServiceWorkerV8CacheStrategiesTest() override {} 1777 ~ServiceWorkerV8CacheStrategiesTest() override {}
1778 1778
1779 protected: 1779 protected:
1780 void CheckStrategyIsNone() { 1780 void CheckStrategyIsNone() {
1781 RegisterAndActivateServiceWorker(); 1781 RegisterAndActivateServiceWorker();
1782 1782
1783 NavigateToTestPage(); 1783 NavigateToTestPage();
1784 EXPECT_EQ(0, GetSideDataSize()); 1784 WaitUntilSideDataSizeIs(0);
1785 1785
1786 NavigateToTestPage(); 1786 NavigateToTestPage();
1787 EXPECT_EQ(0, GetSideDataSize()); 1787 WaitUntilSideDataSizeIs(0);
1788 1788
1789 NavigateToTestPage(); 1789 NavigateToTestPage();
1790 EXPECT_EQ(0, GetSideDataSize()); 1790 WaitUntilSideDataSizeIs(0);
1791 } 1791 }
1792 1792
1793 void CheckStrategyIsNormal() { 1793 void CheckStrategyIsNormal() {
1794 RegisterAndActivateServiceWorker(); 1794 RegisterAndActivateServiceWorker();
1795 1795
1796 NavigateToTestPage(); 1796 NavigateToTestPage();
1797 // fetch_event_response_via_cache.js returns |cloned_response| for the first 1797 // fetch_event_response_via_cache.js returns |cloned_response| for the first
1798 // load. So the V8 code cache should not be stored to the CacheStorage. 1798 // load. So the V8 code cache should not be stored to the CacheStorage.
1799 EXPECT_EQ(0, GetSideDataSize()); 1799 WaitUntilSideDataSizeIs(0);
1800 1800
1801 NavigateToTestPage(); 1801 NavigateToTestPage();
1802 // V8ScriptRunner::setCacheTimeStamp() stores 12 byte data (tag + 1802 // V8ScriptRunner::setCacheTimeStamp() stores 12 byte data (tag +
1803 // timestamp). 1803 // timestamp).
1804 EXPECT_EQ(kV8CacheTimeStampDataSize, GetSideDataSize()); 1804 WaitUntilSideDataSizeIs(kV8CacheTimeStampDataSize);
1805 1805
1806 NavigateToTestPage(); 1806 NavigateToTestPage();
1807 // The V8 code cache must be stored to the CacheStorage which must be bigger 1807 // The V8 code cache must be stored to the CacheStorage which must be bigger
1808 // than 12 byte. 1808 // than 12 byte.
1809 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); 1809 WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
1810 } 1810 }
1811 1811
1812 void CheckStrategyIsAggressive() { 1812 void CheckStrategyIsAggressive() {
1813 RegisterAndActivateServiceWorker(); 1813 RegisterAndActivateServiceWorker();
1814 1814
1815 NavigateToTestPage(); 1815 NavigateToTestPage();
1816 // fetch_event_response_via_cache.js returns |cloned_response| for the first 1816 // fetch_event_response_via_cache.js returns |cloned_response| for the first
1817 // load. So the V8 code cache should not be stored to the CacheStorage. 1817 // load. So the V8 code cache should not be stored to the CacheStorage.
1818 EXPECT_EQ(0, GetSideDataSize()); 1818 WaitUntilSideDataSizeIs(0);
1819 1819
1820 NavigateToTestPage(); 1820 NavigateToTestPage();
1821 // The V8 code cache must be stored to the CacheStorage which must be bigger 1821 // The V8 code cache must be stored to the CacheStorage which must be bigger
1822 // than 12 byte. 1822 // than 12 byte.
1823 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); 1823 WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
1824 1824
1825 NavigateToTestPage(); 1825 NavigateToTestPage();
1826 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); 1826 WaitUntilSideDataSizeIsBiggerThan(kV8CacheTimeStampDataSize);
1827 } 1827 }
1828 1828
1829 private: 1829 private:
1830 static const std::string kPageUrl; 1830 static const std::string kPageUrl;
1831 static const std::string kWorkerUrl; 1831 static const std::string kWorkerUrl;
1832 static const std::string kScriptUrl; 1832 static const std::string kScriptUrl;
1833 static const int kV8CacheTimeStampDataSize; 1833 static const int kV8CacheTimeStampDataSize;
1834 1834
1835 void RegisterAndActivateServiceWorker() { 1835 void RegisterAndActivateServiceWorker() {
1836 scoped_refptr<WorkerActivatedObserver> observer = 1836 scoped_refptr<WorkerActivatedObserver> observer =
(...skipping 17 matching lines...) Expand all
1854 int GetSideDataSize() { 1854 int GetSideDataSize() {
1855 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( 1855 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition(
1856 shell()->web_contents()->GetBrowserContext()); 1856 shell()->web_contents()->GetBrowserContext());
1857 return CacheStorageSideDataSizeChecker::GetSize( 1857 return CacheStorageSideDataSizeChecker::GetSize(
1858 static_cast<CacheStorageContextImpl*>( 1858 static_cast<CacheStorageContextImpl*>(
1859 partition->GetCacheStorageContext()), 1859 partition->GetCacheStorageContext()),
1860 partition->GetFileSystemContext(), embedded_test_server()->base_url(), 1860 partition->GetFileSystemContext(), embedded_test_server()->base_url(),
1861 std::string("cache_name"), embedded_test_server()->GetURL(kScriptUrl)); 1861 std::string("cache_name"), embedded_test_server()->GetURL(kScriptUrl));
1862 } 1862 }
1863 1863
1864 void WaitUntilSideDataSizeIs(int expected_size) {
1865 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!
1866 if (GetSideDataSize() == expected_size)
1867 return;
1868 }
1869 }
1870
1871 void WaitUntilSideDataSizeIsBiggerThan(int minimum_size) {
1872 while (true) {
1873 if (GetSideDataSize() > minimum_size)
1874 return;
1875 }
1876 }
1877
1864 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerV8CacheStrategiesTest); 1878 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerV8CacheStrategiesTest);
1865 }; 1879 };
1866 1880
1867 const std::string ServiceWorkerV8CacheStrategiesTest::kPageUrl = 1881 const std::string ServiceWorkerV8CacheStrategiesTest::kPageUrl =
1868 "/service_worker/v8_cache_test.html"; 1882 "/service_worker/v8_cache_test.html";
1869 const std::string ServiceWorkerV8CacheStrategiesTest::kWorkerUrl = 1883 const std::string ServiceWorkerV8CacheStrategiesTest::kWorkerUrl =
1870 "/service_worker/fetch_event_response_via_cache.js"; 1884 "/service_worker/fetch_event_response_via_cache.js";
1871 const std::string ServiceWorkerV8CacheStrategiesTest::kScriptUrl = 1885 const std::string ServiceWorkerV8CacheStrategiesTest::kScriptUrl =
1872 "/service_worker/v8_cache_test.js"; 1886 "/service_worker/v8_cache_test.js";
1873 // V8ScriptRunner::setCacheTimeStamp() stores 12 byte data (tag + timestamp). 1887 // V8ScriptRunner::setCacheTimeStamp() stores 12 byte data (tag + timestamp).
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 2022
2009 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) { 2023 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) {
2010 const char kPageUrl[] = "/service_worker/disable_web_security_update.html"; 2024 const char kPageUrl[] = "/service_worker/disable_web_security_update.html";
2011 const char kScopeUrl[] = "/service_worker/scope/"; 2025 const char kScopeUrl[] = "/service_worker/scope/";
2012 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; 2026 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
2013 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl); 2027 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl);
2014 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); 2028 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
2015 } 2029 }
2016 2030
2017 } // namespace content 2031 } // namespace content
OLDNEW
« 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