diff options
Diffstat (limited to 'chrome/browser/extensions/extension_webnavigation_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_webnavigation_apitest.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_webnavigation_apitest.cc b/chrome/browser/extensions/extension_webnavigation_apitest.cc index 1996e28..22fb035 100644 --- a/chrome/browser/extensions/extension_webnavigation_apitest.cc +++ b/chrome/browser/extensions/extension_webnavigation_apitest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/command_line.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_service.h" @@ -12,9 +11,11 @@ #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "net/base/mock_host_resolver.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/context_menu.h" namespace { @@ -147,3 +148,34 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) { ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); } + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { + FrameNavigationState::set_allow_extension_scheme(true); + + // Wait for the extension to set itself up and return control to us. + ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) + << message_; + + ResultCatcher catcher; + + ExtensionService* service = browser()->profile()->GetExtensionService(); + const Extension* extension = + service->GetExtensionById(last_loaded_extension_id_, false); + GURL url = extension->GetResourceURL("requestOpenTab/a.html"); + + ui_test_utils::NavigateToURL(browser(), url); + + // There's a link on a.html. Middle-click on it to open it in a new tab. + WebKit::WebMouseEvent mouse_event; + mouse_event.type = WebKit::WebInputEvent::MouseDown; + mouse_event.button = WebKit::WebMouseEvent::ButtonMiddle; + mouse_event.x = 7; + mouse_event.y = 7; + mouse_event.clickCount = 1; + TabContents* tab = browser()->GetSelectedTabContents(); + tab->render_view_host()->ForwardMouseEvent(mouse_event); + mouse_event.type = WebKit::WebInputEvent::MouseUp; + tab->render_view_host()->ForwardMouseEvent(mouse_event); + + ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); +} |