Commit 42b09087 authored by rouslan's avatar rouslan Committed by Commit bot

Reland "Disable user gesture checking for all autofill browser tests."

When drmemory_full runs, the browser tests are slowed down enough to
timeout the user gesture indicator, which prevents autofill from
processing the input and passing the browser test. The fix is to disable
user gesture checking for all autofill browser tests except
AutofillRendererTest.IgnoreNonUserGestureTextFieldChanges.

TBR=thestig@chromium.org,estade@chromium.org
BUG=484910

Review URL: https://codereview.chromium.org/1143593003

Cr-Commit-Position: refs/heads/master@{#330300}
parent 8a0f0753
......@@ -258,6 +258,7 @@ TEST_F(AutofillRendererTest, IgnoreNonUserGestureTextFieldChanges) {
GetMainFrame()->view()->advanceFocus(false);
// Not a user gesture, so no IPC message to browser.
DisableUserGestureSimulationForAutofill();
full_name.setValue("Alice", true);
GetMainFrame()->toWebLocalFrame()->autofillClient()->textFieldDidChange(
full_name);
......@@ -266,6 +267,7 @@ TEST_F(AutofillRendererTest, IgnoreNonUserGestureTextFieldChanges) {
AutofillHostMsg_TextFieldDidChange::ID));
// A user gesture will send a message to the browser.
EnableUserGestureSimulationForAutofill();
SimulateUserInputChangeForElement(&full_name, "Alice");
ASSERT_NE(nullptr, render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_TextFieldDidChange::ID));
......
......@@ -1743,6 +1743,7 @@ if (!is_android) {
"//chrome/browser",
"//chrome/renderer",
"//media/cast:test_support",
"//testing/gmock",
"//testing/gtest",
"//testing/perf",
]
......
......@@ -18,6 +18,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/renderer/render_view.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
......@@ -44,6 +45,34 @@ using blink::WebScriptController;
using blink::WebScriptSource;
using blink::WebString;
using blink::WebURLRequest;
using content::RenderFrame;
using testing::NiceMock;
using testing::Return;
using testing::_;
namespace {
// An autofill agent that treats all typing as user gesture.
class MockAutofillAgent : public AutofillAgent {
public:
MockAutofillAgent(RenderFrame* render_frame,
PasswordAutofillAgent* password_autofill_agent,
PasswordGenerationAgent* password_generation_agent)
: AutofillAgent(render_frame,
password_autofill_agent,
password_generation_agent) {
ON_CALL(*this, IsUserGesture()).WillByDefault(Return(true));
}
~MockAutofillAgent() override {}
MOCK_CONST_METHOD0(IsUserGesture, bool());
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillAgent);
};
} // namespace
ChromeRenderViewTest::ChromeRenderViewTest()
: password_autofill_agent_(NULL),
......@@ -71,9 +100,9 @@ void ChromeRenderViewTest::SetUp() {
new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame());
password_generation_ =
new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame());
autofill_agent_ =
new AutofillAgent(view_->GetMainRenderFrame(), password_autofill_agent_,
password_generation_);
autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(),
password_autofill_agent_,
password_generation_);
}
void ChromeRenderViewTest::TearDown() {
......@@ -96,12 +125,12 @@ content::ContentClient* ChromeRenderViewTest::CreateContentClient() {
}
content::ContentBrowserClient*
ChromeRenderViewTest::CreateContentBrowserClient() {
ChromeRenderViewTest::CreateContentBrowserClient() {
return new chrome::ChromeContentBrowserClient();
}
content::ContentRendererClient*
ChromeRenderViewTest::CreateContentRendererClient() {
ChromeRenderViewTest::CreateContentRendererClient() {
ChromeContentRendererClient* client = new ChromeContentRendererClient();
#if defined(ENABLE_EXTENSIONS)
extension_dispatcher_delegate_.reset(
......@@ -114,3 +143,13 @@ content::ContentRendererClient*
#endif
return client;
}
void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() {
EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)),
IsUserGesture()).WillRepeatedly(Return(true));
}
void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() {
EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)),
IsUserGesture()).WillRepeatedly(Return(false));
}
......@@ -34,6 +34,9 @@ class ChromeRenderViewTest : public content::RenderViewTest {
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
void EnableUserGestureSimulationForAutofill();
void DisableUserGestureSimulationForAutofill();
#if defined(ENABLE_EXTENSIONS)
scoped_ptr<extensions::DispatcherDelegate> extension_dispatcher_delegate_;
#endif
......
......@@ -388,7 +388,7 @@ void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) {
if (ignore_text_changes_)
return;
if (!WebUserGestureIndicator::isProcessingUserGesture())
if (!IsUserGesture())
return;
// We post a task for doing the Autofill as the caret position is not set
......@@ -752,6 +752,10 @@ void AutofillAgent::HidePopup() {
Send(new AutofillHostMsg_HidePopup(routing_id()));
}
bool AutofillAgent::IsUserGesture() const {
return WebUserGestureIndicator::isProcessingUserGesture();
}
void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) {
for (size_t i = 0; i < nodes.size(); ++i) {
WebLocalFrame* frame = nodes[i].document().frame();
......
......@@ -221,6 +221,10 @@ class AutofillAgent : public content::RenderFrameObserver,
// Hides any currently showing Autofill popup.
void HidePopup();
// Returns true if the text field change is due to a user gesture. Can be
// overriden in tests.
virtual bool IsUserGesture() const;
// Formerly cached forms for all frames, now only caches forms for the current
// frame.
FormCache form_cache_;
......
......@@ -35,8 +35,3 @@ BasicExtensionSettingsWebUITest.testUninstall
# https://crbug.com/480721
OutOfProcessProxyResolverBrowserTest.Verify
# https://crbug.com/484910
PasswordAutofillAgentTest.ClearPreviewWithInlineAutocompletedUsername
PasswordAutofillAgentTest.InlineAutocomplete
PasswordAutofillAgentTest.RememberLastNonEmptyUsernameAndPasswordOnSubmit_UserCleared
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