| 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // Navigate! Both extensions will try to inject. | 475 // Navigate! Both extensions will try to inject. |
| 476 ui_test_utils::NavigateToURLWithDisposition( | 476 ui_test_utils::NavigateToURLWithDisposition( |
| 477 browser(), | 477 browser(), |
| 478 embedded_test_server()->GetURL("/empty.html"), | 478 embedded_test_server()->GetURL("/empty.html"), |
| 479 CURRENT_TAB, | 479 CURRENT_TAB, |
| 480 ui_test_utils::BROWSER_TEST_NONE); | 480 ui_test_utils::BROWSER_TEST_NONE); |
| 481 | 481 |
| 482 run_loop.Run(); | 482 run_loop.Run(); |
| 483 // Right now, the alert dialog is showing and blocking injection of anything | 483 // Right now, the alert dialog is showing and blocking injection of anything |
| 484 // after it, so the listener shouldn't be satisfied. | 484 // after it, so the listener shouldn't be satisfied. |
| 485 EXPECT_TRUE(RunAllPending(web_contents)); | |
| 486 EXPECT_FALSE(listener.was_satisfied()); | 485 EXPECT_FALSE(listener.was_satisfied()); |
| 487 EXPECT_EQ(1u, dialog_helper.dialog_count()); | 486 EXPECT_EQ(1u, dialog_helper.dialog_count()); |
| 488 dialog_helper.CloseDialogs(); | 487 dialog_helper.CloseDialogs(); |
| 489 | 488 |
| 490 // After closing the dialog, the rest of the scripts should be able to | 489 // After closing the dialog, the rest of the scripts should be able to |
| 491 // inject. | 490 // inject. |
| 492 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 491 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 493 } | 492 } |
| 494 | 493 |
| 495 // Test that closing a tab with a blocking script results in no further scripts | 494 // Test that closing a tab with a blocking script results in no further scripts |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 // Navitate! | 530 // Navitate! |
| 532 ui_test_utils::NavigateToURLWithDisposition( | 531 ui_test_utils::NavigateToURLWithDisposition( |
| 533 browser(), | 532 browser(), |
| 534 embedded_test_server()->GetURL("/empty.html"), | 533 embedded_test_server()->GetURL("/empty.html"), |
| 535 CURRENT_TAB, | 534 CURRENT_TAB, |
| 536 ui_test_utils::BROWSER_TEST_NONE); | 535 ui_test_utils::BROWSER_TEST_NONE); |
| 537 | 536 |
| 538 // Now, instead of closing the dialog, just close the tab. Later scripts | 537 // Now, instead of closing the dialog, just close the tab. Later scripts |
| 539 // should never get a chance to run (and we shouldn't crash). | 538 // should never get a chance to run (and we shouldn't crash). |
| 540 run_loop.Run(); | 539 run_loop.Run(); |
| 541 EXPECT_TRUE(RunAllPending(web_contents)); | |
| 542 EXPECT_FALSE(listener.was_satisfied()); | 540 EXPECT_FALSE(listener.was_satisfied()); |
| 543 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( | 541 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( |
| 544 browser()->tab_strip_model()->active_index(), 0)); | 542 browser()->tab_strip_model()->active_index(), 0)); |
| 545 EXPECT_FALSE(listener.was_satisfied()); | 543 EXPECT_FALSE(listener.was_satisfied()); |
| 546 } | 544 } |
| 547 | 545 |
| 548 // There was a bug by which content scripts that blocked and ran on | 546 // There was a bug by which content scripts that blocked and ran on |
| 549 // document_idle could be injected twice (crbug.com/431263). Test for | 547 // document_idle could be injected twice (crbug.com/431263). Test for |
| 550 // regression. | 548 // regression. |
| 551 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, | 549 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 569 // Navigate! | 567 // Navigate! |
| 570 ui_test_utils::NavigateToURLWithDisposition( | 568 ui_test_utils::NavigateToURLWithDisposition( |
| 571 browser(), | 569 browser(), |
| 572 embedded_test_server()->GetURL("/empty.html"), | 570 embedded_test_server()->GetURL("/empty.html"), |
| 573 CURRENT_TAB, | 571 CURRENT_TAB, |
| 574 ui_test_utils::BROWSER_TEST_NONE); | 572 ui_test_utils::BROWSER_TEST_NONE); |
| 575 | 573 |
| 576 run_loop.Run(); | 574 run_loop.Run(); |
| 577 | 575 |
| 578 // The extension will have injected at idle, but it should only inject once. | 576 // The extension will have injected at idle, but it should only inject once. |
| 579 EXPECT_TRUE(RunAllPending(web_contents)); | |
| 580 EXPECT_EQ(1u, dialog_helper.dialog_count()); | 577 EXPECT_EQ(1u, dialog_helper.dialog_count()); |
| 581 dialog_helper.CloseDialogs(); | 578 dialog_helper.CloseDialogs(); |
| 582 EXPECT_TRUE(RunAllPending(web_contents)); | 579 EXPECT_TRUE(RunAllPending(web_contents)); |
| 583 EXPECT_EQ(1u, dialog_helper.dialog_count()); | 580 EXPECT_EQ(1u, dialog_helper.dialog_count()); |
| 584 } | 581 } |
| 585 | 582 |
| 586 // Bug fix for crbug.com/507461. | 583 // Bug fix for crbug.com/507461. |
| 587 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, | 584 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, |
| 588 DocumentStartInjectionFromExtensionTabNavigation) { | 585 DocumentStartInjectionFromExtensionTabNavigation) { |
| 589 ASSERT_TRUE(StartEmbeddedTestServer()); | 586 ASSERT_TRUE(StartEmbeddedTestServer()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 ExtensionTestMessageListener iframe_loaded_listener("iframe loaded", false); | 629 ExtensionTestMessageListener iframe_loaded_listener("iframe loaded", false); |
| 633 ExtensionTestMessageListener content_script_listener("script injected", | 630 ExtensionTestMessageListener content_script_listener("script injected", |
| 634 false); | 631 false); |
| 635 LoadExtension(data_dir.AppendASCII("script_a_com")); | 632 LoadExtension(data_dir.AppendASCII("script_a_com")); |
| 636 LoadExtension(data_dir.AppendASCII("background_page_iframe")); | 633 LoadExtension(data_dir.AppendASCII("background_page_iframe")); |
| 637 iframe_loaded_listener.WaitUntilSatisfied(); | 634 iframe_loaded_listener.WaitUntilSatisfied(); |
| 638 EXPECT_FALSE(content_script_listener.was_satisfied()); | 635 EXPECT_FALSE(content_script_listener.was_satisfied()); |
| 639 } | 636 } |
| 640 | 637 |
| 641 } // namespace extensions | 638 } // namespace extensions |
| OLD | NEW |