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

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2482263004: Fix a possible flaky ServiceWorkerNavigationPreloadTest. (Closed)
Patch Set: Created 4 years, 1 month 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 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 RegisterStaticFile(kWorkerUrl, kScript, "text/javascript"); 1626 RegisterStaticFile(kWorkerUrl, kScript, "text/javascript");
1627 1627
1628 SetupForNavigationPreloadTest(page_url, worker_url); 1628 SetupForNavigationPreloadTest(page_url, worker_url);
1629 1629
1630 const base::string16 title = base::ASCIIToUTF16("PASS"); 1630 const base::string16 title = base::ASCIIToUTF16("PASS");
1631 TitleWatcher title_watcher(shell()->web_contents(), title); 1631 TitleWatcher title_watcher(shell()->web_contents(), title);
1632 NavigateToURL(shell(), page_url); 1632 NavigateToURL(shell(), page_url);
1633 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 1633 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
1634 EXPECT_EQ("Hello world.", GetTextContent()); 1634 EXPECT_EQ("Hello world.", GetTextContent());
1635 1635
1636 // The page request must be sent twice. Once for navigation preload, and once 1636 // The page request must be sent once or twice:
1637 // for fallback since respondWith wasn't used. 1637 // - A navigation preload reqeust may be sent. But it is possible that the
falken 2016/11/09 05:32:33 request
horo 2016/11/09 05:37:24 Done.
1638 ASSERT_EQ(2, GetRequestCount(kPageUrl)); 1638 // navigation preload request is canceled before reaching the server.
1639 ASSERT_TRUE(HasNavigationPreloadHeader(request_log_[kPageUrl][0])); 1639 // - A fallback request must be sent since respondWith wasn't used.
1640 EXPECT_EQ("true", GetNavigationPreloadHeader(request_log_[kPageUrl][0])); 1640 const int request_count = GetRequestCount(kPageUrl);
1641 EXPECT_FALSE(HasNavigationPreloadHeader(request_log_[kPageUrl][1])); 1641 ASSERT_TRUE(request_count == 1 || request_count == 2);
1642 if (request_count == 1) {
1643 // Fallback request.
1644 EXPECT_FALSE(HasNavigationPreloadHeader(request_log_[kPageUrl][0]));
1645 } else if (request_count == 2) {
1646 // Navigation preload request.
1647 ASSERT_TRUE(HasNavigationPreloadHeader(request_log_[kPageUrl][0]));
1648 EXPECT_EQ("true", GetNavigationPreloadHeader(request_log_[kPageUrl][0]));
1649 // Fallback request.
1650 EXPECT_FALSE(HasNavigationPreloadHeader(request_log_[kPageUrl][1]));
1651 }
1642 } 1652 }
1643 1653
1644 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest, SetHeaderValue) { 1654 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest, SetHeaderValue) {
1645 const std::string kPageUrl = "/service_worker/navigation_preload.html"; 1655 const std::string kPageUrl = "/service_worker/navigation_preload.html";
1646 const std::string kWorkerUrl = "/service_worker/navigation_preload.js"; 1656 const std::string kWorkerUrl = "/service_worker/navigation_preload.js";
1647 const std::string kPage = "<title>FROM_SERVER</title>"; 1657 const std::string kPage = "<title>FROM_SERVER</title>";
1648 const std::string kScript = 1658 const std::string kScript =
1649 "function createResponse(title, body) {\n" 1659 "function createResponse(title, body) {\n"
1650 " return new Response('<title>' + title + '</title>' + body,\n" 1660 " return new Response('<title>' + title + '</title>' + body,\n"
1651 " {headers: [['content-type', 'text/html']]})\n" 1661 " {headers: [['content-type', 'text/html']]})\n"
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 ServiceWorkerV8CacheStrategiesNormalTest, 2847 ServiceWorkerV8CacheStrategiesNormalTest,
2838 ::testing::Values(true, false)); 2848 ::testing::Values(true, false));
2839 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2849 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2840 ServiceWorkerV8CacheStrategiesAggressiveTest, 2850 ServiceWorkerV8CacheStrategiesAggressiveTest,
2841 ::testing::Values(true, false)); 2851 ::testing::Values(true, false));
2842 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2852 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2843 ServiceWorkerDisableWebSecurityTest, 2853 ServiceWorkerDisableWebSecurityTest,
2844 ::testing::Values(true, false)); 2854 ::testing::Values(true, false));
2845 2855
2846 } // namespace content 2856 } // 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