diff --git a/build/config/jumbo.gni b/build/config/jumbo.gni index b6a7f80..8f923a1 100644 --- a/build/config/jumbo.gni +++ b/build/config/jumbo.gni
@@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/split_static_library.gni") # When someone uses that target_type +import("//build/toolchain/goma.gni") declare_args() { # If true, use a jumbo build (files compiled together) to speed up @@ -25,10 +26,17 @@ # jumbofied. At the same time it increases the compile time for the # largest jumbo chunks by 10-20% and reduces the chance to use all # available CPU cores. So set the default to 50 to balance between - # high and low-core build performance. - jumbo_file_merge_limit = 50 + # high and low-core build performance. -1 means do the default which + # varies depending on whether goma is enabled. + jumbo_file_merge_limit = -1 } +# Normal builds benefit from lots of jumbification +jumbo_file_merge_default = 50 + +# Goma builds benefit from more parallelism +jumbo_file_merge_goma = 8 + # Use one of the targets jumbo_source_set, jumbo_static_library, # jumbo_split_static_library or jumbo_component to generate a target # which merges sources if possible to compile much faster. @@ -111,13 +119,22 @@ current_file_index = 0 next_chunk_start = 0 next_chunk_number = 1 + merge_limit = jumbo_file_merge_limit + if (merge_limit == -1) { + if (use_goma) { + merge_limit = jumbo_file_merge_goma + } else { + merge_limit = jumbo_file_merge_default + } + } + assert(merge_limit > 0) foreach(source_file, invoker_sources) { if (get_path_info(source_file, "extension") != "h") { if (current_file_index == next_chunk_start) { jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_" + next_chunk_number + ".cc" ] next_chunk_number += 1 - next_chunk_start += jumbo_file_merge_limit + next_chunk_start += merge_limit } current_file_index += 1 }
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 464d88b..a9b23d6 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -2816,6 +2816,92 @@ match.contents_class[2].style); } +// Verifies that "http://" is trimmed in the general case. +TEST_F(SearchProviderTest, DoTrimHttpScheme) { + const base::string16 input(ASCIIToUTF16("face book")); + const base::string16 url(ASCIIToUTF16("http://www.facebook.com")); + SearchSuggestionParser::NavigationResult result( + ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), + AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(), + false, 0, false, input); + + // Generate the contents and check for the presence of a scheme. + QueryForInput(input, false, false); + AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match_inline.contents); +} + +// Verifies that "http://" is not trimmed for input that has a scheme, even if +// the input doesn't match the URL. +TEST_F(SearchProviderTest, DontTrimHttpSchemeIfInputHasScheme) { + const base::string16 input(ASCIIToUTF16("https://face book")); + const base::string16 url(ASCIIToUTF16("http://www.facebook.com")); + SearchSuggestionParser::NavigationResult result( + ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), + AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(), + false, 0, false, input); + + // Generate the contents and check for the presence of a scheme. + QueryForInput(input, false, false); + AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); + EXPECT_EQ(url, match_inline.contents); +} + +// Verifies that "https://" is not trimmed for input in the general case. +TEST_F(SearchProviderTest, DontTrimHttpsScheme) { + const base::string16 input(ASCIIToUTF16("face book")); + const base::string16 url(ASCIIToUTF16("https://www.facebook.com")); + SearchSuggestionParser::NavigationResult result( + ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), + AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(), + false, 0, false, input); + + // Generate the contents and check for the presence of a scheme. + QueryForInput(input, false, false); + AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); + EXPECT_EQ(url, match_inline.contents); +} + +// Verifies that "https://" is not trimmed for input that has a (non-matching) +// scheme, even if flag requests it. +TEST_F(SearchProviderTest, DontTrimHttpsSchemeDespiteFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitAndEnableFeature( + omnibox::kUIExperimentHideSuggestionUrlScheme); + + const base::string16 input(ASCIIToUTF16("http://face book")); + const base::string16 url(ASCIIToUTF16("https://www.facebook.com")); + SearchSuggestionParser::NavigationResult result( + ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), + AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(), + false, 0, false, input); + + // Generate the contents and check for the presence of a scheme. + QueryForInput(input, false, false); + AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); + EXPECT_EQ(url, match_inline.contents); +} + +// Verifies that "https://" is trimmed if the flag requests it, and +// nothing else would prevent it. +TEST_F(SearchProviderTest, DoTrimHttpsSchemeIfFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitAndEnableFeature( + omnibox::kUIExperimentHideSuggestionUrlScheme); + + const base::string16 input(ASCIIToUTF16("face book")); + const base::string16 url(ASCIIToUTF16("https://www.facebook.com")); + SearchSuggestionParser::NavigationResult result( + ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), + AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(), + false, 0, false, input); + + // Generate the contents and check for the presence of a scheme. + QueryForInput(input, false, false); + AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match_inline.contents); +} + #if !defined(OS_WIN) // Verify entity suggestion parsing. TEST_F(SearchProviderTest, ParseEntitySuggestion) {
diff --git a/chrome/browser/chrome_network_service_restart_browsertest.cc b/chrome/browser/chrome_network_service_restart_browsertest.cc index d6e1264..eee1cc5 100644 --- a/chrome/browser/chrome_network_service_restart_browsertest.cc +++ b/chrome/browser/chrome_network_service_restart_browsertest.cc
@@ -10,6 +10,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/browser_context.h" +#include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/content_features.h" #include "content/public/common/network_service_test.mojom.h" @@ -43,6 +44,9 @@ network_service_test->SimulateCrash(); run_loop.Run(); + + // Make sure the cached NetworkServicePtr receives error notification. + FlushNetworkServiceInstanceForTesting(); } int LoadBasicRequest(mojom::NetworkContext* network_context) {
diff --git a/components/omnibox/browser/history_quick_provider.cc b/components/omnibox/browser/history_quick_provider.cc index e6810d4..b88bcef2 100644 --- a/components/omnibox/browser/history_quick_provider.cc +++ b/components/omnibox/browser/history_quick_provider.cc
@@ -244,9 +244,10 @@ OffsetsFromTermMatches(history_match.url_matches); match.contents = url_formatter::FormatUrlWithOffsets( info.url(), - AutocompleteMatch::GetFormatTypes(history_match.match_in_scheme, - history_match.match_in_subdomain, - history_match.match_after_host), + AutocompleteMatch::GetFormatTypes( + autocomplete_input_.parts().scheme.len > 0 || + history_match.match_in_scheme, + history_match.match_in_subdomain, history_match.match_after_host), net::UnescapeRule::SPACES, nullptr, nullptr, &offsets); TermMatches new_matches =
diff --git a/components/omnibox/browser/history_quick_provider.h b/components/omnibox/browser/history_quick_provider.h index 2b1f0fcc..c93fb9e 100644 --- a/components/omnibox/browser/history_quick_provider.h +++ b/components/omnibox/browser/history_quick_provider.h
@@ -41,6 +41,15 @@ friend class HistoryQuickProviderTest; FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DoTrimHttpScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, + DontTrimHttpSchemeIfInputHasScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, + DontTrimHttpSchemeIfInputMatches); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DontTrimHttpsScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, + DontTrimHttpsSchemeDespiteFlag); + FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DoTrimHttpsSchemeIfFlag); ~HistoryQuickProvider() override;
diff --git a/components/omnibox/browser/history_quick_provider_unittest.cc b/components/omnibox/browser/history_quick_provider_unittest.cc index 5811e04..84ec7631 100644 --- a/components/omnibox/browser/history_quick_provider_unittest.cc +++ b/components/omnibox/browser/history_quick_provider_unittest.cc
@@ -17,6 +17,7 @@ #include "base/macros.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "base/test/scoped_task_environment.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/test/bookmark_test_helpers.h" @@ -747,6 +748,103 @@ EXPECT_TRUE(provider().matches().empty()); } +ScoredHistoryMatch BuildScoredHistoryMatch(const std::string& url_text) { + return ScoredHistoryMatch( + history::URLRow(GURL(url_text)), VisitInfoVector(), ASCIIToUTF16(""), + String16Vector(1, ASCIIToUTF16("")), WordStarts(1, 0), RowWordStarts(), + false, 0, base::Time()); +} + +// Trim the http:// scheme from the contents in the general case. +TEST_F(HistoryQuickProviderTest, DoTrimHttpScheme) { + AutocompleteInput input(ASCIIToUTF16("face"), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("http://www.facebook.com"); + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents); +} + +// Don't trim the http:// scheme from the match contents if +// the user input included a scheme. +TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputHasScheme) { + AutocompleteInput input(ASCIIToUTF16("http://face"), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("http://www.facebook.com"); + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents); +} + +// Don't trim the http:// scheme from the match contents if +// the user input matched it. +TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputMatches) { + AutocompleteInput input(ASCIIToUTF16("ht"), metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("http://www.facebook.com"); + history_match.match_in_scheme = true; + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents); +} + +// Don't trim the https:// scheme from the match contents in the general case. +TEST_F(HistoryQuickProviderTest, DontTrimHttpsScheme) { + AutocompleteInput input(ASCIIToUTF16("face"), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("https://www.facebook.com"); + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents); +} + +// Don't trim the https:// scheme from the match contents, if the feature +// to do so is enabled, if the user input included a scheme. +TEST_F(HistoryQuickProviderTest, DontTrimHttpsSchemeDespiteFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitAndEnableFeature( + omnibox::kUIExperimentHideSuggestionUrlScheme); + + AutocompleteInput input(ASCIIToUTF16("https://face"), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("https://www.facebook.com"); + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents); +} + +// Trim the https:// scheme from the match contents, if the feature +// to do so is enabled, and nothing else prevents it. +TEST_F(HistoryQuickProviderTest, DoTrimHttpsSchemeIfFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitAndEnableFeature( + omnibox::kUIExperimentHideSuggestionUrlScheme); + + AutocompleteInput input(ASCIIToUTF16("face"), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + provider().Start(input, false); + ScoredHistoryMatch history_match = + BuildScoredHistoryMatch("https://www.facebook.com"); + + AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents); +} + // HQPOrderingTest ------------------------------------------------------------- class HQPOrderingTest : public HistoryQuickProviderTest {
diff --git a/components/omnibox/browser/history_url_provider.cc b/components/omnibox/browser/history_url_provider.cc index d925450..0bcd66d 100644 --- a/components/omnibox/browser/history_url_provider.cc +++ b/components/omnibox/browser/history_url_provider.cc
@@ -1226,7 +1226,8 @@ history_match.input_location + params.input.text().length()}; const auto format_types = AutocompleteMatch::GetFormatTypes( - !params.trim_http || history_match.match_in_scheme, + params.input.parts().scheme.len > 0 || !params.trim_http || + history_match.match_in_scheme, history_match.match_in_subdomain, history_match.match_after_host); match.contents = url_formatter::FormatUrlWithOffsets( info.url(), format_types, net::UnescapeRule::SPACES, nullptr, nullptr,
diff --git a/components/omnibox/browser/history_url_provider.h b/components/omnibox/browser/history_url_provider.h index 8498098..df943c4 100644 --- a/components/omnibox/browser/history_url_provider.h +++ b/components/omnibox/browser/history_url_provider.h
@@ -221,6 +221,15 @@ private: FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, HUPScoringExperiment); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DoTrimHttpScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, + DontTrimHttpSchemeIfInputHasScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, + DontTrimHttpSchemeIfInputMatchesInScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DontTrimHttpsScheme); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, + DontTrimHttpsSchemeDespiteFlag); + FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DoTrimHttpsSchemeIfFlag); enum MatchType { NORMAL,
diff --git a/components/omnibox/browser/history_url_provider_unittest.cc b/components/omnibox/browser/history_url_provider_unittest.cc index 69c16ad..5b66e34 100644 --- a/components/omnibox/browser/history_url_provider_unittest.cc +++ b/components/omnibox/browser/history_url_provider_unittest.cc
@@ -1246,3 +1246,84 @@ omnibox::kUIExperimentElideSuggestionUrlAfterHost); ExpectFormattedFullMatch("hij", L"https://www.hij.com/\x2026\x0000", 12, 3); } + +std::unique_ptr<HistoryURLProviderParams> BuildHistoryURLProviderParams( + const std::string& input_text, + const std::string& url_text, + bool match_in_scheme) { + AutocompleteInput input(ASCIIToUTF16(input_text), + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier()); + history::HistoryMatch history_match; + history_match.url_info.set_url(GURL(url_text)); + history_match.match_in_scheme = match_in_scheme; + auto params = std::make_unique<HistoryURLProviderParams>( + input, true, AutocompleteMatch(), nullptr, SearchTermsData()); + params->matches.push_back(history_match); + + return params; +} + +// Make sure "http://" scheme is generally trimmed. +TEST_F(HistoryURLProviderTest, DoTrimHttpScheme) { + auto params = + BuildHistoryURLProviderParams("face", "http://www.facebook.com", false); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents); +} + +// Make sure "http://" scheme is not trimmed if input has a scheme too. +TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputHasScheme) { + auto params = BuildHistoryURLProviderParams("http://face", + "http://www.facebook.com", false); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents); +} + +// Make sure "http://" scheme is not trimmed if input matches in scheme. +TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputMatchesInScheme) { + auto params = + BuildHistoryURLProviderParams("ht face", "http://www.facebook.com", true); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents); +} + +// Make sure "https://" scheme is generally not trimmed. +TEST_F(HistoryURLProviderTest, DontTrimHttpsScheme) { + auto params = + BuildHistoryURLProviderParams("face", "https://www.facebook.com", false); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents); +} + +// Make sure "https://" scheme is not trimmed even when requested by flag +// if the input has a scheme. +TEST_F(HistoryURLProviderTest, DontTrimHttpsSchemeDespiteFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitWithFeatures( + {omnibox::kUIExperimentHideSuggestionUrlScheme}, {}); + + auto params = BuildHistoryURLProviderParams( + "https://face", "https://www.facebook.com", false); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents); +} + +// Make sure "https://" scheme is trimmed if requested by flag, and nothing +// else prevents it. +TEST_F(HistoryURLProviderTest, DoTrimHttpsSchemeIfFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitWithFeatures( + {omnibox::kUIExperimentHideSuggestionUrlScheme}, {}); + + auto params = + BuildHistoryURLProviderParams("face", "https://www.facebook.com", false); + + AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0); + EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents); +}
diff --git a/components/omnibox/browser/search_provider.h b/components/omnibox/browser/search_provider.h index 1012bb5..1802419 100644 --- a/components/omnibox/browser/search_provider.h +++ b/components/omnibox/browser/search_provider.h
@@ -98,6 +98,12 @@ FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveExtraAnswers); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoesNotProvideOnFocus); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SendsWarmUpRequestOnFocus); + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoTrimHttpScheme); + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, + DontTrimHttpSchemeIfInputHasScheme); + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DontTrimHttpsScheme); + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DontTrimHttpsSchemeDespiteFlag); + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoTrimHttpsSchemeIfFlag); FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery);
diff --git a/components/omnibox/browser/search_suggestion_parser.cc b/components/omnibox/browser/search_suggestion_parser.cc index 95a6031..674e7d2 100644 --- a/components/omnibox/browser/search_suggestion_parser.cc +++ b/components/omnibox/browser/search_suggestion_parser.cc
@@ -288,7 +288,8 @@ GURL(formatted_url_), {{match_start, match_start + input_text.length()}}, &match_in_scheme, &match_in_subdomain, &match_after_host); auto format_types = AutocompleteMatch::GetFormatTypes( - match_in_scheme, match_in_subdomain, match_after_host); + GURL(input_text).has_scheme() || match_in_scheme, match_in_subdomain, + match_after_host); base::string16 match_contents = url_formatter::FormatUrl(url_, format_types, net::UnescapeRule::SPACES,
diff --git a/components/omnibox/browser/titled_url_match_utils.cc b/components/omnibox/browser/titled_url_match_utils.cc index 08c6139..f567d1b3 100644 --- a/components/omnibox/browser/titled_url_match_utils.cc +++ b/components/omnibox/browser/titled_url_match_utils.cc
@@ -79,7 +79,8 @@ url, titled_url_match.url_match_positions, &match_in_scheme, &match_in_subdomain, &match_after_host); auto format_types = AutocompleteMatch::GetFormatTypes( - match_in_scheme, match_in_subdomain, match_after_host); + input.parts().scheme.len > 0 || match_in_scheme, match_in_subdomain, + match_after_host); std::vector<size_t> offsets = TitledUrlMatch::OffsetsFromMatchPositions( titled_url_match.url_match_positions);
diff --git a/components/omnibox/browser/titled_url_match_utils_unittest.cc b/components/omnibox/browser/titled_url_match_utils_unittest.cc index 4b5095d..8976d6ac 100644 --- a/components/omnibox/browser/titled_url_match_utils_unittest.cc +++ b/components/omnibox/browser/titled_url_match_utils_unittest.cc
@@ -7,11 +7,13 @@ #include <memory> #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "components/bookmarks/browser/titled_url_match.h" #include "components/bookmarks/browser/titled_url_node.h" #include "components/omnibox/browser/autocomplete_input.h" #include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_provider.h" +#include "components/omnibox/browser/omnibox_field_trial.h" #include "components/omnibox/browser/test_scheme_classifier.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/metrics_proto/omnibox_event.pb.h" @@ -110,6 +112,121 @@ autocomplete_match.inline_autocompletion); } +AutocompleteMatch BuildTestAutocompleteMatch( + const std::string& input_text_s, + const GURL& match_url, + const bookmarks::TitledUrlMatch::MatchPositions& match_positions) { + base::string16 input_text(base::ASCIIToUTF16(input_text_s)); + base::string16 match_title(base::ASCIIToUTF16("The Facebook")); + AutocompleteMatchType::Type type = AutocompleteMatchType::BOOKMARK_TITLE; + int relevance = 123; + + MockTitledUrlNode node(match_title, match_url); + bookmarks::TitledUrlMatch titled_url_match; + titled_url_match.node = &node; + titled_url_match.title_match_positions = {{0, 3}}; + // Don't capture the scheme, so that it doesn't match. + titled_url_match.url_match_positions = match_positions; + + scoped_refptr<MockAutocompleteProvider> provider = + new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK); + TestSchemeClassifier classifier; + AutocompleteInput input(input_text, metrics::OmniboxEventProto::NTP, + classifier); + const base::string16 fixed_up_input(input_text); + + return TitledUrlMatchToAutocompleteMatch(titled_url_match, type, relevance, + provider.get(), classifier, input, + fixed_up_input); +} + +TEST(TitledUrlMatchUtilsTest, DoTrimHttpScheme) { + GURL match_url("http://www.facebook.com/"); + AutocompleteMatch autocomplete_match = + BuildTestAutocompleteMatch("face", match_url, {{11, 15}}); + + ACMatchClassifications expected_contents_class = { + {0, ACMatchClassification::URL}, + {4, ACMatchClassification::URL | ACMatchClassification::MATCH}, + {8, ACMatchClassification::URL}, + }; + base::string16 expected_contents(base::ASCIIToUTF16("www.facebook.com")); + + EXPECT_EQ(match_url, autocomplete_match.destination_url); + EXPECT_EQ(expected_contents, autocomplete_match.contents); + EXPECT_TRUE(std::equal(expected_contents_class.begin(), + expected_contents_class.end(), + autocomplete_match.contents_class.begin())); + EXPECT_TRUE(autocomplete_match.allowed_to_be_default_match); +} + +TEST(TitledUrlMatchUtilsTest, DontTrimHttpSchemeIfInputHasScheme) { + GURL match_url("http://www.facebook.com/"); + AutocompleteMatch autocomplete_match = + BuildTestAutocompleteMatch("http://face", match_url, {{11, 15}}); + + ACMatchClassifications expected_contents_class = { + {0, ACMatchClassification::URL}, + {11, ACMatchClassification::URL | ACMatchClassification::MATCH}, + {15, ACMatchClassification::URL}, + }; + base::string16 expected_contents( + base::ASCIIToUTF16("http://www.facebook.com")); + + EXPECT_EQ(match_url, autocomplete_match.destination_url); + EXPECT_EQ(expected_contents, autocomplete_match.contents); + EXPECT_TRUE(std::equal(expected_contents_class.begin(), + expected_contents_class.end(), + autocomplete_match.contents_class.begin())); + EXPECT_FALSE(autocomplete_match.allowed_to_be_default_match); +} + +TEST(TitledUrlMatchUtilsTest, DontTrimHttpsScheme) { + GURL match_url("https://www.facebook.com/"); + AutocompleteMatch autocomplete_match = + BuildTestAutocompleteMatch("face", match_url, {{12, 16}}); + + ACMatchClassifications expected_contents_class = { + {0, ACMatchClassification::URL}, + {12, ACMatchClassification::URL | ACMatchClassification::MATCH}, + {16, ACMatchClassification::URL}, + }; + base::string16 expected_contents( + base::ASCIIToUTF16("https://www.facebook.com")); + + EXPECT_EQ(match_url, autocomplete_match.destination_url); + EXPECT_EQ(expected_contents, autocomplete_match.contents); + EXPECT_TRUE(std::equal(expected_contents_class.begin(), + expected_contents_class.end(), + autocomplete_match.contents_class.begin())); + EXPECT_TRUE(autocomplete_match.allowed_to_be_default_match); +} + +TEST(TitledUrlMatchUtilsTest, DontTrimHttpsSchemeDespiteFlag) { + auto feature_list = std::make_unique<base::test::ScopedFeatureList>(); + feature_list->InitAndEnableFeature( + omnibox::kUIExperimentHideSuggestionUrlScheme); + + GURL match_url("https://www.facebook.com/"); + AutocompleteMatch autocomplete_match = + BuildTestAutocompleteMatch("https://face", match_url, {{12, 16}}); + + ACMatchClassifications expected_contents_class = { + {0, ACMatchClassification::URL}, + {12, ACMatchClassification::URL | ACMatchClassification::MATCH}, + {16, ACMatchClassification::URL}, + }; + base::string16 expected_contents( + base::ASCIIToUTF16("https://www.facebook.com")); + + EXPECT_EQ(match_url, autocomplete_match.destination_url); + EXPECT_EQ(expected_contents, autocomplete_match.contents); + EXPECT_TRUE(std::equal(expected_contents_class.begin(), + expected_contents_class.end(), + autocomplete_match.contents_class.begin())); + EXPECT_FALSE(autocomplete_match.allowed_to_be_default_match); +} + TEST(TitledUrlMatchUtilsTest, EmptyInlineAutocompletion) { // The search term matches the title but not the URL. Since there is no URL // match, the inline autocompletion string will be empty.
diff --git a/content/browser/network_service_restart_browsertest.cc b/content/browser/network_service_restart_browsertest.cc index a43322d..829ba96e 100644 --- a/content/browser/network_service_restart_browsertest.cc +++ b/content/browser/network_service_restart_browsertest.cc
@@ -54,6 +54,9 @@ network_service_test->SimulateCrash(); run_loop.Run(); + + // Make sure the cached NetworkServicePtr receives error notification. + FlushNetworkServiceInstanceForTesting(); } int LoadBasicRequest(mojom::NetworkContext* network_context) { @@ -114,18 +117,10 @@ EXPECT_FALSE(network_context2.encountered_error()); } -// Flaky on Mac bots. crbug.com/793296 -#if defined(OS_MACOSX) -#define MAYBE_StoragePartitionImplGetNetworkContext \ - DISABLED_StoragePartitionImplGetNetworkContext -#else -#define MAYBE_StoragePartitionImplGetNetworkContext \ - StoragePartitionImplGetNetworkContext -#endif // Make sure |StoragePartitionImpl::GetNetworkContext()| returns valid interface // after crash. IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, - MAYBE_StoragePartitionImplGetNetworkContext) { + StoragePartitionImplGetNetworkContext) { StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( BrowserContext::GetDefaultStoragePartition( shell()->web_contents()->GetBrowserContext()));
diff --git a/content/public/browser/network_service_instance.cc b/content/public/browser/network_service_instance.cc index 0f623888..91d3c6d 100644 --- a/content/public/browser/network_service_instance.cc +++ b/content/public/browser/network_service_instance.cc
@@ -15,12 +15,14 @@ namespace content { +static mojom::NetworkServicePtr* g_network_service = nullptr; + mojom::NetworkService* GetNetworkService() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(base::FeatureList::IsEnabled(features::kNetworkService)); - static mojom::NetworkServicePtr* g_network_service = - new mojom::NetworkServicePtr; + if (!g_network_service) + g_network_service = new mojom::NetworkServicePtr; static NetworkServiceClient* g_client; if (!g_network_service->is_bound() || g_network_service->encountered_error()) { @@ -35,4 +37,12 @@ return g_network_service->get(); } +void FlushNetworkServiceInstanceForTesting() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(base::FeatureList::IsEnabled(features::kNetworkService)); + + if (g_network_service) + g_network_service->FlushForTesting(); +} + } // namespace content
diff --git a/content/public/browser/network_service_instance.h b/content/public/browser/network_service_instance.h index 0de5b4d..fe439ea 100644 --- a/content/public/browser/network_service_instance.h +++ b/content/public/browser/network_service_instance.h
@@ -18,6 +18,11 @@ // service is disabled. CONTENT_EXPORT mojom::NetworkService* GetNetworkService(); +// Call |FlushForTesting()| on cached |NetworkServicePtr|. For testing only. +// Must only be called on the UI thread. Must not be called if the network +// service is disabled. +CONTENT_EXPORT void FlushNetworkServiceInstanceForTesting(); + } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_NETWORK_SERVICE_INSTANCE_H_ \ No newline at end of file +#endif // CONTENT_PUBLIC_BROWSER_NETWORK_SERVICE_INSTANCE_H_
diff --git a/testing/buildbot/chromium.swarm.json b/testing/buildbot/chromium.swarm.json index 1c5d8a96..ad735403 100644 --- a/testing/buildbot/chromium.swarm.json +++ b/testing/buildbot/chromium.swarm.json
@@ -1,4 +1,6 @@ { + "AAAAA1 AUTOGENERATED FILE DO NOT EDIT": {}, + "AAAAA2 See generate_buildbot_json.py to make changes": {}, "Android N5 Swarm": { "gtest_tests": [ {
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index 5f12c7cc..662688ee 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -580,6 +580,8 @@ 'Marshmallow Phone Tester (rel)', # chromium.clang 'ToTAndroidCFI', + # TODO(dpranke): on chromium.swarm, this is probably also an accident. + 'Android N5X Swarm', ], 'key_removals': { 'ToTAndroid x64': [ @@ -1041,6 +1043,12 @@ 'Fuchsia x64 SANDBOX', ], 'modifications': { + # TODO(dpranke) - on chromium.swarm, remove this exception. + 'Android N5X Swarm': { + 'swarming': { + 'shards': 4, + }, + }, 'KitKat Tablet Tester': { 'swarming': { 'hard_timeout': 1200, @@ -2764,7 +2772,7 @@ 'shards': 2, }, }, - # chromium.android + # chromium.memory 'Linux ASan LSan Tests (1)': { 'swarming': { 'shards': 2, @@ -2780,6 +2788,12 @@ 'shards': 2, }, }, + # chromium.swarm + 'Android N5X Swarm': { + 'swarming': { + 'shards': 8, + }, + }, }, }, 'url_unittests': { @@ -3099,6 +3113,9 @@ 'Nougat Phone Tester', # chromium.clang 'ToTAndroid x64', + # On chromium.swarm, this should possibly be being run (or removed + # from Android N5X Swarm). + 'Android N5 Swarm', ], 'key_removals': { # chromium.clang
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index 3f81d12..6cc1e62 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -325,6 +325,58 @@ 'interactive_ui_tests': {}, }, + 'chromium_swarm_android_gtests': { + 'base_unittests': {}, + 'chrome_public_test_apk': { + 'swarming': { + 'shards': 14, + }, + }, + 'content_browsertests': { + 'swarming': { + 'shards': 10, + }, + }, + 'content_unittests': { + 'swarming': { + 'shards': 3, + }, + }, + 'content_shell_test_apk': { + 'swarming': { + 'shards': 3, + }, + }, + 'net_unittests': { + 'swarming': { + 'shards': 4, + }, + }, + 'unit_tests': { + 'swarming': { + 'shards': 5, + }, + }, + 'webview_instrumentation_test_apk': { + 'swarming': { + 'shards': 7, + }, + }, + }, + 'chromium_swarm_desktop_gtests': { + 'base_unittests': {}, + 'browser_tests': { + 'swarming': { + 'shards': 2, + }, + }, + 'content_browsertests': {}, + 'content_unittests': {}, + 'interactive_ui_tests': {}, + 'net_unittests': {}, + 'unit_tests': {}, + }, + 'cronet_gtests': { 'cronet_sample_test_apk': { 'swarming': {
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index b764bdc5..583e177b 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -825,6 +825,56 @@ }, }, { + 'name': 'chromium.swarm', + 'machines': { + 'Android N5 Swarm': { + 'test_suites': { + 'gtest_tests': 'chromium_swarm_android_gtests', + }, + 'swarming': { + 'dimension_sets': [ + { + 'device_os': 'KTU84P', + 'device_type': 'hammerhead', + }, + ], + 'expiration': 10800, + }, + # 'os_type': 'android', + }, + 'Android N5X Swarm': { + 'test_suites': { + 'gtest_tests': 'chromium_swarm_android_gtests', + }, + 'swarming': { + 'dimension_sets': [ + { + 'device_os': 'MMB29Q', + 'device_type': 'bullhead', + }, + ], + 'expiration': 10800, + }, + # 'os_type': 'android', + }, + 'Linux Swarm': { + 'test_suites': { + 'gtest_tests': 'chromium_swarm_desktop_gtests', + }, + }, + 'Mac Swarm': { + 'test_suites': { + 'gtest_tests': 'chromium_swarm_desktop_gtests', + }, + }, + 'Windows Swarm': { + 'test_suites': { + 'gtest_tests': 'chromium_swarm_desktop_gtests', + }, + }, + }, + }, + { 'name': 'chromium.win', 'machines': { 'Win Builder': {