| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" | 8 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Helper class to track and allow waiting for navigation start events. | 60 // Helper class to track and allow waiting for navigation start events. |
| 61 class DidStartNavigationObserver : public content::WebContentsObserver { | 61 class DidStartNavigationObserver : public content::WebContentsObserver { |
| 62 public: | 62 public: |
| 63 explicit DidStartNavigationObserver(content::WebContents* web_contents) | 63 explicit DidStartNavigationObserver(content::WebContents* web_contents) |
| 64 : content::WebContentsObserver(web_contents), | 64 : content::WebContentsObserver(web_contents), |
| 65 message_loop_runner_(new content::MessageLoopRunner) {} | 65 message_loop_runner_(new content::MessageLoopRunner) {} |
| 66 ~DidStartNavigationObserver() override {} | 66 ~DidStartNavigationObserver() override {} |
| 67 | 67 |
| 68 // Runs a nested message loop and blocks until the full load has | 68 // Runs a nested run loop and blocks until the full load has |
| 69 // completed. | 69 // completed. |
| 70 void Wait() { message_loop_runner_->Run(); } | 70 void Wait() { message_loop_runner_->Run(); } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 // WebContentsObserver | 73 // WebContentsObserver |
| 74 void DidStartNavigation(content::NavigationHandle* handle) override { | 74 void DidStartNavigation(content::NavigationHandle* handle) override { |
| 75 if (message_loop_runner_->loop_running()) | 75 if (message_loop_runner_->loop_running()) |
| 76 message_loop_runner_->Quit(); | 76 message_loop_runner_->Quit(); |
| 77 } | 77 } |
| 78 | 78 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 // Let the navigation finish. It should commit successfully. | 429 // Let the navigation finish. It should commit successfully. |
| 430 manager.WaitForNavigationFinished(); | 430 manager.WaitForNavigationFinished(); |
| 431 last_committed = web_contents->GetController().GetLastCommittedEntry(); | 431 last_committed = web_contents->GetController().GetLastCommittedEntry(); |
| 432 EXPECT_TRUE(last_committed); | 432 EXPECT_TRUE(last_committed); |
| 433 EXPECT_EQ(kURL2, last_committed->GetURL()); | 433 EXPECT_EQ(kURL2, last_committed->GetURL()); |
| 434 | 434 |
| 435 EXPECT_TRUE(navigation_observer.has_committed()); | 435 EXPECT_TRUE(navigation_observer.has_committed()); |
| 436 EXPECT_FALSE(navigation_observer.was_same_document()); | 436 EXPECT_FALSE(navigation_observer.was_same_document()); |
| 437 EXPECT_FALSE(navigation_observer.was_renderer_initiated()); | 437 EXPECT_FALSE(navigation_observer.was_renderer_initiated()); |
| 438 } | 438 } |
| OLD | NEW |