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

Unified Diff: chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc

Issue 2089943002: MD Settings: deflake back/forward navigation test via session restore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc b/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
index f054a8138bacc13ad5f19903376645b435b4c793..90c0640522bfde3db45d6c35bc7dda00b481abe6 100644
--- a/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
@@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <string>
+#include <vector>
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -17,11 +20,11 @@
#include "content/public/test/browser_test_utils.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
+#include "url/url_constants.h"
typedef InProcessBrowserTest MdSettingsUITest;
using ui_test_utils::NavigateToURL;
-using content::WaitForLoadStop;
IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) {
NavigateToURL(browser(),
@@ -29,21 +32,47 @@ IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) {
chrome::kChromeUIMdSettingsURL));
}
-// May not complete on memory bots. TODO(dbeam): investigate and fix.
-// See https://crbug.com/558434 and https://crbug.com/620370.
-#if defined(MEMORY_SANITIZER)
-#define MAYBE_BackForwardDoesntCrash DISABLED_BackForwardDoesntCrash
-#else
-#define MAYBE_BackForwardDoesntCrash BackForwardDoesntCrash
-#endif
+IN_PROC_BROWSER_TEST_F(MdSettingsUITest, BackForwardDoesntCrash) {
+ auto contents = browser()->tab_strip_model()->GetActiveWebContents();
-IN_PROC_BROWSER_TEST_F(MdSettingsUITest, MAYBE_BackForwardDoesntCrash) {
- NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
+ // Build some history.
+ std::vector<std::unique_ptr<content::NavigationEntry>> entries;
+ entries.push_back(content::NavigationController::CreateNavigationEntry(
+ GURL(url::kAboutBlankURL),
+ content::Referrer(),
+ ui::PAGE_TRANSITION_LINK,
+ true /* is_renderer_initiated */,
+ std::string() /* extra_headers */,
+ contents->GetBrowserContext()));
+ entries.push_back(content::NavigationController::CreateNavigationEntry(
+ GURL(chrome::kChromeUIMdSettingsURL),
+ content::Referrer(),
+ ui::PAGE_TRANSITION_LINK,
+ true /* is_renderer_initiated */,
+ std::string() /* extra_headers */,
+ contents->GetBrowserContext()));
+
+ // Load the built history into the tab via session restore (which should load
+ // about:blank with chrome://md-settings as the URL to visit if forward is
+ // pressed).
+ contents->GetController().Restore(
+ 0 /* selected_navigation */,
+ content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY,
+ &entries);
+ ASSERT_EQ(0U, entries.size());
+
+ ASSERT_TRUE(contents->GetController().CanGoForward());
+ contents->GetController().GoForward();
- NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ // Go forward to visit chrome://md-settings.
+ ASSERT_TRUE(contents->GetController().CanGoForward());
+ contents->GetController().GoForward();
- chrome::GoBack(browser(), CURRENT_TAB);
- WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
+ // TODO(dbeam): do we need to wait until load stop? Is there anything else we
+ // could wait for that reliably constructs handlers but is faster?
+ ASSERT_TRUE(content::WaitForLoadStop(contents));
+ EXPECT_EQ(GURL(chrome::kChromeUIMdSettingsURL),
+ contents->GetLastCommittedURL());
}
// Catch lifetime issues in message handlers. There was previously a problem
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698