Commit bb5ab432 authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Verify presence of just "Process Internals" substring in page contents.

Before this CL, the test would look for "Process Model Internals"
substring in page contents.  This substring is present, but is populated
dynamically in the "Frame Trees" pane:
- WebContents: Process Model Internals, 1 frame.

To make the test less dependent on when the dynamic text is added, this
CL starts looking instead for "Process Internals" substring which is
statically present in
//content/browser/resources/process/process_internals.html

Additionally, after this CL the test inspects page contents via gMock,
rather than via innerHTML.search API.  Hopefully, the change in this CL
will make test failures easier to diagnose in the future (i.e. gMock
should display mismatched |page_contents|).  Before this CL, the test
failure would just say that |innerHTML.search| API returned -1.

Bug: 1107995
Change-Id: I83e5f45563a780b5dc8919e36ad71b2e171ac2ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317852
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791956}
parent ce7c214c
......@@ -9,6 +9,7 @@
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace content {
......@@ -28,10 +29,13 @@ IN_PROC_BROWSER_TEST_F(ProcessInternalsWebUiBrowserTest, NoProcessBindings) {
// Note: This requires using an isolated world in which to execute the
// script because WebUI has a default CSP policy denying "eval()", which is
// what EvalJs uses under the hood.
EXPECT_NE(-1,
EvalJs(shell()->web_contents()->GetMainFrame(),
"document.body.innerHTML.search('Process Model Internals');",
EXECUTE_SCRIPT_DEFAULT_OPTIONS, 1 /* world_id */));
std::string page_contents =
EvalJs(shell()->web_contents()->GetMainFrame(), "document.body.innerHTML",
EXECUTE_SCRIPT_DEFAULT_OPTIONS, 1 /* world_id */)
.ExtractString();
// Crude verification that the page had the right content.
EXPECT_THAT(page_contents, ::testing::HasSubstr("Process Internals"));
}
} // namespace content
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