Commit 9f2b44de authored by W. James MacLean's avatar W. James MacLean Committed by Commit Bot

Re-write WebFrameTest.ExternallyHandledPluginDocumentTest.DocumentType.

This CL re-implements the named test so that it is meaningful in the
context of OOPIF-based PDFs. The test (i) verifies that the embedder loads
correct boilerplate <embed> tag, and (ii) that the extension loads.

Bug: 1019367
Change-Id: I79193923d2b0572bd49bf75cb462f2db8768a901
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906181
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714699}
parent c60e58ff
......@@ -508,6 +508,50 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTestWithTestGuestViewManager,
content::GetFocusedWebContents(embedder_web_contents));
}
// This test verifies that when a PDF is loaded, that (i) the embedder
// WebContents' html consists of a single <embed> tag with appropriate
// properties, and (ii) that the guest WebContents finishes loading and
// has the correct URL for the PDF extension.
// TODO(wjmaclean): Are there any attributes we can/should test with respect to
// the extension's loaded html?
IN_PROC_BROWSER_TEST_F(PDFExtensionTestWithTestGuestViewManager,
PdfExtensionLoadedInGuest) {
// Load test HTML, and verify the text area has focus.
GURL main_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
ui_test_utils::NavigateToURL(browser(), main_url);
auto* embedder_web_contents = GetActiveWebContents();
// Verify the pdf has loaded.
auto* guest_web_contents = GetGuestViewManager()->WaitForSingleGuestCreated();
ASSERT_TRUE(guest_web_contents);
EXPECT_NE(embedder_web_contents, guest_web_contents);
EXPECT_TRUE(content::WaitForLoadStop(guest_web_contents));
// Verify we loaded the extension.
const GURL extension_url(
"chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html");
EXPECT_EQ(extension_url, guest_web_contents->GetURL());
EXPECT_EQ(main_url, embedder_web_contents->GetURL());
// Make sure the embedder has the correct html boilerplate.
EXPECT_EQ(1, content::EvalJs(embedder_web_contents,
"document.body.children.length;")
.ExtractInt());
EXPECT_EQ("EMBED", content::EvalJs(embedder_web_contents,
"document.body.firstChild.tagName;")
.ExtractString());
EXPECT_EQ("application/pdf", content::EvalJs(embedder_web_contents,
"document.body.firstChild.type;")
.ExtractString());
EXPECT_EQ("about:blank", content::EvalJs(embedder_web_contents,
"document.body.firstChild.src;")
.ExtractString());
EXPECT_TRUE(
content::EvalJs(embedder_web_contents,
"document.body.firstChild.hasAttribute('internalid');")
.ExtractBool());
}
class PDFExtensionLoadTest : public PDFExtensionTest,
public testing::WithParamInterface<int> {
public:
......
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