Title: [209610] trunk
- Revision
- 209610
- Author
- rn...@webkit.org
- Date
- 2016-12-09 09:54:56 -0800 (Fri, 09 Dec 2016)
Log Message
Custom Elements from a different document are not customized when created with innerHTML
https://bugs.webkit.org/show_bug.cgi?id=165617
Reviewed by Antti Koivisto.
Source/WebCore:
The bug was caused by a superflous null check on window in createHTMLElementOrFindCustomElementInterface.
Removed the nullcheck to fix the bug.
Test: fast/custom-elements/adopting-from-frameless-document.html
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
LayoutTests:
Added a W3C style testharness.js test.
* fast/custom-elements/adopting-from-frameless-document-expected.txt: Added.
* fast/custom-elements/adopting-from-frameless-document.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (209609 => 209610)
--- trunk/LayoutTests/ChangeLog 2016-12-09 17:45:29 UTC (rev 209609)
+++ trunk/LayoutTests/ChangeLog 2016-12-09 17:54:56 UTC (rev 209610)
@@ -1,3 +1,15 @@
+2016-12-09 Ryosuke Niwa <rn...@webkit.org>
+
+ Custom Elements from a different document are not customized when created with innerHTML
+ https://bugs.webkit.org/show_bug.cgi?id=165617
+
+ Reviewed by Antti Koivisto.
+
+ Added a W3C style testharness.js test.
+
+ * fast/custom-elements/adopting-from-frameless-document-expected.txt: Added.
+ * fast/custom-elements/adopting-from-frameless-document.html: Added.
+
2016-12-09 Daniel Bates <daba...@apple.com>
[CSP] Policy of window opener not applied to about:blank window
Added: trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document-expected.txt (0 => 209610)
--- trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document-expected.txt 2016-12-09 17:54:56 UTC (rev 209610)
@@ -0,0 +1,20 @@
+
+PASS A custom element candidate created by document.createElementNS in the document of the template elements should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in the document of the template elements should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in the document of the template elements should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.createElementNS in a new document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in a new document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in a new document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.createElementNS in a cloned document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in a cloned document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in a cloned document should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.createElementNS in a document created by createHTMLDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in a document created by createHTMLDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in a document created by createHTMLDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.createElementNS in an HTML document created by createDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in an HTML document created by createDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in an HTML document created by createDocument should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.createElementNS in an HTML document fetched by XHR should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by innerHTML in an HTML document fetched by XHR should be upgraded once adopted into a document with a definition
+PASS A custom element candidate created by document.write in an HTML document fetched by XHR should be upgraded once adopted into a document with a definition
+
Added: trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document.html (0 => 209610)
--- trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document.html (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/adopting-from-frameless-document.html 2016-12-09 17:54:56 UTC (rev 209610)
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Custom Elements: A custom element candidate created in a frameless document should be upgraded once adopted into a document with a definition</title>
+<meta name="author" title="Ryosuke Niwa" href=""
+<meta name="assert" content="A custom element candidate created in a frameless document should be upgraded once adopted into a document with a definition">
+<meta name="help" content="https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token">
+<meta name="help" content="https://dom.spec.whatwg.org/#concept-create-element">
+<meta name="help" content="https://dom.spec.whatwg.org/#concept-node-insert">
+<meta name="help" content="https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade">
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="log"></div>
+<script>
+
+let customElement = define_custom_element_in_window(window, 'test-element', []);
+
+document_types().forEach((entry) => {
+ if (entry.isOwner || entry.hasBrowsingContext)
+ return;
+
+ promise_test(() => {
+ return entry.create().then((doc) => {
+ assert_array_equals(customElement.takeLog().types(), []);
+ let instance = doc.createElementNS('http://www.w3.org/1999/xhtml', 'test-element');
+ doc.documentElement.appendChild(instance);
+ assert_array_equals(customElement.takeLog().types(), []);
+ document.body.appendChild(instance);
+ assert_array_equals(customElement.takeLog().types(), ['constructed', 'connected']);
+ instance.remove();
+ assert_array_equals(customElement.takeLog().types(), ['disconnected']);
+ });
+ }, `A custom element candidate created by document.createElementNS in ${entry.name} should be upgraded once adopted into a document with a definition`);
+
+ promise_test(() => {
+ return entry.create().then((doc) => {
+ assert_array_equals(customElement.takeLog().types(), []);
+ doc.documentElement.innerHTML = '<test-element xmlns="http://www.w3.org/1999/xhtml"></test-element>';
+ let instance = doc.querySelector('test-element');
+ assert_array_equals(customElement.takeLog().types(), []);
+ document.body.appendChild(instance);
+ assert_array_equals(customElement.takeLog().types(), ['constructed', 'connected']);
+ instance.remove();
+ assert_array_equals(customElement.takeLog().types(), ['disconnected']);
+ });
+ }, `A custom element candidate created by innerHTML in ${entry.name} should be upgraded once adopted into a document with a definition`);
+
+ promise_test(() => {
+ return entry.create().then((doc) => {
+ assert_array_equals(customElement.takeLog().types(), []);
+ try {
+ doc.open();
+ doc.write('<!DOCTYPE html><test-element></test-element>');
+ doc.close();
+ } catch (e) {
+ // The standards mandates that all documents have document.write but in reality, no browser implements this.
+ return;
+ }
+
+ let instance = doc.querySelector('test-element');
+ assert_array_equals(customElement.takeLog().types(), []);
+ document.body.appendChild(instance);
+ assert_array_equals(customElement.takeLog().types(), ['constructed', 'connected']);
+ instance.remove();
+ assert_array_equals(customElement.takeLog().types(), ['disconnected']);
+ });
+ }, `A custom element candidate created by document.write in ${entry.name} should be upgraded once adopted into a document with a definition`);
+
+});
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (209609 => 209610)
--- trunk/Source/WebCore/ChangeLog 2016-12-09 17:45:29 UTC (rev 209609)
+++ trunk/Source/WebCore/ChangeLog 2016-12-09 17:54:56 UTC (rev 209610)
@@ -1,3 +1,18 @@
+2016-12-09 Ryosuke Niwa <rn...@webkit.org>
+
+ Custom Elements from a different document are not customized when created with innerHTML
+ https://bugs.webkit.org/show_bug.cgi?id=165617
+
+ Reviewed by Antti Koivisto.
+
+ The bug was caused by a superflous null check on window in createHTMLElementOrFindCustomElementInterface.
+ Removed the nullcheck to fix the bug.
+
+ Test: fast/custom-elements/adopting-from-frameless-document.html
+
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
+
2016-12-09 Daniel Bates <daba...@apple.com>
[CSP] Policy of window opener not applied to about:blank window
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (209609 => 209610)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2016-12-09 17:45:29 UTC (rev 209609)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2016-12-09 17:54:56 UTC (rev 209610)
@@ -666,7 +666,7 @@
}
QualifiedName qualifiedName(nullAtom, localName, xhtmlNamespaceURI);
- if (window && Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) {
+ if (Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) {
element = HTMLElement::create(qualifiedName, ownerDocument);
element->setIsCustomElementUpgradeCandidate();
} else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes