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

Unified Diff: chrome/browser/ui/search/local_ntp_browsertest.cc

Issue 2704373002: [Local NTP] Add a test for embeddedSearch API availability (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/local_ntp_browsertest.cc
diff --git a/chrome/browser/ui/search/local_ntp_browsertest.cc b/chrome/browser/ui/search/local_ntp_browsertest.cc
index c80828b124a92b567c87c4a9a4aa8d0898eda0db..076291ba238a150f48573fe8f49312b65bc5e9c0 100644
--- a/chrome/browser/ui/search/local_ntp_browsertest.cc
+++ b/chrome/browser/ui/search/local_ntp_browsertest.cc
@@ -32,6 +32,8 @@ class LocalNTPTest : public InProcessBrowserTest,
public:
LocalNTPTest() {}
+ GURL other_url() { return https_test_server().GetURL("/simple.html"); }
+
protected:
void SetUpInProcessBrowserTestFixture() override {
ASSERT_TRUE(https_test_server().Start());
@@ -62,6 +64,48 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, SimpleJavascriptTests) {
EXPECT_TRUE(success);
}
+IN_PROC_BROWSER_TEST_F(LocalNTPTest, EmbeddedSearchAPIOnlyAvailableOnNTP) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ FocusOmnibox();
+
+ // Open an NTP.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), ntp_url(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* active_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(search::IsInstantNTP(active_tab));
+
+ // Check that the embeddedSearch API is available.
+ bool result = false;
+ ASSERT_TRUE(
+ GetBoolFromJS(active_tab, "!!window.chrome.embeddedSearch", &result));
+ EXPECT_TRUE(result);
+
+ // Navigate somewhere else in the same tab.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), other_url(), WindowOpenDisposition::CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ASSERT_FALSE(search::IsInstantNTP(active_tab));
+
+ // Now the embeddedSearch API should have gone away.
+ ASSERT_TRUE(
+ GetBoolFromJS(active_tab, "!!window.chrome.embeddedSearch", &result));
+ EXPECT_FALSE(result);
+
+ // Navigate back to an NTP.
sfiera 2017/02/21 11:49:46 You're not actually navigating "back", right? (th
Marc Treib 2017/02/21 12:13:08 Right, the formulation was misleading. Changed.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), ntp_url(), WindowOpenDisposition::CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ASSERT_TRUE(search::IsInstantNTP(active_tab));
+
+ // Now the API should be available again.
+ ASSERT_TRUE(
+ GetBoolFromJS(active_tab, "!!window.chrome.embeddedSearch", &result));
+ EXPECT_TRUE(result);
+}
+
IN_PROC_BROWSER_TEST_F(LocalNTPTest, FakeboxRedirectsToOmnibox) {
ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
FocusOmnibox();
« 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