OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/pattern.h" | 11 #include "base/strings/pattern.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/apps/app_browsertest_util.h" |
16 #include "chrome/browser/devtools/devtools_window_testing.h" | 17 #include "chrome/browser/devtools/devtools_window_testing.h" |
17 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 18 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
18 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 19 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
19 #include "chrome/browser/extensions/extension_apitest.h" | 20 #include "chrome/browser/extensions/extension_apitest.h" |
20 #include "chrome/browser/extensions/extension_function_test_utils.h" | 21 #include "chrome/browser/extensions/extension_function_test_utils.h" |
21 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
22 #include "chrome/browser/extensions/window_controller.h" | 23 #include "chrome/browser/extensions/window_controller.h" |
23 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 24 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 30 #include "chrome/browser/ui/views/frame/browser_view.h" |
29 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 31 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
30 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
31 #include "content/public/browser/browser_context.h" | 33 #include "content/public/browser/browser_context.h" |
32 #include "content/public/browser/storage_partition.h" | 34 #include "content/public/browser/storage_partition.h" |
33 #include "content/public/common/page_zoom.h" | 35 #include "content/public/common/page_zoom.h" |
34 #include "content/public/common/url_constants.h" | 36 #include "content/public/common/url_constants.h" |
35 #include "extensions/browser/api_test_utils.h" | 37 #include "extensions/browser/api_test_utils.h" |
| 38 #include "extensions/browser/app_window/app_window.h" |
| 39 #include "extensions/browser/app_window/app_window_registry.h" |
| 40 #include "extensions/browser/app_window/native_app_window.h" |
36 #include "extensions/common/manifest_constants.h" | 41 #include "extensions/common/manifest_constants.h" |
37 #include "extensions/common/test_util.h" | 42 #include "extensions/common/test_util.h" |
38 #include "extensions/test/extension_test_message_listener.h" | 43 #include "extensions/test/extension_test_message_listener.h" |
39 #include "extensions/test/result_catcher.h" | 44 #include "extensions/test/result_catcher.h" |
40 #include "net/test/spawned_test_server/spawned_test_server.h" | 45 #include "net/test/spawned_test_server/spawned_test_server.h" |
41 #include "ui/gfx/geometry/rect.h" | 46 #include "ui/gfx/geometry/rect.h" |
| 47 #include "ui/views/widget/widget.h" |
| 48 #include "ui/views/widget/widget_observer.h" |
42 | 49 |
43 namespace extensions { | 50 namespace extensions { |
44 | 51 |
45 namespace keys = tabs_constants; | 52 namespace keys = tabs_constants; |
46 namespace utils = extension_function_test_utils; | 53 namespace utils = extension_function_test_utils; |
47 | 54 |
48 namespace { | 55 namespace { |
49 using ExtensionTabsTest = ExtensionApiTest; | 56 using ExtensionTabsTest = PlatformAppBrowserTest; |
50 | 57 |
51 class ExtensionWindowCreateTest : public InProcessBrowserTest { | 58 class ExtensionWindowCreateTest : public InProcessBrowserTest { |
52 public: | 59 public: |
53 // Runs chrome.windows.create(), expecting an error. | 60 // Runs chrome.windows.create(), expecting an error. |
54 std::string RunCreateWindowExpectError(const std::string& args) { | 61 std::string RunCreateWindowExpectError(const std::string& args) { |
55 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction); | 62 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction); |
56 function->set_extension(test_util::CreateEmptyExtension().get()); | 63 function->set_extension(test_util::CreateEmptyExtension().get()); |
57 return api_test_utils::RunFunctionAndReturnError(function.get(), args, | 64 return api_test_utils::RunFunctionAndReturnError(function.get(), args, |
58 browser()->profile()); | 65 browser()->profile()); |
59 } | 66 } |
(...skipping 17 matching lines...) Expand all Loading... |
77 | 84 |
78 int GetWindowId(base::DictionaryValue* window) { | 85 int GetWindowId(base::DictionaryValue* window) { |
79 int id = kUndefinedId; | 86 int id = kUndefinedId; |
80 if (window) | 87 if (window) |
81 window->GetInteger(keys::kIdKey, &id); | 88 window->GetInteger(keys::kIdKey, &id); |
82 return id; | 89 return id; |
83 } | 90 } |
84 | 91 |
85 } // namespace | 92 } // namespace |
86 | 93 |
87 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, WindowTypes) { | |
88 Browser* normal_browser = new Browser(Browser::CreateParams( | |
89 browser()->profile(), browser()->host_desktop_type())); | |
90 EXPECT_EQ(keys::kWindowTypeValueNormal, | |
91 normal_browser->extension_window_controller()->GetWindowTypeText()); | |
92 | |
93 Browser* popup_browser = new Browser( | |
94 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), | |
95 browser()->host_desktop_type())); | |
96 EXPECT_EQ(keys::kWindowTypeValuePopup, | |
97 popup_browser->extension_window_controller()->GetWindowTypeText()); | |
98 | |
99 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( | |
100 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); | |
101 EXPECT_EQ(keys::kWindowTypeValueDevTools, DevToolsWindowTesting::Get(devtools) | |
102 ->browser() | |
103 ->extension_window_controller() | |
104 ->GetWindowTypeText()); | |
105 } | |
106 | |
107 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { | 94 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { |
108 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 95 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
109 | 96 |
110 // Invalid window ID error. | 97 // Invalid window ID error. |
111 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); | 98 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); |
112 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 99 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
113 function->set_extension(extension.get()); | 100 function->set_extension(extension.get()); |
114 EXPECT_TRUE(base::MatchPattern( | 101 EXPECT_TRUE(base::MatchPattern( |
115 utils::RunFunctionAndReturnError( | 102 utils::RunFunctionAndReturnError( |
116 function.get(), base::StringPrintf("[%u]", window_id + 1), browser()), | 103 function.get(), base::StringPrintf("[%u]", window_id + 1), browser()), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // With "include_incognito". | 183 // With "include_incognito". |
197 function = new WindowsGetFunction(); | 184 function = new WindowsGetFunction(); |
198 function->set_extension(extension.get()); | 185 function->set_extension(extension.get()); |
199 result.reset(utils::ToDictionary( | 186 result.reset(utils::ToDictionary( |
200 utils::RunFunctionAndReturnSingleResult( | 187 utils::RunFunctionAndReturnSingleResult( |
201 function.get(), | 188 function.get(), |
202 base::StringPrintf("[%u]", incognito_window_id), | 189 base::StringPrintf("[%u]", incognito_window_id), |
203 browser(), | 190 browser(), |
204 utils::INCLUDE_INCOGNITO))); | 191 utils::INCLUDE_INCOGNITO))); |
205 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "incognito")); | 192 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "incognito")); |
| 193 |
| 194 // DevTools window. |
| 195 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 196 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
| 197 |
| 198 function = new WindowsGetFunction(); |
| 199 function->set_extension(extension.get()); |
| 200 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 201 function.get(), |
| 202 base::StringPrintf("[%u, {\"windowTypes\": [\"devtools\"]}]", |
| 203 ExtensionTabUtil::GetWindowId( |
| 204 DevToolsWindowTesting::Get(devtools)->browser())), |
| 205 browser(), utils::INCLUDE_INCOGNITO))); |
| 206 EXPECT_EQ("devtools", api_test_utils::GetString(result.get(), "type")); |
| 207 |
| 208 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
206 } | 209 } |
207 | 210 |
208 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { | 211 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { |
209 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 212 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
210 Browser* new_browser = CreateBrowser(browser()->profile()); | 213 Browser* new_browser = CreateBrowser(browser()->profile()); |
211 int new_id = ExtensionTabUtil::GetWindowId(new_browser); | 214 int new_id = ExtensionTabUtil::GetWindowId(new_browser); |
212 | 215 |
213 // Get the current window using new_browser. | 216 // Get the current window using new_browser. |
214 scoped_refptr<WindowsGetCurrentFunction> function = | 217 scoped_refptr<WindowsGetCurrentFunction> function = |
215 new WindowsGetCurrentFunction(); | 218 new WindowsGetCurrentFunction(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 const size_t NUM_WINDOWS = 5; | 253 const size_t NUM_WINDOWS = 5; |
251 std::set<int> window_ids; | 254 std::set<int> window_ids; |
252 std::set<int> result_ids; | 255 std::set<int> result_ids; |
253 window_ids.insert(ExtensionTabUtil::GetWindowId(browser())); | 256 window_ids.insert(ExtensionTabUtil::GetWindowId(browser())); |
254 | 257 |
255 for (size_t i = 0; i < NUM_WINDOWS - 1; ++i) { | 258 for (size_t i = 0; i < NUM_WINDOWS - 1; ++i) { |
256 Browser* new_browser = CreateBrowser(browser()->profile()); | 259 Browser* new_browser = CreateBrowser(browser()->profile()); |
257 window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); | 260 window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); |
258 } | 261 } |
259 | 262 |
260 // Undocked DevTools window should not be accessible. | 263 // Application windows should not be accessible, unless allWindowTypes is set |
| 264 // to true. |
| 265 AppWindow* app_window = CreateTestAppWindow("{}"); |
| 266 |
| 267 // Undocked DevTools window should not be accessible, unless allWindowTypes is |
| 268 // set to true. |
261 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( | 269 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
262 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); | 270 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
263 | 271 |
264 scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); | 272 scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); |
265 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 273 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
266 function->set_extension(extension.get()); | 274 function->set_extension(extension.get()); |
267 scoped_ptr<base::ListValue> result(utils::ToList( | 275 scoped_ptr<base::ListValue> result(utils::ToList( |
268 utils::RunFunctionAndReturnSingleResult(function.get(), | 276 utils::RunFunctionAndReturnSingleResult(function.get(), |
269 "[]", | 277 "[]", |
270 browser()))); | 278 browser()))); |
271 | 279 |
272 base::ListValue* windows = result.get(); | 280 base::ListValue* windows = result.get(); |
273 EXPECT_EQ(NUM_WINDOWS, windows->GetSize()); | 281 EXPECT_EQ(window_ids.size(), windows->GetSize()); |
274 for (size_t i = 0; i < NUM_WINDOWS; ++i) { | 282 for (size_t i = 0; i < windows->GetSize(); ++i) { |
275 base::DictionaryValue* result_window = nullptr; | 283 base::DictionaryValue* result_window = nullptr; |
276 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); | 284 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); |
277 result_ids.insert(GetWindowId(result_window)); | 285 result_ids.insert(GetWindowId(result_window)); |
278 | 286 |
279 // "populate" was not passed in so tabs are not populated. | 287 // "populate" was not passed in so tabs are not populated. |
280 base::ListValue* tabs = nullptr; | 288 base::ListValue* tabs = nullptr; |
281 EXPECT_FALSE(result_window->GetList(keys::kTabsKey, &tabs)); | 289 EXPECT_FALSE(result_window->GetList(keys::kTabsKey, &tabs)); |
282 } | 290 } |
283 // The returned ids should contain all the current browser instance ids. | 291 // The returned ids should contain all the current browser instance ids. |
284 EXPECT_EQ(window_ids, result_ids); | 292 EXPECT_EQ(window_ids, result_ids); |
285 | 293 |
286 result_ids.clear(); | 294 result_ids.clear(); |
287 function = new WindowsGetAllFunction(); | 295 function = new WindowsGetAllFunction(); |
288 function->set_extension(extension.get()); | 296 function->set_extension(extension.get()); |
289 result.reset(utils::ToList( | 297 result.reset(utils::ToList( |
290 utils::RunFunctionAndReturnSingleResult(function.get(), | 298 utils::RunFunctionAndReturnSingleResult(function.get(), |
291 "[{\"populate\": true}]", | 299 "[{\"populate\": true}]", |
292 browser()))); | 300 browser()))); |
293 | 301 |
294 windows = result.get(); | 302 windows = result.get(); |
295 EXPECT_EQ(NUM_WINDOWS, windows->GetSize()); | 303 EXPECT_EQ(window_ids.size(), windows->GetSize()); |
296 for (size_t i = 0; i < windows->GetSize(); ++i) { | 304 for (size_t i = 0; i < windows->GetSize(); ++i) { |
297 base::DictionaryValue* result_window = nullptr; | 305 base::DictionaryValue* result_window = nullptr; |
298 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); | 306 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); |
299 result_ids.insert(GetWindowId(result_window)); | 307 result_ids.insert(GetWindowId(result_window)); |
300 | 308 |
301 // "populate" was enabled so tabs should be populated. | 309 // "populate" was enabled so tabs should be populated. |
302 base::ListValue* tabs = nullptr; | 310 base::ListValue* tabs = nullptr; |
303 EXPECT_TRUE(result_window->GetList(keys::kTabsKey, &tabs)); | 311 EXPECT_TRUE(result_window->GetList(keys::kTabsKey, &tabs)); |
304 } | 312 } |
305 // The returned ids should contain all the current browser instance ids. | 313 // The returned ids should contain all the current app, browser and |
| 314 // devtools instance ids. |
306 EXPECT_EQ(window_ids, result_ids); | 315 EXPECT_EQ(window_ids, result_ids); |
307 | 316 |
308 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); | 317 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 318 |
| 319 CloseAppWindow(app_window); |
| 320 } |
| 321 |
| 322 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindowsAllTypes) { |
| 323 const size_t NUM_WINDOWS = 5; |
| 324 std::set<int> window_ids; |
| 325 std::set<int> result_ids; |
| 326 window_ids.insert(ExtensionTabUtil::GetWindowId(browser())); |
| 327 |
| 328 for (size_t i = 0; i < NUM_WINDOWS - 1; ++i) { |
| 329 Browser* new_browser = CreateBrowser(browser()->profile()); |
| 330 window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); |
| 331 } |
| 332 |
| 333 // Application windows should be accessible. |
| 334 AppWindow* app_window = CreateTestAppWindow("{}"); |
| 335 window_ids.insert(app_window->session_id().id()); |
| 336 |
| 337 // Undocked DevTools window should be accessible too. |
| 338 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 339 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
| 340 window_ids.insert(ExtensionTabUtil::GetWindowId( |
| 341 DevToolsWindowTesting::Get(devtools)->browser())); |
| 342 |
| 343 scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); |
| 344 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
| 345 function->set_extension(extension.get()); |
| 346 scoped_ptr<base::ListValue> result( |
| 347 utils::ToList(utils::RunFunctionAndReturnSingleResult( |
| 348 function.get(), |
| 349 "[{\"windowTypes\": [\"app\", \"devtools\", \"normal\", \"panel\", " |
| 350 "\"popup\"]}]", |
| 351 browser()))); |
| 352 |
| 353 base::ListValue* windows = result.get(); |
| 354 EXPECT_EQ(window_ids.size(), windows->GetSize()); |
| 355 for (size_t i = 0; i < windows->GetSize(); ++i) { |
| 356 base::DictionaryValue* result_window = nullptr; |
| 357 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); |
| 358 result_ids.insert(GetWindowId(result_window)); |
| 359 |
| 360 // "populate" was not passed in so tabs are not populated. |
| 361 base::ListValue* tabs = nullptr; |
| 362 EXPECT_FALSE(result_window->GetList(keys::kTabsKey, &tabs)); |
| 363 } |
| 364 // The returned ids should contain all the current app, browser and |
| 365 // devtools instance ids. |
| 366 EXPECT_EQ(window_ids, result_ids); |
| 367 |
| 368 result_ids.clear(); |
| 369 function = new WindowsGetAllFunction(); |
| 370 function->set_extension(extension.get()); |
| 371 result.reset(utils::ToList(utils::RunFunctionAndReturnSingleResult( |
| 372 function.get(), |
| 373 "[{\"populate\": true, \"windowTypes\": [\"app\", \"devtools\", " |
| 374 "\"normal\", \"panel\", \"popup\"]}]", |
| 375 browser()))); |
| 376 |
| 377 windows = result.get(); |
| 378 EXPECT_EQ(window_ids.size(), windows->GetSize()); |
| 379 for (size_t i = 0; i < windows->GetSize(); ++i) { |
| 380 base::DictionaryValue* result_window = nullptr; |
| 381 EXPECT_TRUE(windows->GetDictionary(i, &result_window)); |
| 382 result_ids.insert(GetWindowId(result_window)); |
| 383 |
| 384 // "populate" was enabled so tabs should be populated. |
| 385 base::ListValue* tabs = nullptr; |
| 386 EXPECT_TRUE(result_window->GetList(keys::kTabsKey, &tabs)); |
| 387 } |
| 388 // The returned ids should contain all the current app, browser and |
| 389 // devtools instance ids. |
| 390 EXPECT_EQ(window_ids, result_ids); |
| 391 |
| 392 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 393 |
| 394 CloseAppWindow(app_window); |
309 } | 395 } |
310 | 396 |
311 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { | 397 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { |
312 // The test empty extension has no permissions, therefore it should not get | 398 // The test empty extension has no permissions, therefore it should not get |
313 // tab data in the function result. | 399 // tab data in the function result. |
314 scoped_refptr<TabsUpdateFunction> update_tab_function( | 400 scoped_refptr<TabsUpdateFunction> update_tab_function( |
315 new TabsUpdateFunction()); | 401 new TabsUpdateFunction()); |
316 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); | 402 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
317 update_tab_function->set_extension(empty_extension.get()); | 403 update_tab_function->set_extension(empty_extension.get()); |
318 // Without a callback the function will not generate a result. | 404 // Without a callback the function will not generate a result. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; | 693 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; |
608 function = new WindowsUpdateFunction(); | 694 function = new WindowsUpdateFunction(); |
609 function->set_extension(extension.get()); | 695 function->set_extension(extension.get()); |
610 EXPECT_TRUE(base::MatchPattern( | 696 EXPECT_TRUE(base::MatchPattern( |
611 utils::RunFunctionAndReturnError( | 697 utils::RunFunctionAndReturnError( |
612 function.get(), | 698 function.get(), |
613 base::StringPrintf(kArgsMaximizedWithBounds, window_id), browser()), | 699 base::StringPrintf(kArgsMaximizedWithBounds, window_id), browser()), |
614 keys::kInvalidWindowStateError)); | 700 keys::kInvalidWindowStateError)); |
615 } | 701 } |
616 | 702 |
| 703 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateAppWindowSizeConstraint) { |
| 704 AppWindow* app_window = CreateTestAppWindow( |
| 705 "{\"outerBounds\": " |
| 706 "{\"width\": 300, \"height\": 300," |
| 707 " \"minWidth\": 200, \"minHeight\": 200," |
| 708 " \"maxWidth\": 400, \"maxHeight\": 400}}"); |
| 709 |
| 710 scoped_refptr<WindowsGetFunction> get_function = new WindowsGetFunction(); |
| 711 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension().get()); |
| 712 get_function->set_extension(extension.get()); |
| 713 scoped_ptr<base::DictionaryValue> result( |
| 714 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 715 get_function.get(), |
| 716 base::StringPrintf("[%u, {\"windowTypes\": [\"app\"]}]", |
| 717 app_window->session_id().id()), |
| 718 browser()))); |
| 719 |
| 720 EXPECT_EQ(300, api_test_utils::GetInteger(result.get(), "width")); |
| 721 EXPECT_EQ(300, api_test_utils::GetInteger(result.get(), "height")); |
| 722 |
| 723 // Verify the min width/height of the application window are |
| 724 // respected. |
| 725 scoped_refptr<WindowsUpdateFunction> update_min_function = |
| 726 new WindowsUpdateFunction(); |
| 727 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 728 update_min_function.get(), |
| 729 base::StringPrintf("[%u, {\"width\": 100, \"height\": 100}]", |
| 730 app_window->session_id().id()), |
| 731 browser()))); |
| 732 |
| 733 EXPECT_EQ(200, api_test_utils::GetInteger(result.get(), "width")); |
| 734 EXPECT_EQ(200, api_test_utils::GetInteger(result.get(), "height")); |
| 735 |
| 736 // Verify the max width/height of the application window are |
| 737 // respected. |
| 738 scoped_refptr<WindowsUpdateFunction> update_max_function = |
| 739 new WindowsUpdateFunction(); |
| 740 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 741 update_max_function.get(), |
| 742 base::StringPrintf("[%u, {\"width\": 500, \"height\": 500}]", |
| 743 app_window->session_id().id()), |
| 744 browser()))); |
| 745 |
| 746 EXPECT_EQ(400, api_test_utils::GetInteger(result.get(), "width")); |
| 747 EXPECT_EQ(400, api_test_utils::GetInteger(result.get(), "height")); |
| 748 |
| 749 CloseAppWindow(app_window); |
| 750 } |
| 751 |
| 752 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateDevToolsWindow) { |
| 753 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 754 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
| 755 |
| 756 scoped_refptr<WindowsGetFunction> get_function = new WindowsGetFunction(); |
| 757 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension().get()); |
| 758 get_function->set_extension(extension.get()); |
| 759 scoped_ptr<base::DictionaryValue> result( |
| 760 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 761 get_function.get(), |
| 762 base::StringPrintf( |
| 763 "[%u, {\"windowTypes\": [\"devtools\"]}]", |
| 764 ExtensionTabUtil::GetWindowId( |
| 765 DevToolsWindowTesting::Get(devtools)->browser())), |
| 766 browser()))); |
| 767 |
| 768 // Verify the updating width/height works. |
| 769 int32_t new_width = api_test_utils::GetInteger(result.get(), "width") - 50; |
| 770 int32_t new_height = api_test_utils::GetInteger(result.get(), "height") - 50; |
| 771 |
| 772 scoped_refptr<WindowsUpdateFunction> update_function = |
| 773 new WindowsUpdateFunction(); |
| 774 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 775 update_function.get(), |
| 776 base::StringPrintf("[%u, {\"width\": %d, \"height\": %d}]", |
| 777 ExtensionTabUtil::GetWindowId( |
| 778 DevToolsWindowTesting::Get(devtools)->browser()), |
| 779 new_width, new_height), |
| 780 browser()))); |
| 781 |
| 782 EXPECT_EQ(new_width, api_test_utils::GetInteger(result.get(), "width")); |
| 783 EXPECT_EQ(new_height, api_test_utils::GetInteger(result.get(), "height")); |
| 784 |
| 785 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 786 } |
| 787 |
| 788 // TODO(llandwerlin): Activating a browser window and waiting for the |
| 789 // action to happen requires views::Widget which is not available on |
| 790 // MacOSX. Deactivate for now. |
| 791 #if !defined(OS_MACOSX) |
| 792 class ExtensionWindowLastFocusedTest : public ExtensionTabsTest { |
| 793 public: |
| 794 void SetUpOnMainThread() override; |
| 795 |
| 796 void ActivateAppWindow(AppWindow* app_window); |
| 797 |
| 798 void ActivateBrowserWindow(Browser* browser); |
| 799 |
| 800 Browser* CreateBrowserWithEmptyTab(bool as_popup); |
| 801 |
| 802 int GetTabId(const base::DictionaryValue* value) const; |
| 803 |
| 804 base::Value* RunFunction(UIThreadExtensionFunction* function, |
| 805 const std::string& params); |
| 806 |
| 807 private: |
| 808 // A helper class to wait for an AppWindow to become activated. On |
| 809 // window system like X11, for a NativeWidget to be activated, we |
| 810 // need to wait for the round trip communication with the X server. |
| 811 class AppWindowActivatedWaiter : public AppWindowRegistry::Observer { |
| 812 public: |
| 813 AppWindowActivatedWaiter(AppWindow* app_window, |
| 814 content::BrowserContext* browser_context) |
| 815 : app_window_(app_window), |
| 816 browser_context_(browser_context), |
| 817 waiting_(false) { |
| 818 AppWindowRegistry::Get(browser_context_)->AddObserver(this); |
| 819 } |
| 820 ~AppWindowActivatedWaiter() override { |
| 821 AppWindowRegistry::Get(browser_context_)->RemoveObserver(this); |
| 822 } |
| 823 |
| 824 void ActivateAndWait() { |
| 825 app_window_->GetBaseWindow()->Activate(); |
| 826 if (!app_window_->GetBaseWindow()->IsActive()) { |
| 827 waiting_ = true; |
| 828 content::RunMessageLoop(); |
| 829 } |
| 830 } |
| 831 |
| 832 // AppWindowRegistry::Observer: |
| 833 void OnAppWindowActivated(AppWindow* app_window) override { |
| 834 if (app_window_ == app_window && waiting_) { |
| 835 base::MessageLoopForUI::current()->Quit(); |
| 836 waiting_ = false; |
| 837 } |
| 838 } |
| 839 |
| 840 private: |
| 841 AppWindow* app_window_; |
| 842 content::BrowserContext* browser_context_; |
| 843 bool waiting_; |
| 844 }; |
| 845 |
| 846 // A helper class to wait for an views::Widget to become activated. |
| 847 class WidgetActivatedWaiter : public views::WidgetObserver { |
| 848 public: |
| 849 explicit WidgetActivatedWaiter(views::Widget* widget) |
| 850 : widget_(widget), waiting_(false) { |
| 851 widget_->AddObserver(this); |
| 852 } |
| 853 ~WidgetActivatedWaiter() override { widget_->RemoveObserver(this); } |
| 854 |
| 855 void ActivateAndWait() { |
| 856 widget_->Activate(); |
| 857 if (!widget_->IsActive()) { |
| 858 waiting_ = true; |
| 859 content::RunMessageLoop(); |
| 860 } |
| 861 } |
| 862 |
| 863 // views::WidgetObserver: |
| 864 void OnWidgetActivationChanged(views::Widget* widget, |
| 865 bool active) override { |
| 866 if (widget_ == widget && waiting_) { |
| 867 base::MessageLoopForUI::current()->Quit(); |
| 868 waiting_ = false; |
| 869 } |
| 870 } |
| 871 |
| 872 private: |
| 873 views::Widget* widget_; |
| 874 bool waiting_; |
| 875 }; |
| 876 |
| 877 scoped_refptr<Extension> extension_; |
| 878 }; |
| 879 |
| 880 void ExtensionWindowLastFocusedTest::SetUpOnMainThread() { |
| 881 ExtensionTabsTest::SetUpOnMainThread(); |
| 882 extension_ = test_util::CreateEmptyExtension(); |
| 883 } |
| 884 |
| 885 void ExtensionWindowLastFocusedTest::ActivateAppWindow(AppWindow* app_window) { |
| 886 AppWindowActivatedWaiter waiter(app_window, browser()->profile()); |
| 887 waiter.ActivateAndWait(); |
| 888 } |
| 889 |
| 890 void ExtensionWindowLastFocusedTest::ActivateBrowserWindow(Browser* browser) { |
| 891 BrowserView* view = BrowserView::GetBrowserViewForBrowser(browser); |
| 892 EXPECT_NE(nullptr, view); |
| 893 views::Widget* widget = view->frame(); |
| 894 EXPECT_NE(nullptr, widget); |
| 895 WidgetActivatedWaiter waiter(widget); |
| 896 waiter.ActivateAndWait(); |
| 897 } |
| 898 |
| 899 Browser* ExtensionWindowLastFocusedTest::CreateBrowserWithEmptyTab( |
| 900 bool as_popup) { |
| 901 Browser* new_browser; |
| 902 if (as_popup) |
| 903 new_browser = new Browser( |
| 904 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), |
| 905 browser()->host_desktop_type())); |
| 906 else |
| 907 new_browser = new Browser(Browser::CreateParams( |
| 908 browser()->profile(), browser()->host_desktop_type())); |
| 909 AddBlankTabAndShow(new_browser); |
| 910 return new_browser; |
| 911 } |
| 912 |
| 913 int ExtensionWindowLastFocusedTest::GetTabId( |
| 914 const base::DictionaryValue* value) const { |
| 915 const base::ListValue* tabs = NULL; |
| 916 if (!value->GetList(keys::kTabsKey, &tabs)) |
| 917 return -2; |
| 918 const base::Value* tab = NULL; |
| 919 if (!tabs->Get(0, &tab)) |
| 920 return -2; |
| 921 const base::DictionaryValue* tab_dict = NULL; |
| 922 if (!tab->GetAsDictionary(&tab_dict)) |
| 923 return -2; |
| 924 int tab_id = 0; |
| 925 if (!tab_dict->GetInteger(keys::kIdKey, &tab_id)) |
| 926 return -2; |
| 927 return tab_id; |
| 928 } |
| 929 |
| 930 base::Value* ExtensionWindowLastFocusedTest::RunFunction( |
| 931 UIThreadExtensionFunction* function, |
| 932 const std::string& params) { |
| 933 function->set_extension(extension_.get()); |
| 934 return utils::RunFunctionAndReturnSingleResult(function, params, browser()); |
| 935 } |
| 936 |
| 937 IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest, |
| 938 NoDevtoolsAndAppWindows) { |
| 939 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 940 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
| 941 { |
| 942 int devtools_window_id = ExtensionTabUtil::GetWindowId( |
| 943 DevToolsWindowTesting::Get(devtools)->browser()); |
| 944 ActivateBrowserWindow(DevToolsWindowTesting::Get(devtools)->browser()); |
| 945 |
| 946 scoped_refptr<WindowsGetLastFocusedFunction> function = |
| 947 new WindowsGetLastFocusedFunction(); |
| 948 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 949 RunFunction(function.get(), "[{\"populate\": true}]"))); |
| 950 EXPECT_NE(devtools_window_id, |
| 951 api_test_utils::GetInteger(result.get(), "id")); |
| 952 } |
| 953 |
| 954 AppWindow* app_window = CreateTestAppWindow( |
| 955 "{\"outerBounds\": " |
| 956 "{\"width\": 300, \"height\": 300," |
| 957 " \"minWidth\": 200, \"minHeight\": 200," |
| 958 " \"maxWidth\": 400, \"maxHeight\": 400}}"); |
| 959 { |
| 960 ActivateAppWindow(app_window); |
| 961 |
| 962 scoped_refptr<WindowsGetLastFocusedFunction> get_current_app_function = |
| 963 new WindowsGetLastFocusedFunction(); |
| 964 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 965 RunFunction(get_current_app_function.get(), "[{\"populate\": true}]"))); |
| 966 int app_window_id = app_window->session_id().id(); |
| 967 EXPECT_NE(app_window_id, api_test_utils::GetInteger(result.get(), "id")); |
| 968 } |
| 969 |
| 970 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 971 CloseAppWindow(app_window); |
| 972 } |
| 973 |
| 974 IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest, |
| 975 NoTabIdForDevToolsAndAppWindows) { |
| 976 Browser* normal_browser = CreateBrowserWithEmptyTab(false); |
| 977 { |
| 978 ActivateBrowserWindow(normal_browser); |
| 979 |
| 980 scoped_refptr<WindowsGetLastFocusedFunction> function = |
| 981 new WindowsGetLastFocusedFunction(); |
| 982 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 983 RunFunction(function.get(), "[{\"populate\": true}]"))); |
| 984 int normal_browser_window_id = |
| 985 ExtensionTabUtil::GetWindowId(normal_browser); |
| 986 EXPECT_EQ(normal_browser_window_id, |
| 987 api_test_utils::GetInteger(result.get(), "id")); |
| 988 EXPECT_NE(-1, GetTabId(result.get())); |
| 989 EXPECT_EQ("normal", api_test_utils::GetString(result.get(), "type")); |
| 990 } |
| 991 |
| 992 Browser* popup_browser = CreateBrowserWithEmptyTab(true); |
| 993 { |
| 994 ActivateBrowserWindow(popup_browser); |
| 995 |
| 996 scoped_refptr<WindowsGetLastFocusedFunction> function = |
| 997 new WindowsGetLastFocusedFunction(); |
| 998 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 999 RunFunction(function.get(), "[{\"populate\": true}]"))); |
| 1000 int popup_browser_window_id = ExtensionTabUtil::GetWindowId(popup_browser); |
| 1001 EXPECT_EQ(popup_browser_window_id, |
| 1002 api_test_utils::GetInteger(result.get(), "id")); |
| 1003 EXPECT_NE(-1, GetTabId(result.get())); |
| 1004 EXPECT_EQ("popup", api_test_utils::GetString(result.get(), "type")); |
| 1005 } |
| 1006 |
| 1007 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 1008 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
| 1009 { |
| 1010 ActivateBrowserWindow(DevToolsWindowTesting::Get(devtools)->browser()); |
| 1011 |
| 1012 scoped_refptr<WindowsGetLastFocusedFunction> function = |
| 1013 new WindowsGetLastFocusedFunction(); |
| 1014 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(RunFunction( |
| 1015 function.get(), |
| 1016 "[{\"populate\": true, \"windowTypes\": [ \"devtools\" ]}]"))); |
| 1017 int devtools_window_id = ExtensionTabUtil::GetWindowId( |
| 1018 DevToolsWindowTesting::Get(devtools)->browser()); |
| 1019 EXPECT_EQ(devtools_window_id, |
| 1020 api_test_utils::GetInteger(result.get(), "id")); |
| 1021 EXPECT_EQ(-1, GetTabId(result.get())); |
| 1022 EXPECT_EQ("devtools", api_test_utils::GetString(result.get(), "type")); |
| 1023 } |
| 1024 |
| 1025 AppWindow* app_window = CreateTestAppWindow( |
| 1026 "{\"outerBounds\": " |
| 1027 "{\"width\": 300, \"height\": 300," |
| 1028 " \"minWidth\": 200, \"minHeight\": 200," |
| 1029 " \"maxWidth\": 400, \"maxHeight\": 400}}"); |
| 1030 { |
| 1031 ActivateAppWindow(app_window); |
| 1032 |
| 1033 scoped_refptr<WindowsGetLastFocusedFunction> get_current_app_function = |
| 1034 new WindowsGetLastFocusedFunction(); |
| 1035 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 1036 RunFunction(get_current_app_function.get(), |
| 1037 "[{\"populate\": true, \"windowTypes\": [ \"app\" ]}]"))); |
| 1038 int app_window_id = app_window->session_id().id(); |
| 1039 EXPECT_EQ(app_window_id, api_test_utils::GetInteger(result.get(), "id")); |
| 1040 EXPECT_EQ(-1, GetTabId(result.get())); |
| 1041 EXPECT_EQ("app", api_test_utils::GetString(result.get(), "type")); |
| 1042 } |
| 1043 |
| 1044 chrome::CloseWindow(normal_browser); |
| 1045 chrome::CloseWindow(popup_browser); |
| 1046 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 1047 CloseAppWindow(app_window); |
| 1048 } |
| 1049 #endif // !defined(OS_MACOSX) |
| 1050 |
617 IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, AcceptState) { | 1051 IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, AcceptState) { |
618 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); | 1052 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); |
619 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 1053 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
620 function->set_extension(extension.get()); | 1054 function->set_extension(extension.get()); |
621 | 1055 |
622 scoped_ptr<base::DictionaryValue> result( | 1056 scoped_ptr<base::DictionaryValue> result( |
623 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( | 1057 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
624 function.get(), "[{\"state\": \"minimized\"}]", browser(), | 1058 function.get(), "[{\"state\": \"minimized\"}]", browser(), |
625 utils::INCLUDE_INCOGNITO))); | 1059 utils::INCLUDE_INCOGNITO))); |
626 int window_id = GetWindowId(result.get()); | 1060 int window_id = GetWindowId(result.get()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 EXPECT_EQ(window_id, duplicate_tab_window_id); | 1200 EXPECT_EQ(window_id, duplicate_tab_window_id); |
767 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 1201 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
768 // The test empty extension has no permissions, therefore |duplicate_result| | 1202 // The test empty extension has no permissions, therefore |duplicate_result| |
769 // should not contain url, title, and faviconUrl in the function result. | 1203 // should not contain url, title, and faviconUrl in the function result. |
770 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 1204 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
771 } | 1205 } |
772 | 1206 |
773 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsEventOnDevTools) { | 1207 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsEventOnDevTools) { |
774 extensions::ResultCatcher catcher; | 1208 extensions::ResultCatcher catcher; |
775 ExtensionTestMessageListener listener("ready", true); | 1209 ExtensionTestMessageListener listener("ready", true); |
776 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("tabs/no_events"))); | 1210 ASSERT_TRUE( |
| 1211 LoadExtension(test_data_dir_.AppendASCII("api_test/tabs/no_events"))); |
777 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 1212 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
778 | 1213 |
779 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( | 1214 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
780 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); | 1215 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
781 | 1216 |
782 listener.Reply("stop"); | 1217 listener.Reply("stop"); |
783 | 1218 |
784 ASSERT_TRUE(catcher.GetNextResult()); | 1219 ASSERT_TRUE(catcher.GetNextResult()); |
785 | 1220 |
786 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); | 1221 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
787 } | 1222 } |
788 | 1223 |
| 1224 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsAppWindow) { |
| 1225 extensions::ResultCatcher catcher; |
| 1226 ExtensionTestMessageListener listener("ready", true); |
| 1227 ASSERT_TRUE( |
| 1228 LoadExtension(test_data_dir_.AppendASCII("api_test/tabs/no_events"))); |
| 1229 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 1230 |
| 1231 AppWindow* app_window = CreateTestAppWindow( |
| 1232 "{\"outerBounds\": " |
| 1233 "{\"width\": 300, \"height\": 300," |
| 1234 " \"minWidth\": 200, \"minHeight\": 200," |
| 1235 " \"maxWidth\": 400, \"maxHeight\": 400}}"); |
| 1236 |
| 1237 listener.Reply("stop"); |
| 1238 |
| 1239 ASSERT_TRUE(catcher.GetNextResult()); |
| 1240 |
| 1241 CloseAppWindow(app_window); |
| 1242 } |
| 1243 |
| 1244 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, FilteredEvents) { |
| 1245 extensions::ResultCatcher catcher; |
| 1246 ExtensionTestMessageListener listener("ready", true); |
| 1247 ASSERT_TRUE( |
| 1248 LoadExtension(test_data_dir_.AppendASCII("api_test/windows/events"))); |
| 1249 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 1250 |
| 1251 AppWindow* app_window = CreateTestAppWindow( |
| 1252 "{\"outerBounds\": " |
| 1253 "{\"width\": 300, \"height\": 300," |
| 1254 " \"minWidth\": 200, \"minHeight\": 200," |
| 1255 " \"maxWidth\": 400, \"maxHeight\": 400}}"); |
| 1256 |
| 1257 Browser* browser_window = new Browser(Browser::CreateParams( |
| 1258 browser()->profile(), browser()->host_desktop_type())); |
| 1259 AddBlankTabAndShow(browser_window); |
| 1260 |
| 1261 DevToolsWindow* devtools_window = |
| 1262 DevToolsWindowTesting::OpenDevToolsWindowSync( |
| 1263 browser()->tab_strip_model()->GetWebContentsAt(0), |
| 1264 false /* is_docked */); |
| 1265 |
| 1266 chrome::CloseWindow(browser_window); |
| 1267 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
| 1268 CloseAppWindow(app_window); |
| 1269 |
| 1270 // TODO(llandwerlin): It seems creating an app window on MacOSX |
| 1271 // won't create an activation event whereas it does on all other |
| 1272 // platform. Disable focus event tests for now. |
| 1273 #if defined(OS_MACOSX) |
| 1274 listener.Reply(""); |
| 1275 #else |
| 1276 listener.Reply("focus"); |
| 1277 #endif |
| 1278 |
| 1279 ASSERT_TRUE(catcher.GetNextResult()); |
| 1280 } |
| 1281 |
789 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, ExecuteScriptOnDevTools) { | 1282 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, ExecuteScriptOnDevTools) { |
790 scoped_ptr<base::DictionaryValue> test_extension_value( | 1283 scoped_ptr<base::DictionaryValue> test_extension_value( |
791 api_test_utils::ParseDictionary( | 1284 api_test_utils::ParseDictionary( |
792 "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": " | 1285 "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": " |
793 "[\"tabs\"]}")); | 1286 "[\"tabs\"]}")); |
794 scoped_refptr<Extension> extension( | 1287 scoped_refptr<Extension> extension( |
795 api_test_utils::CreateExtension(test_extension_value.get())); | 1288 api_test_utils::CreateExtension(test_extension_value.get())); |
796 | 1289 |
797 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( | 1290 DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync( |
798 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); | 1291 browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */); |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 EXPECT_TRUE( | 1739 EXPECT_TRUE( |
1247 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1740 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
1248 | 1741 |
1249 // chrome.tabs.setZoomSettings(). | 1742 // chrome.tabs.setZoomSettings(). |
1250 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 1743 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
1251 EXPECT_TRUE( | 1744 EXPECT_TRUE( |
1252 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1745 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
1253 } | 1746 } |
1254 | 1747 |
1255 } // namespace extensions | 1748 } // namespace extensions |
OLD | NEW |