OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/notifications/notification_test_util.h" | 21 #include "chrome/browser/notifications/notification_test_util.h" |
22 #include "chrome/browser/notifications/notification_ui_manager.h" | 22 #include "chrome/browser/notifications/notification_ui_manager.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 24 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
25 #include "chrome/browser/task_manager/task_manager_interface.h" | 25 #include "chrome/browser/task_manager/task_manager_interface.h" |
26 #include "chrome/browser/task_manager/task_manager_tester.h" | 26 #include "chrome/browser/task_manager/task_manager_tester.h" |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_commands.h" | 28 #include "chrome/browser/ui/browser_commands.h" |
29 #include "chrome/browser/ui/browser_dialogs.h" | 29 #include "chrome/browser/ui/browser_dialogs.h" |
30 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/browser/ui/panels/panel.h" | |
32 #include "chrome/browser/ui/panels/panel_manager.h" | |
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
34 #include "chrome/browser/web_applications/web_app.h" | 32 #include "chrome/browser/web_applications/web_app.h" |
35 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
37 #include "chrome/test/base/in_process_browser_test.h" | 35 #include "chrome/test/base/in_process_browser_test.h" |
38 #include "chrome/test/base/ui_test_utils.h" | 36 #include "chrome/test/base/ui_test_utils.h" |
39 #include "components/infobars/core/confirm_infobar_delegate.h" | 37 #include "components/infobars/core/confirm_infobar_delegate.h" |
40 #include "components/infobars/core/infobar.h" | 38 #include "components/infobars/core/infobar.h" |
41 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/page_navigator.h" | 40 #include "content/public/browser/page_navigator.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 298 |
301 // Now navigate this tab to a different site. This should wind up in a | 299 // Now navigate this tab to a different site. This should wind up in a |
302 // different renderer process, so it should complete and show up in the task | 300 // different renderer process, so it should complete and show up in the task |
303 // manager. | 301 // manager. |
304 tab2->OpenURL(content::OpenURLParams(url3, content::Referrer(), CURRENT_TAB, | 302 tab2->OpenURL(content::OpenURLParams(url3, content::Referrer(), CURRENT_TAB, |
305 ui::PAGE_TRANSITION_TYPED, false)); | 303 ui::PAGE_TRANSITION_TYPED, false)); |
306 | 304 |
307 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); | 305 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); |
308 } | 306 } |
309 | 307 |
310 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { | |
311 ASSERT_TRUE(LoadExtension( | |
312 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | |
313 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | |
314 .AppendASCII("1.0.0.0"))); | |
315 | |
316 // Open a new panel to an extension url. | |
317 GURL url( | |
318 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | |
319 Panel* docked_panel = PanelManager::GetInstance()->CreatePanel( | |
320 web_app::GenerateApplicationNameFromExtensionId( | |
321 last_loaded_extension_id()), | |
322 browser()->profile(), url, nullptr, gfx::Rect(300, 400), | |
323 PanelManager::CREATE_AS_DOCKED); | |
324 docked_panel->Show(); | |
325 | |
326 // Make sure that a task manager model created after the panel shows the | |
327 // existence of the panel and the extension. | |
328 ShowTaskManager(); | |
329 ASSERT_NO_FATAL_FAILURE( | |
330 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
331 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
332 1, | |
333 MatchExtension( | |
334 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
335 "french_sentence.html"))); | |
336 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); | |
337 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | |
338 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
339 | |
340 // Create a second, detached panel. | |
341 Panel* detached_panel = PanelManager::GetInstance()->CreatePanel( | |
342 web_app::GenerateApplicationNameFromExtensionId( | |
343 last_loaded_extension_id()), | |
344 browser()->profile(), url, nullptr, gfx::Rect(150, 150), | |
345 PanelManager::CREATE_AS_DETACHED); | |
346 detached_panel->ShowInactive(); | |
347 | |
348 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
349 2, MatchExtension("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
350 "french_sentence.html"))); | |
351 ASSERT_NO_FATAL_FAILURE( | |
352 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
353 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyExtension())); | |
354 | |
355 // Close the panels and verify that we notice. | |
356 docked_panel->Close(); | |
357 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); | |
358 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
359 1, MatchExtension("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
360 "french_sentence.html"))); | |
361 ASSERT_NO_FATAL_FAILURE( | |
362 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
363 | |
364 detached_panel->Close(); | |
365 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); | |
366 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
367 0, | |
368 MatchExtension( | |
369 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
370 "french_sentence.html"))); | |
371 ASSERT_NO_FATAL_FAILURE( | |
372 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
373 } | |
374 | |
375 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanelChanges) { | |
376 ShowTaskManager(); | |
377 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | |
378 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
379 | |
380 ASSERT_TRUE(LoadExtension( | |
381 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | |
382 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | |
383 .AppendASCII("1.0.0.0"))); | |
384 | |
385 // Browser, the New Tab Page and Extension background page. | |
386 ASSERT_NO_FATAL_FAILURE( | |
387 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
388 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); | |
389 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
390 | |
391 // Open a new panel to an extension url and make sure we notice that. | |
392 GURL url( | |
393 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | |
394 Panel* panel = PanelManager::GetInstance()->CreatePanel( | |
395 web_app::GenerateApplicationNameFromExtensionId( | |
396 last_loaded_extension_id()), | |
397 browser()->profile(), | |
398 url, | |
399 nullptr, | |
400 gfx::Rect(300, 400), | |
401 PanelManager::CREATE_AS_DOCKED); | |
402 panel->ShowInactive(); | |
403 | |
404 ASSERT_NO_FATAL_FAILURE( | |
405 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
406 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
407 1, | |
408 MatchExtension( | |
409 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
410 "french_sentence.html"))); | |
411 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); | |
412 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | |
413 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
414 | |
415 // Close the panel and verify that we notice. | |
416 panel->Close(); | |
417 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); | |
418 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
419 0, | |
420 MatchExtension( | |
421 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
422 "french_sentence.html"))); | |
423 ASSERT_NO_FATAL_FAILURE( | |
424 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
425 | |
426 // Unload extension. | |
427 UnloadExtension(last_loaded_extension_id()); | |
428 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); | |
429 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
430 } | |
431 | |
432 // Kills a process that has more than one task manager entry. | |
433 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaExtensionResource) { | |
434 ShowTaskManager(); | |
435 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") | |
436 .AppendASCII("Extensions") | |
437 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | |
438 .AppendASCII("1.0.0.0"))); | |
439 | |
440 // Open a new panel to an extension url. | |
441 GURL url( | |
442 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
443 "french_sentence.html"); | |
444 Panel* panel = PanelManager::GetInstance()->CreatePanel( | |
445 web_app::GenerateApplicationNameFromExtensionId( | |
446 last_loaded_extension_id()), | |
447 browser()->profile(), | |
448 url, | |
449 nullptr, | |
450 gfx::Rect(300, 400), | |
451 PanelManager::CREATE_AS_DETACHED); | |
452 panel->Show(); | |
453 | |
454 ASSERT_NO_FATAL_FAILURE( | |
455 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
456 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
457 1, | |
458 MatchExtension( | |
459 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
460 "french_sentence.html"))); | |
461 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); | |
462 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | |
463 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
464 | |
465 // Kill the process via the BACKGROUND PAGE (not the panel). Verify that both | |
466 // the background page and the panel go away from the task manager. | |
467 int background_page = FindResourceIndex(MatchExtension("My extension 1")); | |
468 ASSERT_NE(-1, background_page); | |
469 ASSERT_EQ(-1, model()->GetTabId(background_page)); | |
470 model()->Kill(background_page); | |
471 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); | |
472 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
473 } | |
474 | |
475 // Kills a process that has more than one task manager entry. This test is the | |
476 // same as KillPanelViaExtensionResource except it does the kill via the other | |
477 // entry. | |
478 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) { | |
479 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") | |
480 .AppendASCII("Extensions") | |
481 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | |
482 .AppendASCII("1.0.0.0"))); | |
483 | |
484 // Open a new panel to an extension url. | |
485 GURL url( | |
486 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
487 "french_sentence.html"); | |
488 Panel* panel = PanelManager::GetInstance()->CreatePanel( | |
489 web_app::GenerateApplicationNameFromExtensionId( | |
490 last_loaded_extension_id()), | |
491 browser()->profile(), | |
492 url, | |
493 nullptr, | |
494 gfx::Rect(300, 400), | |
495 PanelManager::CREATE_AS_DETACHED); | |
496 panel->ShowInactive(); | |
497 | |
498 ShowTaskManager(); | |
499 ASSERT_NO_FATAL_FAILURE( | |
500 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); | |
501 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( | |
502 1, | |
503 MatchExtension( | |
504 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
505 "french_sentence.html"))); | |
506 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); | |
507 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | |
508 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
509 | |
510 int background_page = FindResourceIndex(MatchExtension("My extension 1")); | |
511 ASSERT_NE(-1, background_page); | |
512 ASSERT_EQ(-1, model()->GetTabId(background_page)); | |
513 | |
514 // Kill the process via the PANEL RESOURCE (not the background page). Verify | |
515 // that both the background page and the panel go away from the task manager. | |
516 int panel_index = FindResourceIndex(MatchExtension( | |
517 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" | |
518 "french_sentence.html")); | |
519 ASSERT_NE(-1, panel_index); | |
520 ASSERT_NE(-1, model()->GetTabId(panel_index)); | |
521 model()->Kill(panel_index); | |
522 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); | |
523 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | |
524 } | |
525 | |
526 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { | 308 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { |
527 ShowTaskManager(); | 309 ShowTaskManager(); |
528 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 310 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
529 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 311 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
530 | 312 |
531 ASSERT_TRUE(LoadExtension( | 313 ASSERT_TRUE(LoadExtension( |
532 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 314 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
533 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 315 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
534 .AppendASCII("1.0.0.0"))); | 316 .AppendASCII("1.0.0.0"))); |
535 | 317 |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 | 1068 |
1287 // Because the subframes for tab 2 are nested, their order is deterministic. | 1069 // Because the subframes for tab 2 are nested, their order is deterministic. |
1288 EXPECT_EQ("Subframe: http://a.com/", | 1070 EXPECT_EQ("Subframe: http://a.com/", |
1289 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); | 1071 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); |
1290 EXPECT_EQ("Subframe: http://c.com/", | 1072 EXPECT_EQ("Subframe: http://c.com/", |
1291 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); | 1073 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); |
1292 EXPECT_EQ("Subframe: http://b.com/", | 1074 EXPECT_EQ("Subframe: http://b.com/", |
1293 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); | 1075 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); |
1294 } | 1076 } |
1295 } | 1077 } |
OLD | NEW |