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

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

Issue 2478783002: Resolve FetchEvent.preloadResponse with undefined when Navigation Preload is disabled. (Closed)
Patch Set: ScriptPromiseProperty::resolveWithUndefined() Created 3 years, 11 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
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 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 StartServerAndNavigateToSetup(); 1757 StartServerAndNavigateToSetup();
1758 SetupForNavigationPreloadTest(page_url, worker_url); 1758 SetupForNavigationPreloadTest(page_url, worker_url);
1759 1759
1760 const std::string kPageUrl1 = kPageUrl + "?enable"; 1760 const std::string kPageUrl1 = kPageUrl + "?enable";
1761 const base::string16 title1 = base::ASCIIToUTF16("ENABLED"); 1761 const base::string16 title1 = base::ASCIIToUTF16("ENABLED");
1762 TitleWatcher title_watcher1(shell()->web_contents(), title1); 1762 TitleWatcher title_watcher1(shell()->web_contents(), title1);
1763 title_watcher1.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER")); 1763 title_watcher1.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER"));
1764 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl1)); 1764 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl1));
1765 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); 1765 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle());
1766 // When the navigation started, the navigation preload was not enabled yet. 1766 // When the navigation started, the navigation preload was not enabled yet.
1767 EXPECT_EQ("null", GetTextContent()); 1767 EXPECT_EQ("undefined", GetTextContent());
1768 ASSERT_EQ(0, GetRequestCount(kPageUrl1)); 1768 ASSERT_EQ(0, GetRequestCount(kPageUrl1));
1769 1769
1770 const std::string kPageUrl2 = kPageUrl + "?change"; 1770 const std::string kPageUrl2 = kPageUrl + "?change";
1771 const base::string16 title2 = base::ASCIIToUTF16("CHANGED"); 1771 const base::string16 title2 = base::ASCIIToUTF16("CHANGED");
1772 TitleWatcher title_watcher2(shell()->web_contents(), title2); 1772 TitleWatcher title_watcher2(shell()->web_contents(), title2);
1773 title_watcher2.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER")); 1773 title_watcher2.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER"));
1774 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl2)); 1774 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl2));
1775 EXPECT_EQ(title2, title_watcher2.WaitAndGetTitle()); 1775 EXPECT_EQ(title2, title_watcher2.WaitAndGetTitle());
1776 // When the navigation started, the navigation preload was enabled, but the 1776 // When the navigation started, the navigation preload was enabled, but the
1777 // header was not changed yet. 1777 // header was not changed yet.
(...skipping 14 matching lines...) Expand all
1792 ASSERT_TRUE(HasNavigationPreloadHeader(request_log_[kPageUrl3][0])); 1792 ASSERT_TRUE(HasNavigationPreloadHeader(request_log_[kPageUrl3][0]));
1793 EXPECT_EQ("Hello", GetNavigationPreloadHeader(request_log_[kPageUrl3][0])); 1793 EXPECT_EQ("Hello", GetNavigationPreloadHeader(request_log_[kPageUrl3][0]));
1794 1794
1795 const std::string kPageUrl4 = kPageUrl + "?test"; 1795 const std::string kPageUrl4 = kPageUrl + "?test";
1796 const base::string16 title4 = base::ASCIIToUTF16("TEST"); 1796 const base::string16 title4 = base::ASCIIToUTF16("TEST");
1797 TitleWatcher title_watcher4(shell()->web_contents(), title4); 1797 TitleWatcher title_watcher4(shell()->web_contents(), title4);
1798 title_watcher4.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER")); 1798 title_watcher4.AlsoWaitForTitle(base::ASCIIToUTF16("FROM_SERVER"));
1799 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl4)); 1799 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl4));
1800 EXPECT_EQ(title4, title_watcher4.WaitAndGetTitle()); 1800 EXPECT_EQ(title4, title_watcher4.WaitAndGetTitle());
1801 // When the navigation started, the navigation preload must be disabled. 1801 // When the navigation started, the navigation preload must be disabled.
1802 EXPECT_EQ("null", GetTextContent()); 1802 EXPECT_EQ("undefined", GetTextContent());
1803 ASSERT_EQ(0, GetRequestCount(kPageUrl4)); 1803 ASSERT_EQ(0, GetRequestCount(kPageUrl4));
1804 } 1804 }
1805 1805
1806 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest, 1806 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest,
1807 RespondWithNavigationPreload) { 1807 RespondWithNavigationPreload) {
1808 const char kPageUrl[] = "/service_worker/navigation_preload.html"; 1808 const char kPageUrl[] = "/service_worker/navigation_preload.html";
1809 const char kWorkerUrl[] = "/service_worker/navigation_preload.js"; 1809 const char kWorkerUrl[] = "/service_worker/navigation_preload.js";
1810 const char kPage[] = "<title>PASS</title>Hello world."; 1810 const char kPage[] = "<title>PASS</title>Hello world.";
1811 const std::string kScript = 1811 const std::string kScript =
1812 kEnableNavigationPreloadScript + 1812 kEnableNavigationPreloadScript +
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 const base::string16 title = base::ASCIIToUTF16("RESOLVED"); 2044 const base::string16 title = base::ASCIIToUTF16("RESOLVED");
2045 TitleWatcher title_watcher(shell()->web_contents(), title); 2045 TitleWatcher title_watcher(shell()->web_contents(), title);
2046 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("REJECTED")); 2046 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("REJECTED"));
2047 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("ERROR")); 2047 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("ERROR"));
2048 NavigateToURL(shell(), page_url); 2048 NavigateToURL(shell(), page_url);
2049 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 2049 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
2050 2050
2051 // The page request must not be sent, since the worker responded with a 2051 // The page request must not be sent, since the worker responded with a
2052 // generated Response and the navigation preload isn't enabled. 2052 // generated Response and the navigation preload isn't enabled.
2053 EXPECT_EQ(0, GetRequestCount(kPageUrl)); 2053 EXPECT_EQ(0, GetRequestCount(kPageUrl));
2054 EXPECT_EQ("Resolved with null.", GetTextContent()); 2054 EXPECT_EQ("Resolved with undefined.", GetTextContent());
2055 } 2055 }
2056 2056
2057 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest, 2057 IN_PROC_BROWSER_TEST_P(ServiceWorkerNavigationPreloadTest,
2058 PreloadHeadersCustom) { 2058 PreloadHeadersCustom) {
2059 const char kPageUrl[] = "/service_worker/navigation_preload.html"; 2059 const char kPageUrl[] = "/service_worker/navigation_preload.html";
2060 const char kWorkerUrl[] = "/service_worker/navigation_preload.js"; 2060 const char kWorkerUrl[] = "/service_worker/navigation_preload.js";
2061 const char kPageResponse[] = 2061 const char kPageResponse[] =
2062 "HTTP/1.1 201 HELLOWORLD\r\n" 2062 "HTTP/1.1 201 HELLOWORLD\r\n"
2063 "Connection: close\r\n" 2063 "Connection: close\r\n"
2064 "Content-Length: 32\r\n" 2064 "Content-Length: 32\r\n"
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 ServiceWorkerV8CacheStrategiesNormalTest, 3044 ServiceWorkerV8CacheStrategiesNormalTest,
3045 ::testing::Values(true, false)); 3045 ::testing::Values(true, false));
3046 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 3046 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
3047 ServiceWorkerV8CacheStrategiesAggressiveTest, 3047 ServiceWorkerV8CacheStrategiesAggressiveTest,
3048 ::testing::Values(true, false)); 3048 ::testing::Values(true, false));
3049 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 3049 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
3050 ServiceWorkerDisableWebSecurityTest, 3050 ServiceWorkerDisableWebSecurityTest,
3051 ::testing::Values(true, false)); 3051 ::testing::Values(true, false));
3052 3052
3053 } // namespace content 3053 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698