Commit 8a21aac7 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Chromium LUCI CQ

Prerender: Ignore results of ExecJs() to fix flaky browser tests

To deflake browser tests, this CL makes NavigationWithLocation() helper
ignore the result of ExecJs().

The helper is used for activating prerendered pages. Depending on
timing, activation could destroy the current WebContents before ExecJs()
gets a result from the frame that executed scripts. This results in
execution failure even when it actually succeeded. This part will
drastically be modified by the MPArch, so this CL takes the approach
just to ignore it instead of fixing the timing issue. When ExecJs()
actually fails, the remaining test steps should fail, so it should be
safe to ignore it.

Bug: 1156141
Change-Id: Ia9c72ccd161b29f9fde4481cbc3e4fae4167fb0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593796Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837494}
parent 5d463cbd
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/macros.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/thread_annotations.h" #include "base/thread_annotations.h"
...@@ -100,7 +101,18 @@ class PrerenderBrowserTest : public ContentBrowserTest, ...@@ -100,7 +101,18 @@ class PrerenderBrowserTest : public ContentBrowserTest,
void NavigateWithLocation(const GURL& url) { void NavigateWithLocation(const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::TestNavigationObserver observer(shell()->web_contents()); content::TestNavigationObserver observer(shell()->web_contents());
EXPECT_TRUE( // Ignore the result of ExecJs().
//
// Depending on timing, activation could destroy the current WebContents
// before ExecJs() gets a result from the frame that executed scripts. This
// results in execution failure even when the execution succeeded. See
// https://crbug.com/1156141 for details.
//
// This part will drastically be modified by the MPArch, so we take the
// approach just to ignore it instead of fixing the timing issue. When
// ExecJs() actually fails, the remaining test steps should fail, so it
// should be safe to ignore it.
ignore_result(
ExecJs(shell()->web_contents(), JsReplace("location = $1", url))); ExecJs(shell()->web_contents(), JsReplace("location = $1", url)));
observer.Wait(); observer.Wait();
EXPECT_EQ(shell()->web_contents()->GetURL(), url); EXPECT_EQ(shell()->web_contents()->GetURL(), url);
......
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