Index: Source/core/testing/Internals.cpp |
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp |
index 83580fbb3308fc801e44acfdcece6884859f8abe..755150e256f2b545d88758dfcc359ad58cc06653 100644 |
--- a/Source/core/testing/Internals.cpp |
+++ b/Source/core/testing/Internals.cpp |
@@ -84,6 +84,7 @@ |
#include "core/html/HTMLTextAreaElement.h" |
#include "core/html/canvas/CanvasRenderingContext2D.h" |
#include "core/html/forms/FormController.h" |
+#include "core/html/shadow/PluginPlaceholderElement.h" |
#include "core/html/shadow/ShadowElementNames.h" |
#include "core/html/shadow/TextControlInnerElements.h" |
#include "core/inspector/ConsoleMessageStorage.h" |
@@ -2251,15 +2252,36 @@ void Internals::hideAllTransitionElements() |
void Internals::forcePluginPlaceholder(HTMLElement* element, const String& htmlSource, ExceptionState& exceptionState) |
{ |
- if (!element) { |
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "HTMLElement")); |
+ if (!element->isPluginElement()) { |
+ exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin."); |
return; |
} |
+ |
+ element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState); |
+ if (exceptionState.hadException()) |
+ return; |
+ |
+ toHTMLPlugInElement(element)->setUsePlaceholderContent(true); |
+} |
+ |
+void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState) |
+{ |
if (!element->isPluginElement()) { |
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin."); |
return; |
} |
- element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState); |
+ |
+ RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(element->document()); |
+ String stringValue; |
+ if (DictionaryHelper::get(options, "message", stringValue)) |
+ placeholder->setMessage(stringValue); |
+ |
+ ShadowRoot& shadowRoot = element->ensureUserAgentShadowRoot(); |
+ shadowRoot.removeChildren(); |
+ shadowRoot.appendChild(placeholder.release(), exceptionState); |
+ if (exceptionState.hadException()) |
+ return; |
+ |
toHTMLPlugInElement(element)->setUsePlaceholderContent(true); |
} |