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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 8373010: Fixing visibility transitions for Instant. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixing possible crash. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/instant/instant_controller.h" 10 #include "chrome/browser/instant/instant_controller.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch 52 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch
53 #define MAYBE_SearchToNonSearch DISABLED_SearchToNonSearch 53 #define MAYBE_SearchToNonSearch DISABLED_SearchToNonSearch
54 #define MAYBE_ValidHeight DISABLED_ValidHeight 54 #define MAYBE_ValidHeight DISABLED_ValidHeight
55 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent 55 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent
56 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent 56 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent
57 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever 57 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever
58 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed 58 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed
59 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS 59 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS
60 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox 60 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox
61 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant 61 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant
62 #define MAYBE_PageVisibilityTest DISABLED_PageVisibilityTest
62 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled 63 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled
63 #define MAYBE_IntranetPathLooksLikeSearch DISABLED_IntranetPathLooksLikeSearch 64 #define MAYBE_IntranetPathLooksLikeSearch DISABLED_IntranetPathLooksLikeSearch
64 #else 65 #else
65 #define MAYBE_OnChangeEvent OnChangeEvent 66 #define MAYBE_OnChangeEvent OnChangeEvent
66 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings 67 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings
67 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray 68 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray
68 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson 69 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson
69 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions 70 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions
70 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson 71 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson
71 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions 72 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions
72 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion 73 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion
73 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch 74 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch
74 #define MAYBE_NonSearchToSearch NonSearchToSearch 75 #define MAYBE_NonSearchToSearch NonSearchToSearch
75 #define MAYBE_SearchToNonSearch SearchToNonSearch 76 #define MAYBE_SearchToNonSearch SearchToNonSearch
76 #define MAYBE_ValidHeight ValidHeight 77 #define MAYBE_ValidHeight ValidHeight
77 #define MAYBE_OnSubmitEvent OnSubmitEvent 78 #define MAYBE_OnSubmitEvent OnSubmitEvent
78 #define MAYBE_OnCancelEvent OnCancelEvent 79 #define MAYBE_OnCancelEvent OnCancelEvent
79 #define MAYBE_InstantCompleteNever InstantCompleteNever 80 #define MAYBE_InstantCompleteNever InstantCompleteNever
80 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed 81 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed
81 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS 82 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS
82 #define MAYBE_DontPersistSearchbox DontPersistSearchbox 83 #define MAYBE_DontPersistSearchbox DontPersistSearchbox
83 #define MAYBE_PreloadsInstant PreloadsInstant 84 #define MAYBE_PreloadsInstant PreloadsInstant
85 #define MAYBE_PageVisibilityTest PageVisibilityTest
84 #define MAYBE_ExperimentEnabled ExperimentEnabled 86 #define MAYBE_ExperimentEnabled ExperimentEnabled
85 #define MAYBE_IntranetPathLooksLikeSearch IntranetPathLooksLikeSearch 87 #define MAYBE_IntranetPathLooksLikeSearch IntranetPathLooksLikeSearch
86 #endif 88 #endif
87 89
88 #if defined(OS_MACOSX) || defined(OS_LINUX) 90 #if defined(OS_MACOSX) || defined(OS_LINUX)
89 // Showing as flaky on Mac and Linux. 91 // Showing as flaky on Mac and Linux.
90 // http://crbug.com/70860 92 // http://crbug.com/70860
91 #define MAYBE_SearchServerDoesntSupportInstant \ 93 #define MAYBE_SearchServerDoesntSupportInstant \
92 DISABLED_SearchServerDoesntSupportInstant 94 DISABLED_SearchServerDoesntSupportInstant
93 #define MAYBE_NonSearchToSearchDoesntSupportInstant \ 95 #define MAYBE_NonSearchToSearchDoesntSupportInstant \
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 "window.domAutomationController.send(%s)", function.c_str()); 260 "window.domAutomationController.send(%s)", function.c_str());
259 return ui_test_utils::ExecuteJavaScriptAndExtractBool( 261 return ui_test_utils::ExecuteJavaScriptAndExtractBool(
260 tab_contents->render_view_host(), 262 tab_contents->render_view_host(),
261 std::wstring(), UTF8ToWide(script), result); 263 std::wstring(), UTF8ToWide(script), result);
262 } 264 }
263 265
264 bool HasPreview() { 266 bool HasPreview() {
265 return browser()->instant()->GetPreviewContents() != NULL; 267 return browser()->instant()->GetPreviewContents() != NULL;
266 } 268 }
267 269
270 bool IsVisible(TabContents* tab_contents) {
271 std::string visibility;
272 if (!GetStringFromJavascript(tab_contents, "document.webkitVisibilityState",
273 &visibility))
274 return false;
275 return visibility == "visible";
276 }
277
268 // Returns the state of the search box as a string. This consists of the 278 // Returns the state of the search box as a string. This consists of the
269 // following: 279 // following:
270 // window.chrome.sv 280 // window.chrome.sv
271 // window.onsubmitcalls 281 // window.onsubmitcalls
272 // window.oncancelcalls 282 // window.oncancelcalls
273 // window.onchangecalls 283 // window.onchangecalls
274 // 'true' if window.onresizecalls has been sent, otherwise false. 284 // 'true' if window.onresizecalls has been sent, otherwise false.
275 // window.beforeLoadSearchBox.value 285 // window.beforeLoadSearchBox.value
276 // window.beforeLoadSearchBox.verbatim 286 // window.beforeLoadSearchBox.verbatim
277 // window.chrome.searchBox.value 287 // window.chrome.searchBox.value
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 FindLocationBar(); 901 FindLocationBar();
892 location_bar_->FocusLocation(false); 902 location_bar_->FocusLocation(false);
893 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); 903 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents();
894 EXPECT_TRUE(tab_contents); 904 EXPECT_TRUE(tab_contents);
895 905
896 instant_support_observer.Wait(); 906 instant_support_observer.Wait();
897 907
898 // Instant should have a preview, but not display it. 908 // Instant should have a preview, but not display it.
899 EXPECT_TRUE(HasPreview()); 909 EXPECT_TRUE(HasPreview());
900 EXPECT_FALSE(browser()->instant()->is_displayable()); 910 EXPECT_FALSE(browser()->instant()->is_displayable());
911 EXPECT_FALSE(IsVisible(tab_contents->tab_contents()));
901 912
902 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper. 913 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper.
903 AddBlankTabAndShow(browser()); 914 AddBlankTabAndShow(browser());
904 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); 915 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents());
905 916
906 // Doing a search should still use the same loader for the preview. 917 // Doing a search should still use the same loader for the preview.
907 SetLocationBarText("def"); 918 SetLocationBarText("def");
908 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); 919 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents());
909 920
910 // Verify that the preview is in fact showing instant search. 921 // Verify that the preview is in fact showing instant search.
(...skipping 17 matching lines...) Expand all
928 939
929 // Navigate to a URL that looks like a search (when the scheme is stripped). 940 // Navigate to a URL that looks like a search (when the scheme is stripped).
930 // It's okay if the host is bogus or the navigation fails, since we only care 941 // It's okay if the host is bogus or the navigation fails, since we only care
931 // that instant doesn't act on it. 942 // that instant doesn't act on it.
932 ui_test_utils::NavigateToURL(browser(), GURL("http://baby/beluga")); 943 ui_test_utils::NavigateToURL(browser(), GURL("http://baby/beluga"));
933 944
934 // Instant should not have tried to load a preview for this "search". 945 // Instant should not have tried to load a preview for this "search".
935 EXPECT_FALSE(HasPreview()); 946 EXPECT_FALSE(HasPreview());
936 } 947 }
937 948
949 // Tests that the instant search page's visibility is set correctly.
950 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_PageVisibilityTest) {
951 ASSERT_TRUE(test_server()->Start());
952 EnableInstant();
953 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html"));
954
955 // Initially navigate to the empty page which should be visible.
956 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(""));
957 TabContents* initial_contents = browser()->GetSelectedTabContents();
958 EXPECT_TRUE(IsVisible(initial_contents));
959
960 // Type something for instant to trigger and wait for preview to navigate.
961 ASSERT_NO_FATAL_FAILURE(FindLocationBar());
962 location_bar_->FocusLocation(false);
963 SetupLocationBar();
964 SetupPreview();
965 SetLocationBarText("def");
966 TabContents* preview_contents =
967 browser()->instant()->GetPreviewContents()->tab_contents();
968 EXPECT_TRUE(IsVisible(preview_contents));
969 EXPECT_FALSE(IsVisible(initial_contents));
970
971 // Delete the user text we should show the previous page.
972 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(""));
973 EXPECT_FALSE(IsVisible(preview_contents));
974 EXPECT_TRUE(IsVisible(initial_contents));
975
976 // Set the user text back and we should see the preview again.
977 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def"));
978 EXPECT_TRUE(IsVisible(preview_contents));
979 EXPECT_FALSE(IsVisible(initial_contents));
980
981 // Commit the preview.
982 SendKey(ui::VKEY_RETURN);
983 EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents());
984 EXPECT_TRUE(IsVisible(preview_contents));
985 }
986
987
938 // Tests the INSTANT experiment of the field trial. 988 // Tests the INSTANT experiment of the field trial.
939 class InstantFieldTrialInstantTest : public InstantTest { 989 class InstantFieldTrialInstantTest : public InstantTest {
940 public: 990 public:
941 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 991 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
942 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, 992 command_line->AppendSwitchASCII(switches::kInstantFieldTrial,
943 switches::kInstantFieldTrialInstant); 993 switches::kInstantFieldTrialInstant);
944 } 994 }
945 }; 995 };
946 996
947 // Tests that instant is active, even without calling EnableInstant(). 997 // Tests that instant is active, even without calling EnableInstant().
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1138
1089 // Wait for the preview to navigate. 1139 // Wait for the preview to navigate.
1090 WaitForPreviewToNavigate(); 1140 WaitForPreviewToNavigate();
1091 instant_support_observer.Wait(); 1141 instant_support_observer.Wait();
1092 1142
1093 // Instant should be active, but not displayable or committable. 1143 // Instant should be active, but not displayable or committable.
1094 EXPECT_TRUE(HasPreview()); 1144 EXPECT_TRUE(HasPreview());
1095 EXPECT_FALSE(browser()->instant()->is_displayable()); 1145 EXPECT_FALSE(browser()->instant()->is_displayable());
1096 EXPECT_FALSE(browser()->instant()->PrepareForCommit()); 1146 EXPECT_FALSE(browser()->instant()->PrepareForCommit());
1097 } 1147 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698