Changeset 197528 in webkit
- Timestamp:
- Mar 3, 2016 4:28:44 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r197524 r197528 1 2016-03-02 Ryosuke Niwa <rniwa@webkit.org> 2 3 Disallow custom elements inside template elements and share the registry for windowless documents 4 https://bugs.webkit.org/show_bug.cgi?id=154944 5 <rdar://problem/24944875> 6 7 Reviewed by Antti Koivisto. 8 9 Added various tests to ensure the custom elements registry is not shared between documents with 10 distinct browsing context (e.g. iframes) but shared among the ones that share a single browsing context 11 (e.g. documents created by DOMImplementation). 12 13 Also added a test case for defineCustomElement to ensure it throws NotSupportedError when it's called on 14 a template element's inert owner document as well as a basic test case for document.write. 15 16 * fast/custom-elements/Document-defineCustomElement-expected.txt: 17 * fast/custom-elements/Document-defineCustomElement.html: Added a new test case. 18 * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write-expected.txt: Added. 19 * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: Added. 20 * fast/custom-elements/parser/parser-uses-registry-of-owner-document-expected.txt: Added. 21 * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: Added. 22 1 23 2016-03-03 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt
r195087 r197528 3 3 PASS document.defineCustomElement should throw with an invalid name 4 4 PASS document.defineCustomElement should throw with a duplicate name 5 PASS document.defineCustomElement must throw a NotSupportedError when the context object is an associated inert template document 6 PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument 7 PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument 5 8 PASS document.defineCustomElement should throw when the element interface is not a constructor 6 9 PASS document.defineCustomElement should define an instantiatable custom element -
trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html
r195087 r197528 59 59 60 60 test(function () { 61 class SomeCustomElement extends HTMLElement {}; 62 63 var templateContentOwnerDocument = document.createElement('template').content.ownerDocument; 64 assert_throws({'name': 'NotSupportedError'}, function () { 65 templateContentOwnerDocument.defineCustomElement('some-custom-element', SomeCustomElement); 66 }); 67 68 }, 'document.defineCustomElement must throw a NotSupportedError when the context object is an associated inert template document'); 69 70 test(function () { 71 class SomeCustomElement extends HTMLElement {}; 72 73 var windowlessDocument = document.implementation.createHTMLDocument(); 74 assert_throws({'name': 'NotSupportedError'}, function () { 75 windowlessDocument.defineCustomElement('some-custom-element', SomeCustomElement); 76 }); 77 78 }, 'document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument'); 79 80 test(function () { 81 class SomeCustomElement extends HTMLElement {}; 82 83 var windowlessDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null) 84 assert_throws({'name': 'NotSupportedError'}, function () { 85 windowlessDocument.defineCustomElement('some-custom-element', SomeCustomElement); 86 }); 87 88 }, 'document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument'); 89 90 test(function () { 61 91 assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', 1); }, 62 92 'document.defineCustomElement must throw a TypeError when the element interface is a number'); -
trunk/Source/WebCore/ChangeLog
r197527 r197528 1 2016-03-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 Disallow custom elements inside a window-less documents 4 https://bugs.webkit.org/show_bug.cgi?id=154944 5 <rdar://problem/24944875> 6 7 Reviewed by Antti Koivisto. 8 9 Disallow custom elements inside a window-less documents such as the shared inert document of template elements 10 and the ones created by DOMImplementation.createDocument and DOMImplementation.createHTMLDocument. 11 12 Throw NotSupportedError in defineCustomElement when it's called in such a document as discussed in: 13 https://github.com/w3c/webcomponents/issues/369 14 15 Tests: fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html 16 fast/custom-elements/parser/parser-uses-registry-of-owner-document.html 17 18 * bindings/js/JSDOMBinding.cpp: 19 (WebCore::throwNotSupportedError): Added. 20 * bindings/js/JSDOMBinding.h: 21 * bindings/js/JSDocumentCustom.cpp: 22 (WebCore::JSDocument::defineCustomElement): Throw NotSupportedError when the context object's document doesn't 23 have a browsing context (i.e. window-less). 24 * html/parser/HTMLDocumentParser.cpp: 25 (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Replaced a FIXME with an assertion now that we 26 disallow instantiation of custom elements inside a template element. 27 1 28 2016-03-03 Alex Christensen <achristensen@webkit.org> 2 29 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r197353 r197528 636 636 } 637 637 638 void throwNotSupportedError(JSC::ExecState& state, const char* message) 639 { 640 ASSERT(!state.hadException()); 641 String messageString(message); 642 state.vm().throwException(&state, createDOMException(&state, NOT_SUPPORTED_ERR, &messageString)); 643 } 644 638 645 JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState& state, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues) 639 646 { -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r197353 r197528 85 85 WEBCORE_EXPORT void reportDeprecatedSetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName); 86 86 87 void throwNotSupportedError(JSC::ExecState&, const char* message); 87 88 void throwArrayElementTypeError(JSC::ExecState&); 88 89 void throwAttributeTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName, const char* expectedType); -
trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r195520 r197528 148 148 149 149 Document& document = wrapped(); 150 if (!document.domWindow()) { 151 throwNotSupportedError(state, "Cannot define a custom element in a docuemnt without a browsing context"); 152 return jsUndefined(); 153 } 154 150 155 switch (CustomElementDefinitions::checkName(tagName)) { 151 156 case CustomElementDefinitions::NameStatus::Valid: … … 162 167 auto& definitions = document.ensureCustomElementDefinitions(); 163 168 if (definitions.findInterface(tagName)) { 164 ExceptionCodeWithMessage ec; 165 ec.code = NOT_SUPPORTED_ERR; 166 ec.message = "Cannot define multiple custom elements with the same tag name"; 167 setDOMException(&state, ec); 169 throwNotSupportedError(state, "Cannot define multiple custom elements with the same tag name"); 168 170 return jsUndefined(); 169 171 } -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r197463 r197528 197 197 RefPtr<Element> newElement = constructionData->interface->constructElement(constructionData->name, JSCustomElementInterface::ShouldClearException::Clear); 198 198 if (!newElement) { 199 // FIXME: This call to docuemnt() is wrong for elements inside a template element.199 ASSERT(!m_treeBuilder->isParsingTemplateContents()); 200 200 newElement = HTMLUnknownElement::create(QualifiedName(nullAtom, constructionData->name, xhtmlNamespaceURI), *document()); 201 201 } -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r197463 r197528 62 62 void constructTree(AtomicHTMLToken&); 63 63 64 bool isParsingTemplateContents() const; 64 65 bool hasParserBlockingScriptWork() const; 65 66 … … 108 109 }; 109 110 110 bool isParsingTemplateContents() const;111 111 bool isParsingFragmentOrTemplateContents() const; 112 112
Note: See TracChangeset
for help on using the changeset viewer.