[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] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 7 | #include "base/path_service.h" |
Avi Drissman | 5f0fb8c | 2018-12-25 23:20:49 | [diff] [blame] | 8 | #include "base/stl_util.h" |
[email protected] | 46acbf1 | 2013-06-10 18:43:42 | [diff] [blame] | 9 | #include "base/strings/stringprintf.h" |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_apitest.h" |
[email protected] | 01996a59 | 2013-09-13 06:55:04 | [diff] [blame] | 12 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 2ad4a90 | 2010-11-17 06:05:13 | [diff] [blame] | 13 | #include "chrome/browser/ui/browser.h" |
[email protected] | d874814 | 2012-05-16 21:13:43 | [diff] [blame] | 14 | #include "chrome/browser/ui/browser_finder.h" |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame] | 15 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 16 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 17 | #include "chrome/common/chrome_paths.h" |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 18 | #include "chrome/common/url_constants.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 19 | #include "chrome/test/base/ui_test_utils.h" |
nick | 6cfe5c7 | 2017-05-22 22:00:42 | [diff] [blame] | 20 | #include "content/public/browser/navigation_entry.h" |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 21 | #include "content/public/browser/notification_service.h" |
| 22 | #include "content/public/browser/notification_types.h" |
| 23 | #include "content/public/browser/render_frame_host.h" |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 24 | #include "content/public/browser/render_process_host.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 25 | #include "content/public/browser/web_contents.h" |
[email protected] | 1dd66b7 | 2012-09-19 20:41:48 | [diff] [blame] | 26 | #include "content/public/common/result_codes.h" |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 27 | #include "content/public/common/url_constants.h" |
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 28 | #include "content/public/test/browser_test_utils.h" |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 29 | #include "content/public/test/test_navigation_observer.h" |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 30 | #include "extensions/browser/extension_host.h" |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 31 | #include "extensions/browser/process_manager.h" |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 32 | #include "extensions/common/constants.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 33 | #include "extensions/common/extension.h" |
lfg | 910f2f9 | 2014-09-19 05:31:09 | [diff] [blame] | 34 | #include "extensions/test/extension_test_message_listener.h" |
yoz | e8dc2f1 | 2014-09-09 23:16:32 | [diff] [blame] | 35 | #include "extensions/test/result_catcher.h" |
[email protected] | f2cb3cf | 2013-03-21 01:40:53 | [diff] [blame] | 36 | #include "net/dns/mock_host_resolver.h" |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 37 | #include "net/test/embedded_test_server/embedded_test_server.h" |
[email protected] | bc44f414 | 2013-02-12 06:15:56 | [diff] [blame] | 38 | #include "testing/gtest/include/gtest/gtest.h" |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 39 | #include "ui/base/base_window.h" |
| 40 | |
| 41 | #if defined(OS_CHROMEOS) |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 42 | #include "ash/public/cpp/window_pin_type.h" |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 43 | #include "ash/public/cpp/window_properties.h" |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 44 | #include "chrome/app/chrome_command_ids.h" |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 45 | #include "chrome/browser/extensions/window_controller.h" |
| 46 | #include "chrome/browser/extensions/window_controller_list.h" |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 47 | #include "chrome/browser/ui/browser_command_controller.h" |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 48 | #include "ui/aura/window.h" |
| 49 | #endif |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 50 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 51 | using content::OpenURLParams; |
| 52 | using content::Referrer; |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 53 | using content::WebContents; |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 54 | |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 55 | namespace aura { |
| 56 | class Window; |
| 57 | } |
| 58 | |
Devlin Cronin | 836f545d | 2018-05-09 00:25:05 | [diff] [blame] | 59 | namespace extensions { |
| 60 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 61 | class WindowOpenApiTest : public ExtensionApiTest { |
| 62 | void SetUpOnMainThread() override { |
| 63 | ExtensionApiTest::SetUpOnMainThread(); |
| 64 | host_resolver()->AddRule("*", "127.0.0.1"); |
| 65 | } |
| 66 | }; |
| 67 | |
rob | f8cd8ce | 2015-02-21 12:18:04 | [diff] [blame] | 68 | // The test uses the chrome.browserAction.openPopup API, which requires that the |
| 69 | // window can automatically be activated. |
| 70 | // See comments at BrowserActionInteractiveTest::ShouldRunPopupTest |
johnme | 7e30b51 | 2015-04-16 14:57:35 | [diff] [blame] | 71 | // Fails flakily on all platforms. https://crbug.com/477691 |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 72 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, DISABLED_WindowOpen) { |
yoz | e8dc2f1 | 2014-09-09 23:16:32 | [diff] [blame] | 73 | extensions::ResultCatcher catcher; |
[email protected] | 32b7c49 | 2010-09-01 04:15:00 | [diff] [blame] | 74 | ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ |
| 75 | .AppendASCII("window_open").AppendASCII("spanning"))); |
| 76 | EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 77 | } |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 78 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 79 | bool WaitForTabsPopupsApps(Browser* browser, |
| 80 | int num_tabs, |
| 81 | int num_popups, |
| 82 | int num_apps) { |
[email protected] | 58b349b | 2011-11-23 02:07:15 | [diff] [blame] | 83 | SCOPED_TRACE( |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 84 | base::StringPrintf("WaitForTabsPopupsApps tabs:%d, popups:%d, apps:%d", |
| 85 | num_tabs, num_popups, num_apps)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 86 | // We start with one tab and one browser already open. |
| 87 | ++num_tabs; |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 88 | size_t num_browsers = static_cast<size_t>(num_popups + num_apps) + 1; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 89 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 90 | const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(10); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 91 | base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; |
| 92 | while (base::TimeTicks::Now() < end_time) { |
scottmg | 34c5dd88 | 2016-02-03 05:21:54 | [diff] [blame] | 93 | if (chrome::GetBrowserCount(browser->profile()) == num_browsers && |
dimich | 566d364 | 2016-08-23 16:39:06 | [diff] [blame] | 94 | browser->tab_strip_model()->count() == num_tabs) |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 95 | break; |
| 96 | |
[email protected] | b8deecd | 2012-07-30 21:09:44 | [diff] [blame] | 97 | content::RunAllPendingInMessageLoop(); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 98 | } |
| 99 | |
scottmg | 34c5dd88 | 2016-02-03 05:21:54 | [diff] [blame] | 100 | EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser->profile())); |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 101 | EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 102 | |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 103 | int num_popups_seen = 0; |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 104 | int num_apps_seen = 0; |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame] | 105 | for (auto* b : *BrowserList::GetInstance()) { |
| 106 | if (b == browser) |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 107 | continue; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 108 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 109 | EXPECT_TRUE(b->is_type_popup() || b->is_type_app()); |
| 110 | if (b->is_type_popup()) |
| 111 | ++num_popups_seen; |
| 112 | else if (b->is_type_app()) |
| 113 | ++num_apps_seen; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 114 | } |
[email protected] | f9e82d9 | 2011-10-29 00:50:45 | [diff] [blame] | 115 | EXPECT_EQ(num_popups, num_popups_seen); |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 116 | EXPECT_EQ(num_apps, num_apps_seen); |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 117 | |
scottmg | 34c5dd88 | 2016-02-03 05:21:54 | [diff] [blame] | 118 | return ((num_browsers == chrome::GetBrowserCount(browser->profile())) && |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 119 | (num_tabs == browser->tab_strip_model()->count()) && |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 120 | (num_popups == num_popups_seen) && (num_apps == num_apps_seen)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 121 | } |
| 122 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 123 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, BrowserIsApp) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 124 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 125 | ASSERT_TRUE(LoadExtension( |
| 126 | test_data_dir_.AppendASCII("window_open").AppendASCII("browser_is_app"))); |
| 127 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 128 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 0, 0, 2)); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 129 | |
scottmg | 8abbff83 | 2016-01-28 22:57:37 | [diff] [blame] | 130 | for (auto* b : *BrowserList::GetInstance()) { |
| 131 | if (b == browser()) |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 132 | ASSERT_FALSE(b->is_type_app()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 133 | else |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 134 | ASSERT_TRUE(b->is_type_app()); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 138 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, WindowOpenPopupDefault) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 139 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 140 | ASSERT_TRUE(LoadExtension( |
| 141 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup"))); |
| 142 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 143 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 1, 0, 0)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 144 | } |
| 145 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 146 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, WindowOpenPopupIframe) { |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 147 | base::FilePath test_data_dir; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 148 | base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 149 | embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
martijn | f9b885b7 | 2016-11-22 22:03:47 | [diff] [blame] | 150 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 151 | ASSERT_TRUE(LoadExtension( |
| 152 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_iframe"))); |
| 153 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 154 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 1, 0, 0)); |
[email protected] | 7c6ef35 | 2013-09-26 07:23:14 | [diff] [blame] | 155 | } |
| 156 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 157 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, WindowOpenPopupLarge) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 158 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 159 | ASSERT_TRUE(LoadExtension( |
| 160 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_large"))); |
| 161 | |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 162 | // On other systems this should open a new popup window. |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 163 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 0, 0, 1)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 164 | } |
| 165 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 166 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, WindowOpenPopupSmall) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 167 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 168 | ASSERT_TRUE(LoadExtension( |
| 169 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_small"))); |
| 170 | |
| 171 | // On ChromeOS this should open a new panel (acts like a new popup window). |
| 172 | // On other systems this should open a new popup window. |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 173 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 0, 0, 1)); |
[email protected] | 0a5bdc652 | 2011-06-08 19:04:49 | [diff] [blame] | 174 | } |
| 175 | |
[email protected] | 73fa1fce | 2013-02-21 20:10:05 | [diff] [blame] | 176 | // Disabled on Windows. Often times out or fails: crbug.com/177530 |
| 177 | #if defined(OS_WIN) |
| 178 | #define MAYBE_PopupBlockingExtension DISABLED_PopupBlockingExtension |
| 179 | #else |
| 180 | #define MAYBE_PopupBlockingExtension PopupBlockingExtension |
| 181 | #endif |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 182 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, MAYBE_PopupBlockingExtension) { |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 183 | ASSERT_TRUE(StartEmbeddedTestServer()); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 184 | |
| 185 | ASSERT_TRUE(LoadExtension( |
| 186 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_blocking") |
| 187 | .AppendASCII("extension"))); |
| 188 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 189 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 5, 2, 1)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 190 | } |
| 191 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 192 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, PopupBlockingHostedApp) { |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 193 | ASSERT_TRUE(embedded_test_server()->Start()); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 194 | |
| 195 | ASSERT_TRUE(LoadExtension( |
| 196 | test_data_dir_.AppendASCII("window_open").AppendASCII("popup_blocking") |
| 197 | .AppendASCII("hosted_app"))); |
| 198 | |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 199 | // The app being tested owns the domain a.com . The test URLs we navigate |
| 200 | // to below must be within that domain, so that they fall within the app's |
| 201 | // web extent. |
| 202 | GURL::Replacements replace_host; |
mgiuca | 77752c3 | 2015-02-05 07:31:18 | [diff] [blame] | 203 | replace_host.SetHostStr("a.com"); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 204 | |
| 205 | const std::string popup_app_contents_path( |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 206 | "/extensions/api_test/window_open/popup_blocking/hosted_app/"); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 207 | |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 208 | GURL open_tab = embedded_test_server() |
| 209 | ->GetURL(popup_app_contents_path + "open_tab.html") |
| 210 | .ReplaceComponents(replace_host); |
| 211 | GURL open_popup = embedded_test_server() |
| 212 | ->GetURL(popup_app_contents_path + "open_popup.html") |
| 213 | .ReplaceComponents(replace_host); |
[email protected] | fe304887 | 2010-10-18 14:58:59 | [diff] [blame] | 214 | |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 215 | browser()->OpenURL(OpenURLParams(open_tab, Referrer(), |
| 216 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 217 | ui::PAGE_TRANSITION_TYPED, false)); |
| 218 | browser()->OpenURL(OpenURLParams(open_popup, Referrer(), |
| 219 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 220 | ui::PAGE_TRANSITION_TYPED, false)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 221 | |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 222 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 3, 1, 0)); |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 223 | } |
[email protected] | d4db6c70 | 2011-03-28 21:49:14 | [diff] [blame] | 224 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 225 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, WindowArgumentsOverflow) { |
[email protected] | e7f9056 | 2011-05-23 21:38:24 | [diff] [blame] | 226 | ASSERT_TRUE(RunExtensionTest("window_open/argument_overflow")) << message_; |
| 227 | } |
| 228 | |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 229 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, DISABLED_WindowOpener) { |
[email protected] | 54edcea | 2011-07-27 01:56:38 | [diff] [blame] | 230 | ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; |
| 231 | } |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 232 | |
[email protected] | fa7c160 | 2013-04-03 23:00:20 | [diff] [blame] | 233 | #if defined(OS_MACOSX) |
| 234 | // Extension popup windows are incorrectly sized on OSX, crbug.com/225601 |
| 235 | #define MAYBE_WindowOpenSized DISABLED_WindowOpenSized |
| 236 | #else |
| 237 | #define MAYBE_WindowOpenSized WindowOpenSized |
| 238 | #endif |
| 239 | // Ensure that the width and height properties of a window opened with |
| 240 | // chrome.windows.create match the creation parameters. See crbug.com/173831. |
jam | 1a5b558 | 2017-05-01 16:50:10 | [diff] [blame] | 241 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, MAYBE_WindowOpenSized) { |
[email protected] | fa7c160 | 2013-04-03 23:00:20 | [diff] [blame] | 242 | ASSERT_TRUE(RunExtensionTest("window_open/window_size")) << message_; |
Joel Hockey | 2687ab5 | 2019-08-14 23:59:46 | [diff] [blame] | 243 | EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 0, 0, 1)); |
[email protected] | fa7c160 | 2013-04-03 23:00:20 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 246 | // Tests that an extension page can call window.open to an extension URL and |
| 247 | // the new window has extension privileges. |
| 248 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { |
| 249 | ASSERT_TRUE(LoadExtension( |
| 250 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 251 | |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 252 | GURL start_url(std::string(extensions::kExtensionScheme) + |
[email protected] | fb4fe095 | 2014-06-05 09:44:24 | [diff] [blame] | 253 | url::kStandardSchemeSeparator + |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 254 | last_loaded_extension_id() + "/test.html"); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 255 | ui_test_utils::NavigateToURL(browser(), start_url); |
[email protected] | f3e73f6 | 2012-10-20 05:35:16 | [diff] [blame] | 256 | WebContents* newtab = NULL; |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 257 | ASSERT_NO_FATAL_FAILURE( |
| 258 | OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 259 | start_url.Resolve("newtab.html"), true, true, &newtab)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 260 | |
| 261 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 262 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", |
| 263 | &result)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 264 | EXPECT_TRUE(result); |
| 265 | } |
| 266 | |
| 267 | // Tests that if an extension page calls window.open to an invalid extension |
| 268 | // URL, the browser doesn't crash. |
| 269 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { |
nick | 6cfe5c7 | 2017-05-22 22:00:42 | [diff] [blame] | 270 | const extensions::Extension* extension = LoadExtension( |
| 271 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")); |
| 272 | ASSERT_TRUE(extension); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 273 | |
nick | 6cfe5c7 | 2017-05-22 22:00:42 | [diff] [blame] | 274 | GURL start_url = extension->GetResourceURL("/test.html"); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 275 | ui_test_utils::NavigateToURL(browser(), start_url); |
nick | 6cfe5c7 | 2017-05-22 22:00:42 | [diff] [blame] | 276 | WebContents* newtab = nullptr; |
Lukasz Anforowicz | fc41749 | 2019-09-25 19:53:28 | [diff] [blame] | 277 | bool new_page_in_same_process = false; |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 278 | bool expect_success = false; |
Lukasz Anforowicz | fc41749 | 2019-09-25 19:53:28 | [diff] [blame] | 279 | GURL broken_extension_url( |
| 280 | "chrome-extension://thisissurelynotavalidextensionid/newtab.html"); |
nick | 6cfe5c7 | 2017-05-22 22:00:42 | [diff] [blame] | 281 | ASSERT_NO_FATAL_FAILURE(OpenWindow( |
| 282 | browser()->tab_strip_model()->GetActiveWebContents(), |
Lukasz Anforowicz | fc41749 | 2019-09-25 19:53:28 | [diff] [blame] | 283 | broken_extension_url, new_page_in_same_process, expect_success, &newtab)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 284 | |
Lukasz Anforowicz | fc41749 | 2019-09-25 19:53:28 | [diff] [blame] | 285 | EXPECT_EQ(broken_extension_url, |
| 286 | newtab->GetMainFrame()->GetLastCommittedURL()); |
| 287 | EXPECT_EQ(content::PAGE_TYPE_ERROR, |
| 288 | newtab->GetController().GetLastCommittedEntry()->GetPageType()); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | // Tests that calling window.open from the newtab page to an extension URL |
| 292 | // gives the new window extension privileges - even though the opening page |
| 293 | // does not have extension privileges, we break the script connection, so |
| 294 | // there is no privilege leak. |
| 295 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { |
| 296 | ASSERT_TRUE(LoadExtension( |
| 297 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 298 | |
| 299 | ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
[email protected] | f3e73f6 | 2012-10-20 05:35:16 | [diff] [blame] | 300 | WebContents* newtab = NULL; |
[email protected] | e044887 | 2013-01-11 19:35:02 | [diff] [blame] | 301 | ASSERT_NO_FATAL_FAILURE( |
| 302 | OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 99bee64 | 2014-05-31 22:36:43 | [diff] [blame] | 303 | GURL(std::string(extensions::kExtensionScheme) + |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 304 | url::kStandardSchemeSeparator + |
| 305 | last_loaded_extension_id() + "/newtab.html"), |
| 306 | false, true, &newtab)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 307 | |
| 308 | // Extension API should succeed. |
| 309 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 310 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", |
| 311 | &result)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 312 | EXPECT_TRUE(result); |
| 313 | } |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 314 | |
| 315 | // Tests that calling window.open for an extension URL from a non-HTTP or HTTPS |
| 316 | // URL on a new tab cannot access non-web-accessible resources. |
| 317 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, |
| 318 | WindowOpenInaccessibleResourceFromDataURL) { |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 319 | const extensions::Extension* extension = LoadExtension( |
| 320 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")); |
| 321 | ASSERT_TRUE(extension); |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 322 | |
| 323 | ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,foo")); |
| 324 | |
| 325 | // test.html is not web-accessible and should not be loaded. |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 326 | GURL extension_url(extension->GetResourceURL("test.html")); |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 327 | content::WindowedNotificationObserver windowed_observer( |
| 328 | content::NOTIFICATION_LOAD_STOP, |
| 329 | content::NotificationService::AllSources()); |
| 330 | ASSERT_TRUE(content::ExecuteScript( |
| 331 | browser()->tab_strip_model()->GetActiveWebContents(), |
| 332 | "window.open('" + extension_url.spec() + "');")); |
| 333 | windowed_observer.Wait(); |
| 334 | content::NavigationController* controller = |
| 335 | content::Source<content::NavigationController>(windowed_observer.source()) |
| 336 | .ptr(); |
| 337 | content::WebContents* newtab = controller->GetWebContents(); |
| 338 | ASSERT_TRUE(newtab); |
| 339 | |
Lukasz Anforowicz | fc41749 | 2019-09-25 19:53:28 | [diff] [blame] | 340 | EXPECT_EQ(content::PAGE_TYPE_ERROR, |
| 341 | newtab->GetController().GetLastCommittedEntry()->GetPageType()); |
| 342 | EXPECT_EQ(extension_url, newtab->GetMainFrame()->GetLastCommittedURL()); |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 343 | EXPECT_FALSE(newtab->GetMainFrame()->GetSiteInstance()->GetSiteURL().SchemeIs( |
| 344 | extensions::kExtensionScheme)); |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 345 | } |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 346 | |
| 347 | // Test that navigating to an extension URL is allowed on chrome:// and |
| 348 | // chrome-search:// pages, even for URLs that are not web-accessible. |
| 349 | // See https://crbug.com/662602. |
| 350 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, |
Alex Moshchuk | 7c7368f | 2018-04-25 00:49:25 | [diff] [blame] | 351 | NavigateToInaccessibleResourceFromChromeURL) { |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 352 | // Mint an extension URL which is not web-accessible. |
| 353 | const extensions::Extension* extension = LoadExtension( |
| 354 | test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")); |
| 355 | ASSERT_TRUE(extension); |
| 356 | GURL extension_url(extension->GetResourceURL("test.html")); |
| 357 | |
| 358 | content::WebContents* tab = |
| 359 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 360 | |
| 361 | // Navigate to the non-web-accessible URL from chrome:// and |
| 362 | // chrome-search:// pages. Verify that the page loads correctly. |
| 363 | GURL history_url(chrome::kChromeUIHistoryURL); |
| 364 | GURL ntp_url(chrome::kChromeSearchLocalNtpUrl); |
| 365 | ASSERT_TRUE(history_url.SchemeIs(content::kChromeUIScheme)); |
| 366 | ASSERT_TRUE(ntp_url.SchemeIs(chrome::kChromeSearchScheme)); |
| 367 | GURL start_urls[] = {history_url, ntp_url}; |
Avi Drissman | 5f0fb8c | 2018-12-25 23:20:49 | [diff] [blame] | 368 | for (size_t i = 0; i < base::size(start_urls); i++) { |
alexmos | cf5145bb | 2016-11-09 23:19:45 | [diff] [blame] | 369 | ui_test_utils::NavigateToURL(browser(), start_urls[i]); |
| 370 | EXPECT_EQ(start_urls[i], tab->GetMainFrame()->GetLastCommittedURL()); |
| 371 | |
| 372 | content::TestNavigationObserver observer(tab); |
| 373 | ASSERT_TRUE(content::ExecuteScript( |
| 374 | tab, "location.href = '" + extension_url.spec() + "';")); |
| 375 | observer.Wait(); |
| 376 | EXPECT_EQ(extension_url, tab->GetMainFrame()->GetLastCommittedURL()); |
| 377 | std::string result; |
| 378 | ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 379 | tab, "domAutomationController.send(document.body.innerText)", &result)); |
| 380 | EXPECT_EQ("HOWDIE!!!", result); |
| 381 | } |
| 382 | } |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 383 | |
| 384 | #if defined(OS_CHROMEOS) |
| 385 | |
| 386 | namespace { |
| 387 | |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 388 | aura::Window* GetCurrentWindow() { |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 389 | extensions::WindowController* controller = nullptr; |
| 390 | for (auto* iter : |
| 391 | extensions::WindowControllerList::GetInstance()->windows()) { |
| 392 | if (iter->window()->IsActive()) { |
| 393 | controller = iter; |
| 394 | break; |
| 395 | } |
| 396 | } |
| 397 | EXPECT_TRUE(controller); |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 398 | return controller->window()->GetNativeWindow(); |
| 399 | } |
| 400 | |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 401 | ash::WindowPinType GetCurrentWindowPinType() { |
| 402 | ash::WindowPinType type = |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 403 | GetCurrentWindow()->GetProperty(ash::kWindowPinTypeKey); |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 404 | return type; |
| 405 | } |
| 406 | |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 407 | void SetCurrentWindowPinType(ash::WindowPinType type) { |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 408 | GetCurrentWindow()->SetProperty(ash::kWindowPinTypeKey, type); |
| 409 | } |
| 410 | |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 411 | } // namespace |
| 412 | |
| 413 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, OpenLockedFullscreenWindow) { |
| 414 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/with_permission", |
| 415 | "openLockedFullscreenWindow")) |
| 416 | << message_; |
| 417 | |
| 418 | // Make sure the newly created window is "trusted pinned" (which means that |
| 419 | // it's in locked fullscreen mode). |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 420 | EXPECT_EQ(ash::WindowPinType::kTrustedPinned, GetCurrentWindowPinType()); |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, UpdateWindowToLockedFullscreen) { |
| 424 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/with_permission", |
| 425 | "updateWindowToLockedFullscreen")) |
| 426 | << message_; |
| 427 | |
| 428 | // Make sure the current window is put into the "trusted pinned" state. |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 429 | EXPECT_EQ(ash::WindowPinType::kTrustedPinned, GetCurrentWindowPinType()); |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 430 | } |
| 431 | |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 432 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, RemoveLockedFullscreenFromWindow) { |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 433 | // After locking the window, do a LockedFullscreenStateChanged so the |
| 434 | // command_controller state catches up as well. |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 435 | SetCurrentWindowPinType(ash::WindowPinType::kTrustedPinned); |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 436 | browser()->command_controller()->LockedFullscreenStateChanged(); |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 437 | |
| 438 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/with_permission", |
| 439 | "removeLockedFullscreenFromWindow")) |
| 440 | << message_; |
| 441 | |
| 442 | // Make sure the current window is removed from locked-fullscreen state. |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 443 | EXPECT_EQ(ash::WindowPinType::kNone, GetCurrentWindowPinType()); |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 444 | } |
| 445 | |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 446 | // Make sure that commands disabling code works in locked fullscreen mode. |
| 447 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, VerifyCommandsInLockedFullscreen) { |
| 448 | // IDC_EXIT is always enabled in regular mode so it's a perfect candidate for |
| 449 | // testing. |
| 450 | EXPECT_TRUE(browser()->command_controller()->IsCommandEnabled(IDC_EXIT)); |
| 451 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/with_permission", |
| 452 | "updateWindowToLockedFullscreen")) |
| 453 | << message_; |
| 454 | |
Ivan Sandrk | 6ac9c9a | 2018-12-14 14:15:07 | [diff] [blame] | 455 | // IDC_EXIT should always be disabled in locked fullscreen. |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 456 | EXPECT_FALSE(browser()->command_controller()->IsCommandEnabled(IDC_EXIT)); |
| 457 | |
Ivan Sandrk | 6ac9c9a | 2018-12-14 14:15:07 | [diff] [blame] | 458 | // Some other disabled commands. |
| 459 | EXPECT_FALSE(browser()->command_controller()->IsCommandEnabled(IDC_FIND)); |
| 460 | EXPECT_FALSE( |
| 461 | browser()->command_controller()->IsCommandEnabled(IDC_ZOOM_PLUS)); |
| 462 | |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 463 | // Verify some whitelisted commands. |
| 464 | EXPECT_TRUE(browser()->command_controller()->IsCommandEnabled(IDC_COPY)); |
Ivan Sandrk | 6ac9c9a | 2018-12-14 14:15:07 | [diff] [blame] | 465 | EXPECT_TRUE(browser()->command_controller()->IsCommandEnabled(IDC_PASTE)); |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 466 | } |
| 467 | |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 468 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, |
| 469 | OpenLockedFullscreenWindowWithoutPermission) { |
| 470 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/without_permission", |
| 471 | "openLockedFullscreenWindow")) |
| 472 | << message_; |
| 473 | |
| 474 | // Make sure no new windows get created (so only the one created by default |
| 475 | // exists) since the call to chrome.windows.create fails on the javascript |
| 476 | // side. |
| 477 | EXPECT_EQ(1u, |
| 478 | extensions::WindowControllerList::GetInstance()->windows().size()); |
| 479 | } |
| 480 | |
| 481 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, |
| 482 | UpdateWindowToLockedFullscreenWithoutPermission) { |
| 483 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/without_permission", |
| 484 | "updateWindowToLockedFullscreen")) |
| 485 | << message_; |
| 486 | |
| 487 | // chrome.windows.update call fails since this extension doesn't have the |
| 488 | // correct permission and hence the current window has NONE as WindowPinType. |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 489 | EXPECT_EQ(ash::WindowPinType::kNone, GetCurrentWindowPinType()); |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, |
| 493 | RemoveLockedFullscreenFromWindowWithoutPermission) { |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 494 | SetCurrentWindowPinType(ash::WindowPinType::kTrustedPinned); |
Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 495 | browser()->command_controller()->LockedFullscreenStateChanged(); |
Ivan Sandrk | c9eb296 | 2017-11-16 15:35:10 | [diff] [blame] | 496 | |
| 497 | ASSERT_TRUE(RunExtensionTestWithArg("locked_fullscreen/without_permission", |
| 498 | "removeLockedFullscreenFromWindow")) |
| 499 | << message_; |
| 500 | |
| 501 | // The current window is still locked-fullscreen. |
Xiyuan Xia | 4f992f2 | 2019-06-05 15:33:46 | [diff] [blame] | 502 | EXPECT_EQ(ash::WindowPinType::kTrustedPinned, GetCurrentWindowPinType()); |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 503 | } |
| 504 | #endif // defined(OS_CHROMEOS) |
| 505 | |
| 506 | #if !defined(OS_CHROMEOS) |
| 507 | // Loading an extension requiring the 'lockWindowFullscreenPrivate' permission |
| 508 | // on non Chrome OS platforms should always fail since the API is available only |
| 509 | // on Chrome OS. |
| 510 | IN_PROC_BROWSER_TEST_F(WindowOpenApiTest, |
| 511 | OpenLockedFullscreenWindowNonChromeOS) { |
| 512 | const extensions::Extension* extension = LoadExtensionWithFlags( |
| 513 | test_data_dir_.AppendASCII("locked_fullscreen/with_permission"), |
David Bertoni | 4ec9371a | 2019-12-26 17:14:53 | [diff] [blame] | 514 | kFlagIgnoreManifestWarnings); |
Ivan Sandrk | c30341b | 2017-11-09 19:13:26 | [diff] [blame] | 515 | ASSERT_TRUE(extension); |
| 516 | EXPECT_EQ(1u, extension->install_warnings().size()); |
| 517 | EXPECT_EQ(std::string("'lockWindowFullscreenPrivate' " |
| 518 | "is not allowed for specified platform."), |
| 519 | extension->install_warnings().front().message); |
| 520 | } |
| 521 | #endif |
Devlin Cronin | 836f545d | 2018-05-09 00:25:05 | [diff] [blame] | 522 | |
| 523 | } // namespace extensions |