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

Side by Side Diff: chrome/browser/prefetch/prefetch_browsertest.cc

Issue 148983006: Fix a crash due to uninitialized preference member in ProfileIOData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a comment typo Created 6 years, 10 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 | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 24 matching lines...) Expand all
35 switches::kForceFieldTrials, 35 switches::kForceFieldTrials,
36 "Prefetch/ExperimentNo/"); 36 "Prefetch/ExperimentNo/");
37 } 37 }
38 } 38 }
39 39
40 virtual void SetUpOnMainThread() OVERRIDE { 40 virtual void SetUpOnMainThread() OVERRIDE {
41 browser()->profile()->GetPrefs()->SetBoolean( 41 browser()->profile()->GetPrefs()->SetBoolean(
42 prefs::kNetworkPredictionEnabled, do_predictive_networking_); 42 prefs::kNetworkPredictionEnabled, do_predictive_networking_);
43 } 43 }
44 44
45 bool RunPrefetchExperiment(bool expect_success) { 45 bool RunPrefetchExperiment(bool expect_success, Browser* browser) {
46 CHECK(test_server()->Start()); 46 CHECK(test_server()->Start());
47 GURL url = test_server()->GetURL(kPrefetchPage); 47 GURL url = test_server()->GetURL(kPrefetchPage);
48 48
49 const base::string16 expected_title = 49 const base::string16 expected_title =
50 expect_success ? base::ASCIIToUTF16("link onload") 50 expect_success ? base::ASCIIToUTF16("link onload")
51 : base::ASCIIToUTF16("link onerror"); 51 : base::ASCIIToUTF16("link onerror");
52 content::TitleWatcher title_watcher( 52 content::TitleWatcher title_watcher(
53 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 53 browser->tab_strip_model()->GetActiveWebContents(), expected_title);
54 ui_test_utils::NavigateToURL(browser(), url); 54 ui_test_utils::NavigateToURL(browser, url);
55
56 return expected_title == title_watcher.WaitAndGetTitle(); 55 return expected_title == title_watcher.WaitAndGetTitle();
57 } 56 }
58 57
59 private: 58 private:
60 bool do_predictive_networking_; 59 bool do_predictive_networking_;
61 bool do_prefetch_field_trial_; 60 bool do_prefetch_field_trial_;
62 }; 61 };
63 62
64 class PrefetchBrowserTestPredictionOnExpOn : public PrefetchBrowserTestBase { 63 class PrefetchBrowserTestPredictionOnExpOn : public PrefetchBrowserTestBase {
65 public: 64 public:
(...skipping 14 matching lines...) Expand all
80 }; 79 };
81 80
82 class PrefetchBrowserTestPredictionOffExpOff : public PrefetchBrowserTestBase { 81 class PrefetchBrowserTestPredictionOffExpOff : public PrefetchBrowserTestBase {
83 public: 82 public:
84 PrefetchBrowserTestPredictionOffExpOff() 83 PrefetchBrowserTestPredictionOffExpOff()
85 : PrefetchBrowserTestBase(false, false) {} 84 : PrefetchBrowserTestBase(false, false) {}
86 }; 85 };
87 86
88 // Privacy option is on, experiment is on. Prefetch should succeed. 87 // Privacy option is on, experiment is on. Prefetch should succeed.
89 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOnExpOn, PredOnExpOn) { 88 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOnExpOn, PredOnExpOn) {
90 EXPECT_TRUE(RunPrefetchExperiment(true)); 89 EXPECT_TRUE(RunPrefetchExperiment(true, browser()));
91 } 90 }
92 91
93 // Privacy option is on, experiment is off. Prefetch should be dropped. 92 // Privacy option is on, experiment is off. Prefetch should be dropped.
94 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOnExpOff, PredOnExpOff) { 93 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOnExpOff, PredOnExpOff) {
95 EXPECT_TRUE(RunPrefetchExperiment(false)); 94 EXPECT_TRUE(RunPrefetchExperiment(false, browser()));
96 } 95 }
97 96
98 // Privacy option is off, experiment is on. Prefetch should be dropped. 97 // Privacy option is off, experiment is on. Prefetch should be dropped.
99 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOffExpOn, PredOffExpOn) { 98 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOffExpOn, PredOffExpOn) {
100 EXPECT_TRUE(RunPrefetchExperiment(false)); 99 EXPECT_TRUE(RunPrefetchExperiment(false, browser()));
101 } 100 }
102 101
103 // Privacy option is off, experiment is off. Prefetch should be dropped. 102 // Privacy option is off, experiment is off. Prefetch should be dropped.
104 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOffExpOff, PredOffExpOff) { 103 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOffExpOff, PredOffExpOff) {
105 EXPECT_TRUE(RunPrefetchExperiment(false)); 104 EXPECT_TRUE(RunPrefetchExperiment(false, browser()));
105 }
106
107 // Bug 339909: When in incognito mode the browser crashed due to an
108 // uninitialized preference member. Verify that it no longer does.
109 IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestPredictionOnExpOn, IncognitoTest) {
110 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
111 Browser* incognito_browser = new Browser(
112 Browser::CreateParams(incognito_profile, browser()->host_desktop_type()));
113
114 // Navigate just to have a tab in this window, otherwise there is no
115 // WebContents for the incognito browser.
116 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank"));
117
118 EXPECT_TRUE(RunPrefetchExperiment(true, incognito_browser));
106 } 119 }
107 120
108 } // namespace 121 } // namespace
109 122
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698