Commit 92baad33 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Speculative fix for a crash in AutofillPopupControllerImpl.

- AutofillPopupControllerImpl::UpdateDataListValues recreates all the view in
the dropdown.
- Later AutofillPopupControllerImpl::SetSelectedLine selects a new line and
passes the index of the previous one. It may not exist.

Bug: 965025
Change-Id: Ie53b521803dcf33b02602357bda39a30b5ba0f4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1995392
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732366}
parent a28d963e
......@@ -161,6 +161,7 @@ void AutofillPopupControllerImpl::UpdateDataListValues(
DCHECK_EQ(suggestions_.size(), elided_values_.size());
DCHECK_EQ(suggestions_.size(), elided_labels_.size());
selected_line_.reset();
// Remove all the old data list values, which should always be at the top of
// the list if they are present.
while (!suggestions_.empty() &&
......
......@@ -6,7 +6,9 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_popup_view.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
......@@ -110,4 +112,30 @@ IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest,
autofill_external_delegate_.reset();
}
// crbug.com/965025
IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, ResetSelectedLine) {
test::GenerateTestAutofillPopup(autofill_external_delegate_.get());
auto* client =
autofill::ChromeAutofillClient::FromWebContents(web_contents());
AutofillPopupController* controller =
client->popup_controller_for_testing().get();
ASSERT_TRUE(controller);
// Push some suggestions and select the line #3.
std::vector<base::string16> rows = {
base::ASCIIToUTF16("suggestion1"), base::ASCIIToUTF16("suggestion2"),
base::ASCIIToUTF16("suggestion3"), base::ASCIIToUTF16("suggestion4")};
client->UpdateAutofillPopupDataListValues(rows, rows);
controller->SetSelectedLine(3);
// Replace the list with the smaller one.
rows = {base::ASCIIToUTF16("suggestion1")};
client->UpdateAutofillPopupDataListValues(rows, rows);
// Make sure that previously selected line #3 doesn't exist.
ASSERT_LT(controller->GetLineCount(), 4);
// Selecting a new line should not crash.
controller->SetSelectedLine(0);
}
} // namespace autofill
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