Commit 78510396 authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Update WebNavigationApiTest.UserAction to wait for navigation.

The WebNavigationApiTest.UserAction loads a page with has a subframe in
a different site than the main frame. Since the main page is an
extension URL, those will get isolated in separate processes.
The test checks that a context menu in the subframe, which opens a link
in a new tab results in the correct event for the webNavigation API.
However, since it doesn't wait for the subframe navigation to complete,
the context menu creation can incorrectly capture the parent process id
instead of the subframe process id. This is timing dependent, which
leads to flakiness in the test. This CL adds an explicit observer
for the subframe navigation and updates the test expectation to reflect
the fact that the subframe is in a separate process than the parent.

Bug: 662160
Change-Id: I40efc406818f572243720d8feaff2dd597262a5d
Reviewed-on: https://chromium-review.googlesource.com/1155255
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580022}
parent d689b335
...@@ -321,13 +321,7 @@ IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) { ...@@ -321,13 +321,7 @@ IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) {
ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_; ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_;
} }
// Flaky on Windows. See http://crbug.com/662160. IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) {
#if defined(OS_WIN)
#define MAYBE_UserAction DISABLED_UserAction
#else
#define MAYBE_UserAction UserAction
#endif
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, MAYBE_UserAction) {
content::IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); content::IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(StartEmbeddedTestServer());
...@@ -346,7 +340,16 @@ IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, MAYBE_UserAction) { ...@@ -346,7 +340,16 @@ IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, MAYBE_UserAction) {
GURL url = extension->GetResourceURL( GURL url = extension->GetResourceURL(
"a.html?" + base::IntToString(embedded_test_server()->port())); "a.html?" + base::IntToString(embedded_test_server()->port()));
// Register an observer for the navigation in the subframe, so the test
// can wait until it is fully complete. Otherwise the context menu
// navigation is non-deterministic on which process it will get associated
// with, leading to test flakiness.
content::TestNavigationManager nav_manager(
tab, embedded_test_server()->GetURL(
"/extensions/api_test/webnavigation/userAction/subframe.html"));
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
nav_manager.WaitForNavigationFinished();
EXPECT_TRUE(nav_manager.was_successful());
// This corresponds to "Open link in new tab". // This corresponds to "Open link in new tab".
content::ContextMenuParams params; content::ContextMenuParams params;
......
...@@ -88,7 +88,7 @@ onload = function() { ...@@ -88,7 +88,7 @@ onload = function() {
{ label: "b-onCreatedNavigationTarget", { label: "b-onCreatedNavigationTarget",
event: "onCreatedNavigationTarget", event: "onCreatedNavigationTarget",
details: { sourceFrameId: 1, details: { sourceFrameId: 1,
sourceProcessId: 0, sourceProcessId: 1,
sourceTabId: 0, sourceTabId: 0,
tabId: 1, tabId: 1,
timeStamp: 0, timeStamp: 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment