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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1698183003: Allow attachShadow only for elements in the safelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove expected.txt Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 0a11d478cbcf30c71db9e5a9fcda4d510565e784..60c32e64ee104c6820c6dee9d64bd1bfdbc161a6 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1913,6 +1913,30 @@ PassRefPtrWillBeRawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scri
OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsingFeatures::Feature::ElementAttachShadow);
+ const AtomicString& tagName = localName();
+ bool tagNameIsSupported = isCustomElement()
+ || tagName == HTMLNames::articleTag
+ || tagName == HTMLNames::asideTag
+ || tagName == HTMLNames::blockquoteTag
+ || tagName == HTMLNames::bodyTag
+ || tagName == HTMLNames::divTag
+ || tagName == HTMLNames::footerTag
+ || tagName == HTMLNames::h1Tag
+ || tagName == HTMLNames::h2Tag
+ || tagName == HTMLNames::h3Tag
+ || tagName == HTMLNames::h4Tag
+ || tagName == HTMLNames::h5Tag
+ || tagName == HTMLNames::h6Tag
+ || tagName == HTMLNames::headerTag
+ || tagName == HTMLNames::navTag
+ || tagName == HTMLNames::pTag
+ || tagName == HTMLNames::sectionTag
+ || tagName == HTMLNames::spanTag;
+ if (!tagNameIsSupported) {
+ exceptionState.throwDOMException(NotSupportedError, "This element does not support attachShadow");
+ return nullptr;
+ }
+
if (shadowRootInitDict.hasMode() && shadowRoot()) {
exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree.");
return nullptr;
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698