Commit 9afe1747 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Cleanup] Use WebContentsConsoleObserver in //chrome/browser/pdf

Update tests under //chrome/browser/pdf to use
WebContentsConsoleObserver instead of ConsoleObserverDelegate.
This allows us to observe console messages added without overriding
the existing delegate of the WebContents.

Bug: 1034150
Change-Id: I03badfdb5956066553b4d6d278aae6b34ad94715
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2316702Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791916}
parent e1e57b60
......@@ -510,17 +510,16 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTestWithTestGuestViewManager,
IN_PROC_BROWSER_TEST_F(PDFExtensionTestWithTestGuestViewManager,
CSPFrameAncestorsCanBlockEmbedding) {
WebContents* web_contents = GetActiveWebContents();
auto console_delegate = std::make_unique<content::ConsoleObserverDelegate>(
web_contents,
content::WebContentsConsoleObserver console_observer(web_contents);
console_observer.SetPattern(
"*because an ancestor violates the following Content Security Policy "
"directive: \"frame-ancestors 'none'*");
web_contents->SetDelegate(console_delegate.get());
GURL main_url(embedded_test_server()->GetURL(
"/pdf/frame-test-csp-frame-ancestors-none.html"));
ui_test_utils::NavigateToURL(browser(), main_url);
console_delegate->Wait();
console_observer.Wait();
// Didn't launch a PPAPI process.
EXPECT_EQ(0, CountPDFProcesses());
......@@ -1082,17 +1081,15 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsureOpaqueOriginRepliesBlocked) {
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BlockDirectAccess) {
WebContents* web_contents = GetActiveWebContents();
std::unique_ptr<content::ConsoleObserverDelegate> console_delegate(
new content::ConsoleObserverDelegate(
web_contents,
"*Streams are only available from a mime handler view guest.*"));
web_contents->SetDelegate(console_delegate.get());
GURL forbiddenUrl(
content::WebContentsConsoleObserver console_observer(web_contents);
console_observer.SetPattern(
"*Streams are only available from a mime handler view guest.*");
GURL forbidden_url(
"chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?"
"https://example.com/notrequested.pdf");
ui_test_utils::NavigateToURL(browser(), forbiddenUrl);
ui_test_utils::NavigateToURL(browser(), forbidden_url);
console_delegate->Wait();
console_observer.Wait();
// Didn't launch a PPAPI process.
EXPECT_EQ(0, CountPDFProcesses());
......
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