Commit 6e8610f8 authored by Christoph Schwering's avatar Christoph Schwering Committed by Commit Bot

Added log filtering to iOS chrome://autofill-internals.

Also changed testChromeAutofillInternalsSite to verify that
chrome://autofill-internals/ is a substring of the omnibox URL,
not identical to it, the reason being that autofill-internals
dynamically changes the fragment identifier of the URL.

Change-Id: I1a0d7b57980be5e9c2c54340e7d9b44fb8f95c0a
Bug: 1051504
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035897
Commit-Queue: Christoph Schwering <schwering@google.com>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741438}
parent 183c28dd
...@@ -16,7 +16,13 @@ injected by web. --> ...@@ -16,7 +16,13 @@ injected by web. -->
<link rel="stylesheet" href="autofill_and_password_manager_internals.css"> <link rel="stylesheet" href="autofill_and_password_manager_internals.css">
</head> </head>
<body> <body>
<h1 id="h1-title"></h1> <div>
<h1 id="h1-title"></h1>
<div id="log-display-config">
<span id="marker-fake-button">Add Marker</span>
<input type="checkbox" id="enable-autoscroll" checked><label for="enable-autoscroll">Enable autoscroll</label>
</div>
</div>
<div id="logging-note"></div> <div id="logging-note"></div>
<div id="logging-note-incognito"></div> <div id="logging-note-incognito"></div>
<div id="version-info"> <div id="version-info">
......
...@@ -31,6 +31,7 @@ using base::TrimPositions; ...@@ -31,6 +31,7 @@ using base::TrimPositions;
using chrome_test_util::BackButton; using chrome_test_util::BackButton;
using chrome_test_util::ForwardButton; using chrome_test_util::ForwardButton;
using chrome_test_util::OmniboxText; using chrome_test_util::OmniboxText;
using chrome_test_util::OmniboxContainingText;
namespace { namespace {
...@@ -42,10 +43,10 @@ GURL WebUIPageUrlWithHost(const std::string& host) { ...@@ -42,10 +43,10 @@ GURL WebUIPageUrlWithHost(const std::string& host) {
return GURL(base::StringPrintf("%s://%s", kChromeUIScheme, host.c_str())); return GURL(base::StringPrintf("%s://%s", kChromeUIScheme, host.c_str()));
} }
// Waits for omnibox text to equal |URL| and returns true if it was found or // Waits for omnibox text to equal (if |exactMatch|) or contain (else) |URL|
// false on timeout. Strips trailing URL slash if present as the omnibox does // and returns true if it was found or false on timeout. Strips trailing URL
// not display them. // slash if present as the omnibox does not display them.
bool WaitForOmniboxURLString(std::string URL) { bool WaitForOmniboxURLString(std::string URL, bool exactMatch = true) {
const std::string trimmed_URL = const std::string trimmed_URL =
base::TrimString(URL, "/", TrimPositions::TRIM_TRAILING).as_string(); base::TrimString(URL, "/", TrimPositions::TRIM_TRAILING).as_string();
...@@ -54,9 +55,15 @@ bool WaitForOmniboxURLString(std::string URL) { ...@@ -54,9 +55,15 @@ bool WaitForOmniboxURLString(std::string URL) {
return base::test::ios::WaitUntilConditionOrTimeout( return base::test::ios::WaitUntilConditionOrTimeout(
base::test::ios::kWaitForUIElementTimeout, ^{ base::test::ios::kWaitForUIElementTimeout, ^{
NSError* error = nil; NSError* error = nil;
[[EarlGrey selectElementWithMatcher:OmniboxText(trimmed_URL)] if (exactMatch) {
assertWithMatcher:grey_notNil() [[EarlGrey selectElementWithMatcher:OmniboxText(trimmed_URL)]
error:&error]; assertWithMatcher:grey_notNil()
error:&error];
} else {
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
assertWithMatcher:OmniboxContainingText(trimmed_URL)
error:&error];
}
return error == nil; return error == nil;
}); });
} }
...@@ -301,7 +308,9 @@ bool WaitForOmniboxURLString(std::string URL) { ...@@ -301,7 +308,9 @@ bool WaitForOmniboxURLString(std::string URL) {
GURL URL = WebUIPageUrlWithHost(kChromeUIAutofillInternalsHost); GURL URL = WebUIPageUrlWithHost(kChromeUIAutofillInternalsHost);
[ChromeEarlGrey loadURL:URL]; [ChromeEarlGrey loadURL:URL];
GREYAssert(WaitForOmniboxURLString(URL.spec()), // Autofill-Internals stores the log filter configuration in the URL's
// fragment identifier (after the hash).
GREYAssert(WaitForOmniboxURLString(URL.spec(), false),
@"Omnibox did not contain URL."); @"Omnibox did not contain URL.");
// Validates that some of the expected text on the page exists. // Validates that some of the expected text on the page exists.
......
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