OLD | NEW |
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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 | 1331 |
1332 private: | 1332 private: |
1333 bool data_saver_enabled_; | 1333 bool data_saver_enabled_; |
1334 }; | 1334 }; |
1335 | 1335 |
1336 class ServiceWorkerVersionOffMainThreadFetchTest | 1336 class ServiceWorkerVersionOffMainThreadFetchTest |
1337 : public ServiceWorkerVersionBrowserTest { | 1337 : public ServiceWorkerVersionBrowserTest { |
1338 public: | 1338 public: |
1339 ~ServiceWorkerVersionOffMainThreadFetchTest() override {} | 1339 ~ServiceWorkerVersionOffMainThreadFetchTest() override {} |
1340 void SetUpCommandLine(base::CommandLine* command_line) override { | 1340 void SetUpCommandLine(base::CommandLine* command_line) override { |
1341 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 1341 scoped_feature_list_.InitAndEnableFeature(features::kOffMainThreadFetch); |
1342 features::kOffMainThreadFetch.name); | |
1343 } | 1342 } |
| 1343 |
| 1344 private: |
| 1345 base::test::ScopedFeatureList scoped_feature_list_; |
1344 }; | 1346 }; |
1345 | 1347 |
1346 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchWithSaveData) { | 1348 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchWithSaveData) { |
1347 embedded_test_server()->RegisterRequestHandler( | 1349 embedded_test_server()->RegisterRequestHandler( |
1348 base::Bind(&VerifySaveDataHeaderInRequest)); | 1350 base::Bind(&VerifySaveDataHeaderInRequest)); |
1349 StartServerAndNavigateToSetup(); | 1351 StartServerAndNavigateToSetup(); |
1350 MockContentBrowserClient content_browser_client; | 1352 MockContentBrowserClient content_browser_client; |
1351 content_browser_client.set_data_saver_enabled(true); | 1353 content_browser_client.set_data_saver_enabled(true); |
1352 ContentBrowserClient* old_client = | 1354 ContentBrowserClient* old_client = |
1353 SetBrowserClientForTesting(&content_browser_client); | 1355 SetBrowserClientForTesting(&content_browser_client); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 using self = ServiceWorkerNavigationPreloadTest; | 1547 using self = ServiceWorkerNavigationPreloadTest; |
1546 | 1548 |
1547 ~ServiceWorkerNavigationPreloadTest() override {} | 1549 ~ServiceWorkerNavigationPreloadTest() override {} |
1548 | 1550 |
1549 void SetUpOnMainThread() override { | 1551 void SetUpOnMainThread() override { |
1550 host_resolver()->AddRule("*", "127.0.0.1"); | 1552 host_resolver()->AddRule("*", "127.0.0.1"); |
1551 ServiceWorkerBrowserTest::SetUpOnMainThread(); | 1553 ServiceWorkerBrowserTest::SetUpOnMainThread(); |
1552 } | 1554 } |
1553 | 1555 |
1554 void SetUpCommandLine(base::CommandLine* command_line) override { | 1556 void SetUpCommandLine(base::CommandLine* command_line) override { |
1555 command_line->AppendSwitchASCII( | 1557 scoped_feature_list_.InitAndEnableFeature( |
1556 switches::kEnableFeatures, | 1558 features::kServiceWorkerNavigationPreload); |
1557 features::kServiceWorkerNavigationPreload.name); | |
1558 } | 1559 } |
1559 | 1560 |
1560 protected: | 1561 protected: |
1561 static const std::string kNavigationPreloadHeaderName; | 1562 static const std::string kNavigationPreloadHeaderName; |
1562 static const std::string kEnableNavigationPreloadScript; | 1563 static const std::string kEnableNavigationPreloadScript; |
1563 static const std::string kPreloadResponseTestScript; | 1564 static const std::string kPreloadResponseTestScript; |
1564 | 1565 |
1565 static bool HasNavigationPreloadHeader( | 1566 static bool HasNavigationPreloadHeader( |
1566 const net::test_server::HttpRequest& request) { | 1567 const net::test_server::HttpRequest& request) { |
1567 return request.headers.find(kNavigationPreloadHeaderName) != | 1568 return request.headers.find(kNavigationPreloadHeaderName) != |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 base::ASCIIToUTF16("document.body.textContent;"), | 1656 base::ASCIIToUTF16("document.body.textContent;"), |
1656 base::Bind(&StoreString, &text_content, run_loop.QuitClosure())); | 1657 base::Bind(&StoreString, &text_content, run_loop.QuitClosure())); |
1657 run_loop.Run(); | 1658 run_loop.Run(); |
1658 return text_content; | 1659 return text_content; |
1659 } | 1660 } |
1660 | 1661 |
1661 std::map<std::string, std::vector<net::test_server::HttpRequest>> | 1662 std::map<std::string, std::vector<net::test_server::HttpRequest>> |
1662 request_log_; | 1663 request_log_; |
1663 | 1664 |
1664 private: | 1665 private: |
| 1666 base::test::ScopedFeatureList scoped_feature_list_; |
1665 class CustomResponse : public net::test_server::HttpResponse { | 1667 class CustomResponse : public net::test_server::HttpResponse { |
1666 public: | 1668 public: |
1667 CustomResponse(const std::string& response) : response_(response) {} | 1669 CustomResponse(const std::string& response) : response_(response) {} |
1668 ~CustomResponse() override {} | 1670 ~CustomResponse() override {} |
1669 | 1671 |
1670 void SendResponse( | 1672 void SendResponse( |
1671 const net::test_server::SendBytesCallback& send, | 1673 const net::test_server::SendBytesCallback& send, |
1672 const net::test_server::SendCompleteCallback& done) override { | 1674 const net::test_server::SendCompleteCallback& done) override { |
1673 send.Run(response_, done); | 1675 send.Run(response_, done); |
1674 } | 1676 } |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 // effect in CanSuspendRenderer(). | 3032 // effect in CanSuspendRenderer(). |
3031 shell()->web_contents()->WasHidden(); | 3033 shell()->web_contents()->WasHidden(); |
3032 EXPECT_TRUE(rph->IsProcessBackgrounded()); | 3034 EXPECT_TRUE(rph->IsProcessBackgrounded()); |
3033 | 3035 |
3034 // The process which has service worker thread shouldn't be suspended. | 3036 // The process which has service worker thread shouldn't be suspended. |
3035 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); | 3037 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); |
3036 } | 3038 } |
3037 #endif | 3039 #endif |
3038 | 3040 |
3039 } // namespace content | 3041 } // namespace content |
OLD | NEW |