[email protected] | 35abc33 | 2012-02-24 23:48:38 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 5 | #include <stddef.h> |
| 6 | |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 7 | #include "base/command_line.h" |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 8 | #include "base/memory/scoped_vector.h" |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 9 | #include "base/path_service.h" |
[email protected] | 46acbf1 | 2013-06-10 18:43:42 | [diff] [blame] | 10 | #include "base/strings/stringprintf.h" |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 11 | #include "build/build_config.h" |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 12 | #include "chrome/browser/extensions/extension_apitest.h" |
[email protected] | 01996a59 | 2013-09-13 06:55:04 | [diff] [blame] | 13 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 2ad4a90 | 2010-11-17 06:05:13 | [diff] [blame] | 14 | #include "chrome/browser/ui/browser.h" |
[email protected] | d874814 | 2012-05-16 21:13:43 | [diff] [blame] | 15 | #include "chrome/browser/ui/browser_finder.h" |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame^] | 16 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | f6ffa7d | 2012-08-17 17:27:08 | [diff] [blame] | 17 | #include "chrome/browser/ui/panels/panel_manager.h" |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 18 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 19 | #include "chrome/common/chrome_paths.h" |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 20 | #include "chrome/common/chrome_switches.h" |
[email protected] | b65d4bdcc | 2013-07-31 00:37:33 | [diff] [blame] | 21 | #include "chrome/test/base/test_switches.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 22 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 23 | #include "content/public/browser/render_process_host.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 24 | #include "content/public/browser/web_contents.h" |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 25 | #include "content/public/common/result_codes.h" |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 26 | #include "content/public/common/url_constants.h" |
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 27 | #include "content/public/test/browser_test_utils.h" |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 28 | #include "extensions/browser/extension_host.h" |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 29 | #include "extensions/browser/process_manager.h" |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 30 | #include "extensions/common/constants.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 31 | #include "extensions/common/extension.h" |
[email protected] | c8d0299 | 2013-07-31 22:16:51 | [diff] [blame] | 32 | #include "extensions/common/switches.h" |
lfg | 910f2f9 | 2014-09-19 05:31:09 | [diff] [blame] | 33 | #include "extensions/test/extension_test_message_listener.h" |
yoz | e8dc2f1 | 2014-09-09 23:16:32 | [diff] [blame] | 34 | #include "extensions/test/result_catcher.h" |
[email protected] | f2cb3cf | 2013-03-21 01:40:53 | [diff] [blame] | 35 | #include "net/dns/mock_host_resolver.h" |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 36 | #include "net/test/embedded_test_server/embedded_test_server.h" |
[email protected] | bc44f414 | 2013-02-12 06:15:56 | [diff] [blame] | 37 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 38 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 39 | #if defined(USE_ASH) |
hashimoto | ad3c687 | 2014-08-29 09:46:57 | [diff] [blame] | 40 | #include "extensions/browser/app_window/app_window_registry.h" |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 41 | #endif |
| 42 | |
[email protected] | 1511930 | 2014-05-20 19:23:58 | [diff] [blame] | 43 | #if defined(USE_ASH) && defined(OS_CHROMEOS) |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 44 | // TODO(stevenjb): Figure out the correct behavior for Ash + Win |
| 45 | #define USE_ASH_PANELS |
| 46 | #endif |
| 47 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 48 | using content::OpenURLParams; |
| 49 | using content::Referrer; |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 50 | using content::WebContents; |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 51 | |
rob | f8cd8ce | 2015-02-21 12:18:04 | [diff] [blame] | 52 | // The test uses the chrome.browserAction.openPopup API, which requires that the |
| 53 | // window can automatically be activated. |
| 54 | // See comments at BrowserActionInteractiveTest::ShouldRunPopupTest |
johnme | 7e30b51 | 2015-04-16 14:57:35 | [diff] [blame] | 55 | // Fails flakily on all platforms. https://crbug.com/477691 |
| 56 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpen) { |
yoz | e8dc2f1 | 2014-09-09 23:16:32 | [diff] [blame] | 57 | extensions::ResultCatcher catcher; |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 58 | ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ |
| 59 | .AppendASCII("window_open").AppendASCII("spanning"))); |
| 60 | EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 61 | } |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 62 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 63 | int GetPanelCount(Browser* browser) { |
| 64 | #if defined(USE_ASH_PANELS) |
hashimoto | ad3c687 | 2014-08-29 09:46:57 | [diff] [blame] | 65 | return static_cast<int>(extensions::AppWindowRegistry::Get( |
| 66 | browser->profile())->app_windows().size()); |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 67 | #else |
| 68 | return PanelManager::GetInstance()->num_panels(); |
| 69 | #endif |
| 70 | } |
| 71 | |
| 72 | bool WaitForTabsAndPopups(Browser* browser, |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 73 | int num_tabs, |
| 74 | int num_popups, |
| 75 | int num_panels) { |
[email protected] | 58b349b | 2011-11-23 02:07:15 | [diff] [blame] | 76 | SCOPED_TRACE( |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 77 | base::StringPrintf("WaitForTabsAndPopups tabs:%d, popups:%d, panels:%d", |
| 78 | num_tabs, num_popups, num_panels)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 79 | // We start with one tab and one browser already open. |
| 80 | ++num_tabs; |
[email protected] | f6ffa7d | 2012-08-17 17:27:08 | [diff] [blame] | 81 | size_t num_browsers = static_cast<size_t>(num_popups) + 1; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 82 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 83 | const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(10); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 84 | base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; |
| 85 | while (base::TimeTicks::Now() < end_time) { |
[email protected] | c987a24 | 2013-02-28 01:17:41 | [diff] [blame] | 86 | if (chrome::GetBrowserCount(browser->profile(), |
| 87 | browser->host_desktop_type()) == num_browsers && |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 88 | browser->tab_strip_model()->count() == num_tabs && |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 89 | GetPanelCount(browser) == num_panels) |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 90 | break; |
| 91 | |
[email protected] | b8deecd | 2012-07-30 21:09:44 | [diff] [blame] | 92 | content::RunAllPendingInMessageLoop(); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 93 | } |
| 94 | |
[email protected] | c987a24 | 2013-02-28 01:17:41 | [diff] [blame] | 95 | EXPECT_EQ(num_browsers, |
| 96 | chrome::GetBrowserCount(browser->profile(), |
| 97 | browser->host_desktop_type())); |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 98 | EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 99 | EXPECT_EQ(num_panels, GetPanelCount(browser)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 100 | |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 101 | int num_popups_seen = 0; |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame^] | 102 | for (auto* b : *BrowserList::GetInstance()) { |
| 103 | if (b == browser) |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 104 | continue; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 105 | |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame^] | 106 | EXPECT_TRUE(b->is_type_popup()); |
[email protected] | f6ffa7d | 2012-08-17 17:27:08 | [diff] [blame] | 107 | ++num_popups_seen; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 108 | } |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 109 | EXPECT_EQ(num_popups, num_popups_seen); |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 110 | |
[email protected] | c987a24 | 2013-02-28 01:17:41 | [diff] [blame] | 111 | return ((num_browsers == |
| 112 | chrome::GetBrowserCount(browser->profile(), |
| 113 | browser->host_desktop_type())) && |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 114 | (num_tabs == browser->tab_strip_model()->count()) && |
| 115 | (num_panels == GetPanelCount(browser)) && |
| 116 | (num_popups == num_popups_seen)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 117 | } |
| 118 | |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 119 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserIsApp) { |
| 120 | host_resolver()->AddRule("a.com", "127.0.0.1"); |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 121 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 122 | ASSERT_TRUE(LoadExtension( |
| 123 | test_data_dir_.AppendASCII("window_open").AppendASCII("browser_is_app"))); |
| 124 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 125 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 2, 0)); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 126 | |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame^] | 127 | for (auto* b : *BrowserList::GetInstance()) { |
| 128 | if (b == browser()) |
| 129 | ASSERT_FALSE(b->is_app()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 130 | else |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame^] | 131 | ASSERT_TRUE(b->is_app()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 135 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupDefault) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 136 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 137 | ASSERT_TRUE(LoadExtension( |
| 138 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup"))); |
| 139 | |
| 140 | const int num_tabs = 1; |
| 141 | const int num_popups = 0; |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 142 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), num_tabs, num_popups, 0)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 143 | } |
| 144 | |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 145 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupIframe) { |
| 146 | ASSERT_TRUE(StartEmbeddedTestServer()); |
| 147 | base::FilePath test_data_dir; |
| 148 | PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 149 | embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
| 150 | ASSERT_TRUE(LoadExtension( |
| 151 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_iframe"))); |
| 152 | |
jochen | c5cfa64 | 2014-09-02 15:30:03 | [diff] [blame] | 153 | const int num_tabs = 1; |
| 154 | const int num_popups = 0; |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 155 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), num_tabs, num_popups, 0)); |
| 156 | } |
| 157 | |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 158 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupLarge) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 159 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 160 | ASSERT_TRUE(LoadExtension( |
| 161 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_large"))); |
| 162 | |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 163 | // On other systems this should open a new popup window. |
| 164 | const int num_tabs = 0; |
| 165 | const int num_popups = 1; |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 166 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), num_tabs, num_popups, 0)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupSmall) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 170 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 171 | ASSERT_TRUE(LoadExtension( |
| 172 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_small"))); |
| 173 | |
| 174 | // On ChromeOS this should open a new panel (acts like a new popup window). |
| 175 | // On other systems this should open a new popup window. |
| 176 | const int num_tabs = 0; |
| 177 | const int num_popups = 1; |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 178 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), num_tabs, num_popups, 0)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 179 | } |
| 180 | |
[email protected] | 73fa1fce | 2013-02-21 20:10:05 | [diff] [blame] | 181 | // Disabled on Windows. Often times out or fails: crbug.com/177530 |
| 182 | #if defined(OS_WIN) |
| 183 | #define MAYBE_PopupBlockingExtension DISABLED_PopupBlockingExtension |
| 184 | #else |
| 185 | #define MAYBE_PopupBlockingExtension PopupBlockingExtension |
| 186 | #endif |
| 187 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_PopupBlockingExtension) { |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 188 | host_resolver()->AddRule("*", "127.0.0.1"); |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 189 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 190 | |
| 191 | ASSERT_TRUE(LoadExtension( |
| 192 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_blocking") |
| 193 | .AppendASCII("extension"))); |
| 194 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 195 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 5, 3, 0)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PopupBlockingHostedApp) { |
| 199 | host_resolver()->AddRule("*", "127.0.0.1"); |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 200 | ASSERT_TRUE(embedded_test_server()->Start()); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 201 | |
| 202 | ASSERT_TRUE(LoadExtension( |
| 203 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_blocking") |
| 204 | .AppendASCII("hosted_app"))); |
| 205 | |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 206 | // The app being tested owns the domain a.com . The test URLs we navigate |
| 207 | // to below must be within that domain, so that they fall within the app's |
| 208 | // web extent. |
| 209 | GURL::Replacements replace_host; |
mgiuca | 77752c3 | 2015-02-05 07:31:18 | [diff] [blame] | 210 | replace_host.SetHostStr("a.com"); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 211 | |
| 212 | const std::string popup_app_contents_path( |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 213 | "/extensions/api_test/window_open/popup_blocking/hosted_app/"); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 214 | |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 215 | GURL open_tab = embedded_test_server() |
| 216 | ->GetURL(popup_app_contents_path + "open_tab.html") |
| 217 | .ReplaceComponents(replace_host); |
| 218 | GURL open_popup = embedded_test_server() |
| 219 | ->GetURL(popup_app_contents_path + "open_popup.html") |
| 220 | .ReplaceComponents(replace_host); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 221 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 222 | browser()->OpenURL(OpenURLParams( |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 223 | open_tab, Referrer(), NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 224 | false)); |
| 225 | browser()->OpenURL(OpenURLParams( |
| 226 | open_popup, Referrer(), NEW_FOREGROUND_TAB, |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 227 | ui::PAGE_TRANSITION_TYPED, false)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 228 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 229 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 3, 1, 0)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 230 | } |
[email protected] | d4db6c70 | 2011-03-28 21:49:14 | [diff] [blame] | 231 | |
[email protected] | e7f9056 | 2011-05-23 21:38:24 | [diff] [blame] | 232 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowArgumentsOverflow) { |
| 233 | ASSERT_TRUE(RunExtensionTest("window_open/argument_overflow")) << message_; |
| 234 | } |
| 235 | |
[email protected] | d5c1406 | 2011-10-27 00:02:13 | [diff] [blame] | 236 | class WindowOpenPanelDisabledTest : public ExtensionApiTest { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 237 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 08aa0c3 | 2011-04-11 22:18:37 | [diff] [blame] | 238 | ExtensionApiTest::SetUpCommandLine(command_line); |
[email protected] | 7e7a2809 | 2011-12-09 22:24:55 | [diff] [blame] | 239 | // TODO(jennb): Re-enable when panels are enabled by default. |
| 240 | // command_line->AppendSwitch(switches::kDisablePanels); |
[email protected] | 08aa0c3 | 2011-04-11 22:18:37 | [diff] [blame] | 241 | } |
| 242 | }; |
| 243 | |
[email protected] | 7e7a2809 | 2011-12-09 22:24:55 | [diff] [blame] | 244 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelDisabledTest, |
| 245 | DISABLED_WindowOpenPanelNotEnabled) { |
[email protected] | d5c1406 | 2011-10-27 00:02:13 | [diff] [blame] | 246 | ASSERT_TRUE(RunExtensionTest("window_open/panel_not_enabled")) << message_; |
| 247 | } |
| 248 | |
[email protected] | af6b5451 | 2011-12-14 06:11:21 | [diff] [blame] | 249 | class WindowOpenPanelTest : public ExtensionApiTest { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 250 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | af6b5451 | 2011-12-14 06:11:21 | [diff] [blame] | 251 | ExtensionApiTest::SetUpCommandLine(command_line); |
| 252 | command_line->AppendSwitch(switches::kEnablePanels); |
| 253 | } |
| 254 | }; |
| 255 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 256 | #if defined(USE_ASH_PANELS) |
[email protected] | 87d722a | 2012-07-12 15:38:33 | [diff] [blame] | 257 | // On Ash, this currently fails because we're currently opening new panel |
[email protected] | d101b0c | 2012-03-16 00:30:57 | [diff] [blame] | 258 | // windows as popup windows instead. |
[email protected] | e00ccc9 | 2012-11-01 17:32:30 | [diff] [blame] | 259 | #define MAYBE_WindowOpenPanel DISABLED_WindowOpenPanel |
[email protected] | d101b0c | 2012-03-16 00:30:57 | [diff] [blame] | 260 | #else |
| 261 | #define MAYBE_WindowOpenPanel WindowOpenPanel |
| 262 | #endif |
| 263 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanel) { |
[email protected] | 08aa0c3 | 2011-04-11 22:18:37 | [diff] [blame] | 264 | ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; |
| 265 | } |
[email protected] | 54edcea | 2011-07-27 01:56:38 | [diff] [blame] | 266 | |
lukasza | 43df859 | 2015-12-18 17:40:48 | [diff] [blame] | 267 | // Test verifying that panel-subframe can use window.open to find |
| 268 | // background-subframe (see the picture below). In other words, the test |
| 269 | // verifies that the everything on the picture below stays in the same |
| 270 | // BrowsingInstance. |
| 271 | // |
| 272 | // +-extension background page---+ +-panel-----------------------------+ |
| 273 | // | | | | |
| 274 | // | chrome.windows.create( | | +-panel-subframe----------------+ | |
| 275 | // | 'type':'panel') -------------> | | (foo.com) | | |
| 276 | // | | | | | | |
| 277 | // | +-background-subframe-+ | | | w = window.open(..., | | |
| 278 | // | | (foo.com) | | | | "background-subframe-name") | | |
| 279 | // | | | <--------------/ | | |
| 280 | // | +---------------------+ | | +-------------------------------+ | |
| 281 | // | | | | |
| 282 | // +-----------------------------+ +-----------------------------------+ |
| 283 | // |
| 284 | // See also crbug.com/568357 for more info / context. |
| 285 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, BrowsingInstanceTest) { |
| 286 | host_resolver()->AddRule("*", "127.0.0.1"); |
| 287 | ASSERT_TRUE(StartEmbeddedTestServer()); |
| 288 | |
| 289 | ASSERT_TRUE(RunExtensionTest("window_open/panel_browsing_instance")) |
| 290 | << message_; |
| 291 | } |
| 292 | |
[email protected] | a60837b | 2014-03-11 03:49:20 | [diff] [blame] | 293 | #if defined(USE_ASH_PANELS) || defined(OS_LINUX) |
[email protected] | ca29ed1 | 2012-09-06 09:10:50 | [diff] [blame] | 294 | // On Ash, this currently fails because we're currently opening new panel |
| 295 | // windows as popup windows instead. |
[email protected] | a60837b | 2014-03-11 03:49:20 | [diff] [blame] | 296 | // We're also failing on Linux-aura due to the panel is not opened in the |
| 297 | // right origin. |
[email protected] | cb1849e | 2013-07-08 21:12:53 | [diff] [blame] | 298 | #define MAYBE_WindowOpenPanelDetached DISABLED_WindowOpenPanelDetached |
| 299 | #else |
| 300 | #define MAYBE_WindowOpenPanelDetached WindowOpenPanelDetached |
| 301 | #endif |
| 302 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanelDetached) { |
[email protected] | ca29ed1 | 2012-09-06 09:10:50 | [diff] [blame] | 303 | ASSERT_TRUE(RunExtensionTest("window_open/panel_detached")) << message_; |
| 304 | } |
| 305 | |
[email protected] | 1511930 | 2014-05-20 19:23:58 | [diff] [blame] | 306 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 307 | // TODO(erg): Bring up ash http://crbug.com/300084 |
| 308 | #define MAYBE_CloseNonExtensionPanelsOnUninstall \ |
| 309 | DISABLED_CloseNonExtensionPanelsOnUninstall |
| 310 | #else |
| 311 | #define MAYBE_CloseNonExtensionPanelsOnUninstall \ |
| 312 | CloseNonExtensionPanelsOnUninstall |
| 313 | #endif |
[email protected] | af6b5451 | 2011-12-14 06:11:21 | [diff] [blame] | 314 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, |
[email protected] | 1511930 | 2014-05-20 19:23:58 | [diff] [blame] | 315 | MAYBE_CloseNonExtensionPanelsOnUninstall) { |
[email protected] | 45c6f672 | 2013-07-23 03:02:19 | [diff] [blame] | 316 | #if defined(OS_WIN) && defined(USE_ASH) |
| 317 | // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 318 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 319 | switches::kAshBrowserTests)) |
[email protected] | 45c6f672 | 2013-07-23 03:02:19 | [diff] [blame] | 320 | return; |
| 321 | #endif |
| 322 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 323 | #if defined(USE_ASH_PANELS) |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 324 | // On Ash, new panel windows open as popup windows instead. |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 325 | int num_popups, num_panels; |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 326 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 327 | switches::kEnablePanels)) { |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 328 | num_popups = 2; |
| 329 | num_panels = 2; |
| 330 | } else { |
| 331 | num_popups = 4; |
| 332 | num_panels = 0; |
| 333 | } |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 334 | #else |
| 335 | int num_popups = 2; |
| 336 | int num_panels = 2; |
| 337 | #endif |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 338 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 339 | |
| 340 | // Setup listeners to wait on strings we expect the extension pages to send. |
| 341 | std::vector<std::string> test_strings; |
| 342 | test_strings.push_back("content_tab"); |
| 343 | if (num_panels) |
| 344 | test_strings.push_back("content_panel"); |
| 345 | test_strings.push_back("content_popup"); |
| 346 | |
| 347 | ScopedVector<ExtensionTestMessageListener> listeners; |
| 348 | for (size_t i = 0; i < test_strings.size(); ++i) { |
| 349 | listeners.push_back( |
| 350 | new ExtensionTestMessageListener(test_strings[i], false)); |
| 351 | } |
| 352 | |
| 353 | const extensions::Extension* extension = LoadExtension( |
| 354 | test_data_dir_.AppendASCII("window_open").AppendASCII( |
| 355 | "close_panels_on_uninstall")); |
| 356 | ASSERT_TRUE(extension); |
| 357 | |
| 358 | // Two tabs. One in extension domain and one in non-extension domain. |
| 359 | // Two popups - one in extension domain and one in non-extension domain. |
| 360 | // Two panels - one in extension domain and one in non-extension domain. |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 361 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 2, num_popups, num_panels)); |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 362 | |
| 363 | // Wait on test messages to make sure the pages loaded. |
| 364 | for (size_t i = 0; i < listeners.size(); ++i) |
| 365 | ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); |
| 366 | |
| 367 | UninstallExtension(extension->id()); |
| 368 | |
| 369 | // Wait for the tabs and popups in non-extension domain to stay open. |
| 370 | // Expect everything else, including panels, to close. |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 371 | num_popups -= 1; |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 372 | #if defined(USE_ASH_PANELS) |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 373 | if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 374 | switches::kEnablePanels)) { |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 375 | // On Ash, new panel windows open as popup windows instead, so there are 2 |
| 376 | // extension domain popups that will close (instead of 1 popup on non-Ash). |
| 377 | num_popups -= 1; |
| 378 | } |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 379 | #endif |
[email protected] | 9111fff | 2013-06-12 18:01:55 | [diff] [blame] | 380 | #if defined(USE_ASH) |
| 381 | #if !defined(OS_WIN) |
| 382 | // On linux ash we close all popup applications when closing its extension. |
| 383 | num_popups = 0; |
| 384 | #endif |
| 385 | #endif |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 386 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 1, num_popups, 0)); |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 387 | } |
| 388 | |
[email protected] | 1511930 | 2014-05-20 19:23:58 | [diff] [blame] | 389 | // This test isn't applicable on Chrome OS, which automatically reloads crashed |
| 390 | // pages. |
[email protected] | 4ad85f4 | 2013-07-24 02:31:57 | [diff] [blame] | 391 | #if !defined(OS_CHROMEOS) |
| 392 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, ClosePanelsOnExtensionCrash) { |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 393 | #if defined(USE_ASH_PANELS) |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 394 | // On Ash, new panel windows open as popup windows instead. |
| 395 | int num_popups = 4; |
| 396 | int num_panels = 0; |
| 397 | #else |
| 398 | int num_popups = 2; |
| 399 | int num_panels = 2; |
| 400 | #endif |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 401 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 4cdd857 | 2013-02-15 00:33:25 | [diff] [blame] | 402 | |
| 403 | // Setup listeners to wait on strings we expect the extension pages to send. |
| 404 | std::vector<std::string> test_strings; |
| 405 | test_strings.push_back("content_tab"); |
| 406 | if (num_panels) |
| 407 | test_strings.push_back("content_panel"); |
| 408 | test_strings.push_back("content_popup"); |
| 409 | |
| 410 | ScopedVector<ExtensionTestMessageListener> listeners; |
| 411 | for (size_t i = 0; i < test_strings.size(); ++i) { |
| 412 | listeners.push_back( |
| 413 | new ExtensionTestMessageListener(test_strings[i], false)); |
| 414 | } |
| 415 | |
| 416 | const extensions::Extension* extension = LoadExtension( |
| 417 | test_data_dir_.AppendASCII("window_open").AppendASCII( |
| 418 | "close_panels_on_uninstall")); |
| 419 | ASSERT_TRUE(extension); |
| 420 | |
| 421 | // Two tabs. One in extension domain and one in non-extension domain. |
| 422 | // Two popups - one in extension domain and one in non-extension domain. |
| 423 | // Two panels - one in extension domain and one in non-extension domain. |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 424 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 2, num_popups, num_panels)); |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 425 | |
| 426 | // Wait on test messages to make sure the pages loaded. |
| 427 | for (size_t i = 0; i < listeners.size(); ++i) |
| 428 | ASSERT_TRUE(listeners[i]->WaitUntilSatisfied()); |
| 429 | |
| 430 | // Crash the extension. |
| 431 | extensions::ExtensionHost* extension_host = |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 432 | extensions::ProcessManager::Get(browser()->profile()) |
| 433 | ->GetBackgroundHostForExtension(extension->id()); |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 434 | ASSERT_TRUE(extension_host); |
jaekyun | 37e572a3 | 2014-12-04 23:33:35 | [diff] [blame] | 435 | extension_host->render_process_host()->Shutdown(content::RESULT_CODE_KILLED, |
| 436 | false); |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 437 | WaitForExtensionCrash(extension->id()); |
| 438 | |
| 439 | // Only expect panels to close. The rest stay open to show a sad-tab. |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 440 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 2, num_popups, 0)); |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 441 | } |
[email protected] | 4ad85f4 | 2013-07-24 02:31:57 | [diff] [blame] | 442 | #endif // !defined(OS_CHROMEOS) |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 443 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 444 | #if defined(USE_ASH_PANELS) |
| 445 | // This test is not applicable on Ash. The modified window.open behavior only |
| 446 | // applies to non-Ash panel windows. |
[email protected] | 99f4fdb9 | 2012-08-30 23:13:51 | [diff] [blame] | 447 | #define MAYBE_WindowOpenFromPanel DISABLED_WindowOpenFromPanel |
| 448 | #else |
| 449 | #define MAYBE_WindowOpenFromPanel WindowOpenFromPanel |
| 450 | #endif |
| 451 | IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenFromPanel) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 452 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 6798c33 | 2012-08-29 02:16:51 | [diff] [blame] | 453 | |
[email protected] | 99f4fdb9 | 2012-08-30 23:13:51 | [diff] [blame] | 454 | // Load the extension that will open a panel which then calls window.open. |
[email protected] | 6798c33 | 2012-08-29 02:16:51 | [diff] [blame] | 455 | ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("window_open"). |
| 456 | AppendASCII("panel_window_open"))); |
[email protected] | 99f4fdb9 | 2012-08-30 23:13:51 | [diff] [blame] | 457 | |
| 458 | // Expect one panel (opened by extension) and one tab (from the panel calling |
| 459 | // window.open). Panels modify the WindowOpenDisposition in window.open |
| 460 | // to always open in a tab. |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 461 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 1, 0, 1)); |
[email protected] | 6798c33 | 2012-08-29 02:16:51 | [diff] [blame] | 462 | } |
| 463 | |
[email protected] | 24c6bcfc | 2012-02-29 21:06:36 | [diff] [blame] | 464 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { |
[email protected] | 54edcea | 2011-07-27 01:56:38 | [diff] [blame] | 465 | ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; |
| 466 | } |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 467 | |
[email protected] | fa7c160 | 2013-04-03 23:00:20 | [diff] [blame] | 468 | #if defined(OS_MACOSX) |
| 469 | // Extension popup windows are incorrectly sized on OSX, crbug.com/225601 |
| 470 | #define MAYBE_WindowOpenSized DISABLED_WindowOpenSized |
| 471 | #else |
| 472 | #define MAYBE_WindowOpenSized WindowOpenSized |
| 473 | #endif |
| 474 | // Ensure that the width and height properties of a window opened with |
| 475 | // chrome.windows.create match the creation parameters. See crbug.com/173831. |
| 476 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WindowOpenSized) { |
| 477 | ASSERT_TRUE(RunExtensionTest("window_open/window_size")) << message_; |
| 478 | EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 1, 0)); |
| 479 | } |
| 480 | |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 481 | // Tests that an extension page can call window.open to an extension URL and |
| 482 | // the new window has extension privileges. |
| 483 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { |
| 484 | ASSERT_TRUE(LoadExtension( |
| 485 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 486 | |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 487 | GURL start_url(std::string(extensions::kExtensionScheme) + |
[email protected] | fb4fe095 | 2014-06-05 09:44:24 | [diff] [blame] | 488 | url::kStandardSchemeSeparator + |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 489 | last_loaded_extension_id() + "/test.html"); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 490 | ui_test_utils::NavigateToURL(browser(), start_url); |
[email protected] | f3e73f6 | 2012-10-20 05:35:16 | [diff] [blame] | 491 | WebContents* newtab = NULL; |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 492 | ASSERT_NO_FATAL_FAILURE( |
| 493 | OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), |
| 494 | start_url.Resolve("newtab.html"), true, &newtab)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 495 | |
| 496 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 497 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", |
| 498 | &result)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 499 | EXPECT_TRUE(result); |
| 500 | } |
| 501 | |
| 502 | // Tests that if an extension page calls window.open to an invalid extension |
| 503 | // URL, the browser doesn't crash. |
| 504 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { |
| 505 | ASSERT_TRUE(LoadExtension( |
| 506 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 507 | |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 508 | GURL start_url(std::string(extensions::kExtensionScheme) + |
[email protected] | fb4fe095 | 2014-06-05 09:44:24 | [diff] [blame] | 509 | url::kStandardSchemeSeparator + |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 510 | last_loaded_extension_id() + "/test.html"); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 511 | ui_test_utils::NavigateToURL(browser(), start_url); |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 512 | ASSERT_NO_FATAL_FAILURE( |
| 513 | OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 514 | GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"), |
| 515 | false, NULL)); |
| 516 | |
| 517 | // If we got to this point, we didn't crash, so we're good. |
| 518 | } |
| 519 | |
| 520 | // Tests that calling window.open from the newtab page to an extension URL |
| 521 | // gives the new window extension privileges - even though the opening page |
| 522 | // does not have extension privileges, we break the script connection, so |
| 523 | // there is no privilege leak. |
| 524 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { |
| 525 | ASSERT_TRUE(LoadExtension( |
| 526 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 527 | |
| 528 | ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
[email protected] | f3e73f6 | 2012-10-20 05:35:16 | [diff] [blame] | 529 | WebContents* newtab = NULL; |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 530 | ASSERT_NO_FATAL_FAILURE( |
| 531 | OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 532 | GURL(std::string(extensions::kExtensionScheme) + |
[email protected] | fb4fe095 | 2014-06-05 09:44:24 | [diff] [blame] | 533 | url::kStandardSchemeSeparator + |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 534 | last_loaded_extension_id() + "/newtab.html"), |
| 535 | false, |
| 536 | &newtab)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 537 | |
| 538 | // Extension API should succeed. |
| 539 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 540 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", |
| 541 | &result)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 542 | EXPECT_TRUE(result); |
| 543 | } |