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

Unified Diff: chrome/browser/extensions/extension_override_apitest.cc

Issue 2754363002: Don't focus the omnibox when a subframe navigates on NTP (Merge to M58) (Closed)
Patch Set: Created 3 years, 9 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 | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_override_apitest.cc
diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc
index ad91455c2af1b38c51521120f5220ade2b2762f7..b1c8ae395904a1a6e870402141403d52478d3c31 100644
--- a/chrome/browser/extensions/extension_override_apitest.cc
+++ b/chrome/browser/extensions/extension_override_apitest.cc
@@ -17,10 +17,14 @@
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "extensions/common/constants.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
+#include "net/dns/mock_host_resolver.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
using content::WebContents;
@@ -191,6 +195,43 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewTabIncognito) {
SchemeIs(kExtensionScheme));
}
+// Check that when an overridden new tab page has focus, a subframe navigation
+// on that page does not steal the focus away by focusing the omnibox.
+// See https://crbug.com/700124.
+IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest,
+ SubframeNavigationInOverridenNTPDoesNotAffectFocus) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ // Load an extension that overrides the new tab page.
+ const Extension* extension = LoadExtension(data_dir().AppendASCII("newtab"));
+
+ // Navigate to the new tab page. The overridden new tab page
+ // will call chrome.test.sendMessage('controlled by first').
+ ExtensionTestMessageListener listener("controlled by first", false);
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_TRUE(ExtensionControlsPage(contents, extension->id()));
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+
+ // Start off with the main page focused.
+ contents->Focus();
+ EXPECT_TRUE(contents->GetRenderWidgetHostView()->HasFocus());
+
+ // Inject an iframe and navigate it to a cross-site URL. With
+ // --site-per-process, this will go into a separate process.
+ GURL cross_site_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
+ std::string script = "var f = document.createElement('iframe');\n"
+ "f.src = '" + cross_site_url.spec() + "';\n"
+ "document.body.appendChild(f);\n";
+ EXPECT_TRUE(ExecuteScript(contents, script));
+ WaitForLoadStop(contents);
+
+ // The page should still have focus. The cross-process subframe navigation
+ // above should not try to focus the omnibox, which would make this false.
+ EXPECT_TRUE(contents->GetRenderWidgetHostView()->HasFocus());
+}
+
// Times out consistently on Win, http://crbug.com/45173.
#if defined(OS_WIN)
#define MAYBE_OverrideHistory DISABLED_OverrideHistory
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698