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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 profile())->extension_service(); | 580 profile())->extension_service(); |
581 service->EnableExtension(extension_id); | 581 service->EnableExtension(extension_id); |
582 } | 582 } |
583 | 583 |
584 void ExtensionBrowserTest::OpenWindow(content::WebContents* contents, | 584 void ExtensionBrowserTest::OpenWindow(content::WebContents* contents, |
585 const GURL& url, | 585 const GURL& url, |
586 bool newtab_process_should_equal_opener, | 586 bool newtab_process_should_equal_opener, |
587 content::WebContents** newtab_result) { | 587 content::WebContents** newtab_result) { |
588 content::WindowedNotificationObserver windowed_observer( | 588 content::WindowedNotificationObserver windowed_observer( |
589 content::NOTIFICATION_LOAD_STOP, | 589 content::NOTIFICATION_LOAD_STOP, |
590 content::NotificationService::AllSources()); | 590 content::Source<content::NavigationController>(&contents->GetController())
); |
591 ASSERT_TRUE(content::ExecuteScript(contents, | 591 ASSERT_TRUE(content::ExecuteScript(contents, |
592 "window.open('" + url.spec() + "');")); | 592 "window.open('" + url.spec() + "');")); |
593 | 593 |
594 // The above window.open call is not user-initiated, so it will create | 594 // The above window.open call is not user-initiated, so it will create |
595 // a popup window instead of a new tab in current window. | 595 // a popup window instead of a new tab in current window. |
596 // The stop notification will come from the new tab. | 596 // The stop notification will come from the new tab. |
597 windowed_observer.Wait(); | 597 windowed_observer.Wait(); |
598 content::NavigationController* controller = | 598 content::NavigationController* controller = |
599 content::Source<content::NavigationController>( | 599 content::Source<content::NavigationController>( |
600 windowed_observer.source()).ptr(); | 600 windowed_observer.source()).ptr(); |
(...skipping 10 matching lines...) Expand all Loading... |
611 } | 611 } |
612 | 612 |
613 void ExtensionBrowserTest::NavigateInRenderer(content::WebContents* contents, | 613 void ExtensionBrowserTest::NavigateInRenderer(content::WebContents* contents, |
614 const GURL& url) { | 614 const GURL& url) { |
615 // Ensure any existing navigations complete before trying to navigate anew, to | 615 // Ensure any existing navigations complete before trying to navigate anew, to |
616 // avoid triggering of the unload event for the wrong navigation. | 616 // avoid triggering of the unload event for the wrong navigation. |
617 content::WaitForLoadStop(contents); | 617 content::WaitForLoadStop(contents); |
618 bool result = false; | 618 bool result = false; |
619 content::WindowedNotificationObserver windowed_observer( | 619 content::WindowedNotificationObserver windowed_observer( |
620 content::NOTIFICATION_LOAD_STOP, | 620 content::NOTIFICATION_LOAD_STOP, |
621 content::NotificationService::AllSources()); | 621 content::Source<content::NavigationController>(&contents->GetController())
); |
| 622 //content::NotificationService::AllSources()); |
622 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 623 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
623 contents, | 624 contents, |
624 "window.addEventListener('unload', function() {" | 625 "window.addEventListener('unload', function() {" |
625 " window.domAutomationController.send(true);" | 626 " window.domAutomationController.send(true);" |
626 "}, false);" | 627 "}, false);" |
627 "window.location = '" + url.spec() + "';", | 628 "window.location = '" + url.spec() + "';", |
628 &result)); | 629 &result)); |
629 ASSERT_TRUE(result); | 630 ASSERT_TRUE(result); |
630 windowed_observer.Wait(); | 631 windowed_observer.Wait(); |
631 EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL()); | 632 EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL()); |
(...skipping 22 matching lines...) Expand all Loading... |
654 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 655 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
655 profile(), extension_id, script); | 656 profile(), extension_id, script); |
656 } | 657 } |
657 | 658 |
658 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 659 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
659 const std::string& extension_id, | 660 const std::string& extension_id, |
660 const std::string& script) { | 661 const std::string& script) { |
661 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 662 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
662 profile(), extension_id, script); | 663 profile(), extension_id, script); |
663 } | 664 } |
OLD | NEW |