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

Side by Side Diff: chrome/browser/data_saver/data_saver_browsertest.cc

Issue 2106213002: Ignore favicon request in DataSaverWithServerBrowserTest.ReloadPage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 5 #include <string>
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 void EnableDataSaver(bool enabled) { 61 void EnableDataSaver(bool enabled) {
62 PrefService* prefs = browser()->profile()->GetPrefs(); 62 PrefService* prefs = browser()->profile()->GetPrefs();
63 prefs->SetBoolean(prefs::kDataSaverEnabled, enabled); 63 prefs->SetBoolean(prefs::kDataSaverEnabled, enabled);
64 } 64 }
65 65
66 std::unique_ptr<net::test_server::HttpResponse> VerifySaveDataHeader( 66 std::unique_ptr<net::test_server::HttpResponse> VerifySaveDataHeader(
67 const net::test_server::HttpRequest& request) { 67 const net::test_server::HttpRequest& request) {
68 auto save_data_header_it = request.headers.find("save-data"); 68 auto save_data_header_it = request.headers.find("save-data");
69 69
70 if (request.relative_url == "/favicon.ico") {
71 // Favicon request could be received for the previous page load.
72 return std::unique_ptr<net::test_server::HttpResponse>();
73 }
74
70 if (!expected_save_data_header_.empty()) { 75 if (!expected_save_data_header_.empty()) {
71 EXPECT_TRUE(save_data_header_it != request.headers.end()); 76 EXPECT_TRUE(save_data_header_it != request.headers.end())
72 EXPECT_EQ(expected_save_data_header_, save_data_header_it->second); 77 << request.relative_url;
78 EXPECT_EQ(expected_save_data_header_, save_data_header_it->second)
79 << request.relative_url;
73 } else { 80 } else {
74 EXPECT_TRUE(save_data_header_it == request.headers.end()); 81 EXPECT_TRUE(save_data_header_it == request.headers.end())
82 << request.relative_url;
75 } 83 }
76 return std::unique_ptr<net::test_server::HttpResponse>(); 84 return std::unique_ptr<net::test_server::HttpResponse>();
77 } 85 }
78 86
79 std::unique_ptr<net::EmbeddedTestServer> test_server_; 87 std::unique_ptr<net::EmbeddedTestServer> test_server_;
80 std::string expected_save_data_header_; 88 std::string expected_save_data_header_;
81 }; 89 };
82 90
83 IN_PROC_BROWSER_TEST_F(DataSaverWithServerBrowserTest, ReloadPage) { 91 IN_PROC_BROWSER_TEST_F(DataSaverWithServerBrowserTest, ReloadPage) {
84 Init(); 92 Init();
(...skipping 12 matching lines...) Expand all
97 browser()->tab_strip_model()->GetActiveWebContents()); 105 browser()->tab_strip_model()->GetActiveWebContents());
98 106
99 // Reload the webpage with data saver disabled, and expect all the resources 107 // Reload the webpage with data saver disabled, and expect all the resources
100 // will get no save-data header. 108 // will get no save-data header.
101 EnableDataSaver(false); 109 EnableDataSaver(false);
102 expected_save_data_header_ = ""; 110 expected_save_data_header_ = "";
103 chrome::Reload(browser(), CURRENT_TAB); 111 chrome::Reload(browser(), CURRENT_TAB);
104 content::WaitForLoadStop( 112 content::WaitForLoadStop(
105 browser()->tab_strip_model()->GetActiveWebContents()); 113 browser()->tab_strip_model()->GetActiveWebContents());
106 } 114 }
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