Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2901833002: Create NavigationHandle after beforeunload with PlzNavigate. (Closed)
Patch Set: small fix from jam Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
index 67af007f80cbe0d8faebb0217eadce59cea62586..72a3068a235f10de51cfbc452b68ff4a87c2d887 100644
--- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
+++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -1204,6 +1204,30 @@ class NavigationFinishedObserver : public content::WebContentsObserver {
int num_finished_;
int num_to_wait_for_;
};
+
+class LoadFinishedObserver : public content::WebContentsObserver {
+ public:
+ explicit LoadFinishedObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents), num_finished_(0) {}
+
+ ~LoadFinishedObserver() override {}
+
+ void DidStopLoading() override {
+ num_finished_++;
+ if (run_loop_.running())
+ run_loop_.Quit();
+ }
+
+ void WaitForLoadToFinish() {
+ if (num_finished_ == 0)
+ run_loop_.Run();
+ }
+
+ private:
+ int num_finished_;
+ base::RunLoop run_loop_;
+};
+
} // namespace
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, PageStopLoading) {
@@ -1219,8 +1243,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, PageStopLoading) {
params->SetBoolean("enabled", true);
SendCommand("Page.setControlNavigations", std::move(params), true);
- NavigationFinishedObserver navigation_finished_observer(
- shell()->web_contents());
+ LoadFinishedObserver load_finished_observer(shell()->web_contents());
// The page will try to navigate twice, however since
// Page.setControlNavigations is true, it'll wait for confirmation before
@@ -1233,7 +1256,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, PageStopLoading) {
SendCommand("Page.stopLoading", nullptr);
// Wait for the initial navigation to finish.
- navigation_finished_observer.WaitForNavigationsToFinish(1);
+ load_finished_observer.WaitForLoadToFinish();
}
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ControlNavigationsMainFrame) {
« no previous file with comments | « chrome/browser/ui/browser_instant_controller_unittest.cc ('k') | content/browser/frame_host/frame_tree_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698