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

Fix post-message support for MimeHandlerViewGuest, add test.

The CL https://crrev.com/737514 fixes an issue with the PDF viewer
extension not loading if another extension injects an additional iframe
into the top-level HTML document for the PDF.

Not caught in the bug description is the fact that PostMessaging support
is also broken; that was discovered (and fixed) while writing the
accompanying test.

Bug: 1046795
Change-Id: I650518162e24e5d961e45b471bfb1518e9b7531c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037343
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738361}
parent 595263ae
...@@ -2310,6 +2310,22 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DocumentWriteIntoNewPopup) { ...@@ -2310,6 +2310,22 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DocumentWriteIntoNewPopup) {
ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(popup)); ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(popup));
} }
// Tests that the PDF extension loads in the presence of an extension that, on
// the completion of document loading, adds an <iframe> to the body element.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1046795
IN_PROC_BROWSER_TEST_F(PDFExtensionTest,
PdfLoadsWithExtensionThatInjectsFrame) {
// Load the test extension.
const extensions::Extension* test_extension = LoadExtension(
GetTestResourcesParentDir().AppendASCII("extension_injects_iframe"));
ASSERT_TRUE(test_extension);
// Load the PDF. The call to LoadPdf() will return false if the pdf extension
// fails to load.
GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
ASSERT_TRUE(LoadPdf(test_pdf_url));
}
// This test suite does a simple text-extraction based on the accessibility // This test suite does a simple text-extraction based on the accessibility
// internals, breaking lines & paragraphs where appropriate. Unlike // internals, breaking lines & paragraphs where appropriate. Unlike
// TreeDumpTests, this allows us to verify the kNextOnLine and kPreviousOnLine // TreeDumpTests, this allows us to verify the kNextOnLine and kPreviousOnLine
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
document.body.appendChild(document.createElement("iframe"));
{
"content_scripts": [ {
"js": ["inject.js"],
"matches": ["<all_urls>"],
"run_at": "document_end"
}],
"description": "Test extension that breaks displaying of PDF files in Chromium.",
"manifest_version": 2,
"name": "Break PDF Display",
"permissions": [ "<all_urls>"],
"version": "0.1"
}
...@@ -313,7 +313,10 @@ blink::WebLocalFrame* MimeHandlerViewContainerManager::GetSourceFrame() { ...@@ -313,7 +313,10 @@ blink::WebLocalFrame* MimeHandlerViewContainerManager::GetSourceFrame() {
} }
blink::WebFrame* MimeHandlerViewContainerManager::GetTargetFrame() { blink::WebFrame* MimeHandlerViewContainerManager::GetTargetFrame() {
return GetSourceFrame()->FirstChild(); // Search for the frame using the 'name' attribute, since if an extension
// injects other frames into the embedder, there will be more than one frame.
return GetSourceFrame()->FindFrameByName(
blink::WebString::FromUTF8(internal_id_));
} }
bool MimeHandlerViewContainerManager::IsEmbedded() const { bool MimeHandlerViewContainerManager::IsEmbedded() const {
......
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