Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Unified Diff: third_party/WebKit/Source/core/html/PluginDocument.cpp

Issue 1825873002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/PluginDocument.cpp
diff --git a/third_party/WebKit/Source/core/html/PluginDocument.cpp b/third_party/WebKit/Source/core/html/PluginDocument.cpp
index 9e4f57c69a07dcead5179fea28ec3b7ae88991ac..39a9de3f161d22e9f289fe99f759dff7c1222191 100644
--- a/third_party/WebKit/Source/core/html/PluginDocument.cpp
+++ b/third_party/WebKit/Source/core/html/PluginDocument.cpp
@@ -93,10 +93,15 @@ void PluginDocumentParser::createDocumentStructure()
rootElement->insertedByParser();
document()->appendChild(rootElement);
frame->loader().dispatchDocumentElementAvailable();
+ frame->loader().runScriptsAtDocumentElementAvailable();
+ if (isStopped())
+ return; // runScriptsAtDocumentElementAvailable can detach the frame.
RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document());
body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100%; width: 100%; overflow: hidden; margin: 0");
rootElement->appendChild(body);
+ if (isStopped())
+ return; // Possibly detached by a mutation event listener installed in runScriptsAtDocumentElementAvailable.
m_embedElement = HTMLEmbedElement::create(*document());
m_embedElement->setAttribute(widthAttr, "100%");
@@ -106,6 +111,8 @@ void PluginDocumentParser::createDocumentStructure()
m_embedElement->setAttribute(srcAttr, AtomicString(document()->url().string()));
m_embedElement->setAttribute(typeAttr, document()->loader()->mimeType());
body->appendChild(m_embedElement);
+ if (isStopped())
+ return; // Possibly detached by a mutation event listener installed in runScriptsAtDocumentElementAvailable.
toPluginDocument(document())->setPluginNode(m_embedElement.get());
@@ -115,8 +122,11 @@ void PluginDocumentParser::createDocumentStructure()
// below so flush the layout tasks now instead of waiting on the timer.
frame->view()->flushAnyPendingPostLayoutTasks();
// Focus the plugin here, as the line above is where the plugin is created.
- if (frame->isMainFrame())
+ if (frame->isMainFrame()) {
m_embedElement->focus();
+ if (isStopped())
+ return; // Possibly detached by a focus event listener installed in runScriptsAtDocumentElementAvailable.
+ }
if (PluginView* view = pluginView())
view->didReceiveResponse(document()->loader()->response());
@@ -124,8 +134,11 @@ void PluginDocumentParser::createDocumentStructure()
void PluginDocumentParser::appendBytes(const char* data, size_t length)
{
- if (!m_embedElement)
+ if (!m_embedElement) {
createDocumentStructure();
+ if (isStopped())
+ return;
+ }
if (!length)
return;

Powered by Google App Engine
This is Rietveld 408576698