<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197602] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197602">197602</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-04 17:23:42 -0800 (Fri, 04 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update defineCustomElement according to the spec rewrite
https://bugs.webkit.org/show_bug.cgi?id=155010
<rdar://problem/24970878>
Reviewed by Chris Dumez.
Source/WebCore:
Updated the implementation of defineCustomElement and HTMLConstructor per recent rewrite of the spec:
https://w3c.github.io/webcomponents/spec/custom/#dom-document-defineelement
https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor
defineCustomElement is now called defineElement and we disallow defining multiple custom elements with
a single class and throw an exception in defineElement.
Test: fast/custom-elements/Document-defineElement.html
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::defineElement): Renamed from defineCustomElement. Throw an exception when the interface
already defines another custom element. Also added FIXME's for missing steps.
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement): Removed the support for specifying a tag name in the first argument when
a single class defines multiple custom elements since that now results in an exception (in defineElement).
* dom/CustomElementDefinitions.cpp:
(WebCore::CustomElementDefinitions::containsConstructor): Added.
* dom/CustomElementDefinitions.h:
* dom/Document.idl: Renamed defineCustomElement to defineElement.
* html/HTMLElement.idl: Removed the optional tag name from the constructor.
LayoutTests:
Update the tests for the rename and semantics change of defineCustomElement and HTMLElement constructor.
* fast/custom-elements/Document-createElement.html:
* fast/custom-elements/Document-defineCustomElement-expected.txt: Removed.
* fast/custom-elements/Document-defineCustomElement.html: Removed.
* fast/custom-elements/Document-defineElement-expected.txt: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt.
* fast/custom-elements/Document-defineElement.html: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement.html.
Also added a test case for defining multiple custom elements with a single class, which must throw.
* fast/custom-elements/HTMLElement-constructor-expected.txt:
* fast/custom-elements/HTMLElement-constructor.html:
Removed test cases for the tag name in the first argument as well as ones that associate a single class with multiple tag names.
* fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html:
* fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html:
* fast/custom-elements/parser/parser-constructs-custom-elements.html:
* fast/custom-elements/parser/parser-fallsback-to-unknown-element.html:
* fast/custom-elements/parser/parser-sets-attributes-and-children.html:
* fast/custom-elements/parser/parser-uses-constructed-element.html:
* fast/custom-elements/parser/parser-uses-registry-of-owner-document.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentcreateElementhtml">trunk/LayoutTests/fast/custom-elements/Document-createElement.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsHTMLElementconstructorexpectedtxt">trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsHTMLElementconstructorhtml">trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementindocumentwritehtml">trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementsynchronouslyhtml">trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementshtml">trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserfallsbacktounknownelementhtml">trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparsersetsattributesandchildrenhtml">trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserusesconstructedelementhtml">trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsparserparserusesregistryofownerdocumenthtml">trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDocumentCustomcpp">trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementDefinitionscpp">trunk/Source/WebCore/dom/CustomElementDefinitions.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementDefinitionsh">trunk/Source/WebCore/dom/CustomElementDefinitions.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementidl">trunk/Source/WebCore/html/HTMLElement.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineElementexpectedtxt">trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineElementhtml">trunk/LayoutTests/fast/custom-elements/Document-defineElement.html</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementexpectedtxt">trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementhtml">trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/ChangeLog        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-03-04 Ryosuke Niwa <rniwa@webkit.org>
+
+ Update defineCustomElement according to the spec rewrite
+ https://bugs.webkit.org/show_bug.cgi?id=155010
+ <rdar://problem/24970878>
+
+ Reviewed by Chris Dumez.
+
+ Update the tests for the rename and semantics change of defineCustomElement and HTMLElement constructor.
+
+ * fast/custom-elements/Document-createElement.html:
+ * fast/custom-elements/Document-defineCustomElement-expected.txt: Removed.
+ * fast/custom-elements/Document-defineCustomElement.html: Removed.
+ * fast/custom-elements/Document-defineElement-expected.txt: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt.
+ * fast/custom-elements/Document-defineElement.html: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement.html.
+ Also added a test case for defining multiple custom elements with a single class, which must throw.
+ * fast/custom-elements/HTMLElement-constructor-expected.txt:
+ * fast/custom-elements/HTMLElement-constructor.html:
+ Removed test cases for the tag name in the first argument as well as ones that associate a single class with multiple tag names.
+ * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html:
+ * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html:
+ * fast/custom-elements/parser/parser-constructs-custom-elements.html:
+ * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html:
+ * fast/custom-elements/parser/parser-sets-attributes-and-children.html:
+ * fast/custom-elements/parser/parser-uses-constructed-element.html:
+ * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html:
+
</ins><span class="cx"> 2016-03-04 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Use larger tiles when possible to reduce per-tile painting overhead
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentcreateElementhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/Document-createElement.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-createElement.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/Document-createElement.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> assert_true(document.createElement('my-custom-element') instanceof HTMLElement);
</span><span class="cx"> assert_false(document.createElement('my-custom-element') instanceof MyCustomElement);
</span><span class="cx">
</span><del>- document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+ document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx"> var instance = document.createElement('my-custom-element');
</span><span class="cx"> assert_true(instance instanceof MyCustomElement);
</span><span class="cx"> assert_equals(instance.localName, 'my-custom-element');
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> return {foo: 'bar'};
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>- document.defineCustomElement('object-custom-element', ObjectCustomElement);
</del><ins>+ document.defineElement('object-custom-element', ObjectCustomElement);
</ins><span class="cx">
</span><span class="cx"> var instance = new ObjectCustomElement;
</span><span class="cx"> assert_true(instance instanceof Object);
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> return document.createTextNode('hello');
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>- document.defineCustomElement('text-custom-element', TextCustomElement);
</del><ins>+ document.defineElement('text-custom-element', TextCustomElement);
</ins><span class="cx"> assert_true(new TextCustomElement instanceof Text);
</span><span class="cx"> assert_equals(document.createElement('object-custom-element'), null);
</span><span class="cx"> }, 'document.createElement must return null when a custom element constructor returns a Text node');
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> return createdElement;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>- document.defineCustomElement('div-custom-element', DivCustomElement);
</del><ins>+ document.defineElement('div-custom-element', DivCustomElement);
</ins><span class="cx"> assert_true(new DivCustomElement instanceof HTMLDivElement);
</span><span class="cx">
</span><span class="cx"> var instance = document.createElement('div-custom-element');
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> throw exceptionToThrow;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>- document.defineCustomElement('throw-custom-element', ThrowCustomElement);
</del><ins>+ document.defineElement('throw-custom-element', ThrowCustomElement);
</ins><span class="cx">
</span><span class="cx"> assert_throws(null, function () { new ThrowCustomElement; });
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -1,10 +0,0 @@
</span><del>-
-PASS Check the existence of defineCustomElement on Document interface
-PASS document.defineCustomElement should throw with an invalid name
-PASS document.defineCustomElement should throw with a duplicate name
-PASS document.defineCustomElement must throw a NotSupportedError when the context object is an associated inert template document
-PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument
-PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument
-PASS document.defineCustomElement should throw when the element interface is not a constructor
-PASS document.defineCustomElement should define an instantiatable custom element
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -1,122 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<title>Custom Elements: Extensions to Document interface</title>
-<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
-<meta name="assert" content="document.defineCustomElement should define a custom element">
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-<link rel='stylesheet' href='../../resources/testharness.css'>
-</head>
-<body>
-<div id="log"></div>
-<script>
-
-test(function () {
- assert_true('defineCustomElement' in Document.prototype, '"defineCustomElement" exists on Document.prototype');
- assert_true('defineCustomElement' in document, '"defineCustomElement" exists on document');
-}, 'Check the existence of defineCustomElement on Document interface');
-
-test(function () {
- class MyCustomElement extends HTMLElement {};
-
- assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement(null, MyCustomElement); },
- 'document.defineCustomElement must throw a SyntaxError if the tag name is null');
- assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('', MyCustomElement); },
- 'document.defineCustomElement must throw a SyntaxError if the tag name is empty');
- assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('abc', MyCustomElement); },
- 'document.defineCustomElement must throw a SyntaxError if the tag name does not contain "-"');
- assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('a-Bc', MyCustomElement); },
- 'document.defineCustomElement must throw a SyntaxError if the tag name contains an upper case letter');
-
- var builtinTagNames = [
- 'annotation-xml',
- 'color-profile',
- 'font-face',
- 'font-face-src',
- 'font-face-uri',
- 'font-face-format',
- 'font-face-name',
- 'missing-glyph'
- ];
-
- for (var tagName of builtinTagNames) {
- assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement(tagName, MyCustomElement); },
- 'document.defineCustomElement must throw a SyntaxError if the tag name is "' + tagName + '"');
- }
-
-}, 'document.defineCustomElement should throw with an invalid name');
-
-test(function () {
- class SomeCustomElement extends HTMLElement {};
- class OtherCustomElement extends HTMLElement {};
-
- document.defineCustomElement('some-custom-element', SomeCustomElement);
- assert_throws({'name': 'NotSupportedError'}, function () { document.defineCustomElement('some-custom-element', OtherCustomElement); },
- 'document.defineCustomElement must throw a NotSupportedError if the specified tag name is already used');
-
-}, 'document.defineCustomElement should throw with a duplicate name');
-
-test(function () {
- class SomeCustomElement extends HTMLElement {};
-
- var templateContentOwnerDocument = document.createElement('template').content.ownerDocument;
- assert_throws({'name': 'NotSupportedError'}, function () {
- templateContentOwnerDocument.defineCustomElement('some-custom-element', SomeCustomElement);
- });
-
-}, 'document.defineCustomElement must throw a NotSupportedError when the context object is an associated inert template document');
-
-test(function () {
- class SomeCustomElement extends HTMLElement {};
-
- var windowlessDocument = document.implementation.createHTMLDocument();
- assert_throws({'name': 'NotSupportedError'}, function () {
- windowlessDocument.defineCustomElement('some-custom-element', SomeCustomElement);
- });
-
-}, 'document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument');
-
-test(function () {
- class SomeCustomElement extends HTMLElement {};
-
- var windowlessDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null)
- assert_throws({'name': 'NotSupportedError'}, function () {
- windowlessDocument.defineCustomElement('some-custom-element', SomeCustomElement);
- });
-
-}, 'document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument');
-
-test(function () {
- assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', 1); },
- 'document.defineCustomElement must throw a TypeError when the element interface is a number');
- assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', '123'); },
- 'document.defineCustomElement must throw a TypeError when the element interface is a string');
- assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', {}); },
- 'document.defineCustomElement must throw a TypeError when the element interface is an object');
- assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', []); },
- 'document.defineCustomElement must throw a TypeError when the element interface is an array');
-}, 'document.defineCustomElement should throw when the element interface is not a constructor');
-
-test(function () {
- class MyCustomElement extends HTMLElement {};
- document.defineCustomElement('my-custom-element', MyCustomElement);
-
- var instance = new MyCustomElement;
- assert_true(instance instanceof MyCustomElement,
- 'An instance of a custom HTML element be an instance of the associated interface');
-
- assert_true(instance instanceof HTMLElement,
- 'An instance of a custom HTML element must inherit from HTMLElement');
-
- assert_equals(instance.localName, 'my-custom-element',
- 'An instance of a custom element must use the associated tag name');
-
- assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml',
- 'A custom element HTML must use HTML namespace');
-
-}, 'document.defineCustomElement should define an instantiatable custom element');
-
-</script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineElementexpectedtxtfromrev197596trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt (from rev 197596, trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt) (0 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+
+PASS Check the existence of defineElement on Document interface
+PASS document.defineElement should throw with an invalid name
+PASS document.defineElement should throw when there is already a custom element of the same name
+PASS document.defineElement should throw when there is already a custom element with the same class
+PASS document.defineElement must throw a NotSupportedError when the context object is an associated inert template document
+PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument
+PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument
+PASS document.defineElement should throw when the element interface is not a constructor
+PASS document.defineElement should define an instantiatable custom element
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineElementhtmlfromrev197596trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fast/custom-elements/Document-defineElement.html (from rev 197596, trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html) (0 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineElement.html         (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineElement.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -0,0 +1,131 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>Custom Elements: Extensions to Document interface</title>
+<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
+<meta name="assert" content="document.defineElement should define a custom element">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<link rel='stylesheet' href='../../resources/testharness.css'>
+</head>
+<body>
+<div id="log"></div>
+<script>
+
+test(function () {
+ assert_true('defineElement' in Document.prototype, '"defineElement" exists on Document.prototype');
+ assert_true('defineElement' in document, '"defineElement" exists on document');
+}, 'Check the existence of defineElement on Document interface');
+
+test(function () {
+ class MyCustomElement extends HTMLElement {};
+
+ assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(null, MyCustomElement); },
+ 'document.defineElement must throw a SyntaxError if the tag name is null');
+ assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('', MyCustomElement); },
+ 'document.defineElement must throw a SyntaxError if the tag name is empty');
+ assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('abc', MyCustomElement); },
+ 'document.defineElement must throw a SyntaxError if the tag name does not contain "-"');
+ assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('a-Bc', MyCustomElement); },
+ 'document.defineElement must throw a SyntaxError if the tag name contains an upper case letter');
+
+ var builtinTagNames = [
+ 'annotation-xml',
+ 'color-profile',
+ 'font-face',
+ 'font-face-src',
+ 'font-face-uri',
+ 'font-face-format',
+ 'font-face-name',
+ 'missing-glyph'
+ ];
+
+ for (var tagName of builtinTagNames) {
+ assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(tagName, MyCustomElement); },
+ 'document.defineElement must throw a SyntaxError if the tag name is "' + tagName + '"');
+ }
+
+}, 'document.defineElement should throw with an invalid name');
+
+test(function () {
+ class SomeCustomElement extends HTMLElement {};
+ class OtherCustomElement extends HTMLElement {};
+
+ document.defineElement('some-custom-element', SomeCustomElement);
+ assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-custom-element', OtherCustomElement); },
+ 'document.defineElement must throw a NotSupportedError if the specified tag name is already used');
+
+}, 'document.defineElement should throw when there is already a custom element of the same name');
+
+test(function () {
+ class AnotherCustomElement extends HTMLElement {};
+
+ document.defineElement('another-custom-element', AnotherCustomElement);
+ assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-other-element', AnotherCustomElement); },
+ 'document.defineElement must throw a NotSupportedError if the specified class already defines an element');
+
+}, 'document.defineElement should throw when there is already a custom element with the same class');
+
+test(function () {
+ class SomeCustomElement extends HTMLElement {};
+
+ var templateContentOwnerDocument = document.createElement('template').content.ownerDocument;
+ assert_throws({'name': 'NotSupportedError'}, function () {
+ templateContentOwnerDocument.defineElement('some-custom-element', SomeCustomElement);
+ });
+
+}, 'document.defineElement must throw a NotSupportedError when the context object is an associated inert template document');
+
+test(function () {
+ class SomeCustomElement extends HTMLElement {};
+
+ var windowlessDocument = document.implementation.createHTMLDocument();
+ assert_throws({'name': 'NotSupportedError'}, function () {
+ windowlessDocument.defineElement('some-custom-element', SomeCustomElement);
+ });
+
+}, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument');
+
+test(function () {
+ class SomeCustomElement extends HTMLElement {};
+
+ var windowlessDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null)
+ assert_throws({'name': 'NotSupportedError'}, function () {
+ windowlessDocument.defineElement('some-custom-element', SomeCustomElement);
+ });
+
+}, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument');
+
+test(function () {
+ assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', 1); },
+ 'document.defineElement must throw a TypeError when the element interface is a number');
+ assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', '123'); },
+ 'document.defineElement must throw a TypeError when the element interface is a string');
+ assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', {}); },
+ 'document.defineElement must throw a TypeError when the element interface is an object');
+ assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', []); },
+ 'document.defineElement must throw a TypeError when the element interface is an array');
+}, 'document.defineElement should throw when the element interface is not a constructor');
+
+test(function () {
+ class MyCustomElement extends HTMLElement {};
+ document.defineElement('my-custom-element', MyCustomElement);
+
+ var instance = new MyCustomElement;
+ assert_true(instance instanceof MyCustomElement,
+ 'An instance of a custom HTML element be an instance of the associated interface');
+
+ assert_true(instance instanceof HTMLElement,
+ 'An instance of a custom HTML element must inherit from HTMLElement');
+
+ assert_equals(instance.localName, 'my-custom-element',
+ 'An instance of a custom element must use the associated tag name');
+
+ assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml',
+ 'A custom element HTML must use HTML namespace');
+
+}, 'document.defineElement should define an instantiatable custom element');
+
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsHTMLElementconstructorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -2,7 +2,6 @@
</span><span class="cx"> PASS HTMLElement constructor must throw a TypeError when there is no derived class
</span><span class="cx"> PASS HTMLElement constructor must throw TypeError when custom element is not well defined
</span><span class="cx"> PASS HTMLElement constructor must infer the tag name from the element interface
</span><del>-PASS HTMLElement constructor must allow associating an element interface with multiple tag names
</del><span class="cx"> PASS HTMLElement constructor must allow subclassing a custom element
</span><span class="cx"> PASS HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsHTMLElementconstructorhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -14,34 +14,19 @@
</span><span class="cx">
</span><span class="cx"> test(function () {
</span><span class="cx"> class SomeDefinedElement extends HTMLElement {};
</span><del>- document.defineCustomElement('defined-element', SomeDefinedElement);
</del><ins>+ document.defineElement('defined-element', SomeDefinedElement);
</ins><span class="cx"> assert_throws({'name': 'TypeError'}, function () { new HTMLElement('defined-element'); });
</span><span class="cx"> }, 'HTMLElement constructor must throw a TypeError when there is no derived class');
</span><span class="cx">
</span><span class="cx"> test(function () {
</span><span class="cx"> class SomeCustomElement extends HTMLElement {};
</span><span class="cx"> assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement; },
</span><del>- 'Instantiating a custom element without calling defineCustomElement must throw TypeError');
-
- class AnotherCustomElement extends HTMLElement {
- constructor() { super('some-element'); }
- };
- document.defineCustomElement('another-element', AnotherCustomElement);
- assert_throws({'name': 'TypeError'}, function () { new AnotherCustomElement; },
- 'Calling HTMLElement constructor with a mismatching tag name throw TypeError');
-
- class YetAnotherCustomElement extends HTMLElement {
- constructor() { super(1); }
- };
- document.defineCustomElement('yet-another-element', YetAnotherCustomElement);
- assert_throws({'name': 'TypeError'}, function () { new YetAnotherCustomElement; },
- 'Calling HTMLElement constructor with a bad tag name throw TypeError');
-
</del><ins>+ 'Instantiating a custom element without calling defineElement must throw TypeError');
</ins><span class="cx"> }, 'HTMLElement constructor must throw TypeError when custom element is not well defined');
</span><span class="cx">
</span><span class="cx"> test(function () {
</span><span class="cx"> class CustomElementWithInferredTagName extends HTMLElement {};
</span><del>- document.defineCustomElement('inferred-name', CustomElementWithInferredTagName);
</del><ins>+ document.defineElement('inferred-name', CustomElementWithInferredTagName);
</ins><span class="cx">
</span><span class="cx"> var instance = new CustomElementWithInferredTagName;
</span><span class="cx"> assert_true(instance instanceof Element, 'A custom element must inherit from Element');
</span><span class="lines">@@ -59,32 +44,19 @@
</span><span class="cx"> }, 'HTMLElement constructor must infer the tag name from the element interface');
</span><span class="cx">
</span><span class="cx"> test(function () {
</span><del>- class ElementWithMultipleTagNames extends HTMLElement { };
- document.defineCustomElement('custom-element-1', ElementWithMultipleTagNames);
- document.defineCustomElement('custom-element-2', ElementWithMultipleTagNames);
-
- var instance1 = new ElementWithMultipleTagNames('custom-element-1');
- assert_true(instance1 instanceof ElementWithMultipleTagNames);
- assert_equals(instance1.localName, 'custom-element-1');
- assert_equals(instance1.nodeName, 'CUSTOM-ELEMENT-1');
-
- var instance2 = new ElementWithMultipleTagNames('custom-element-2');
- assert_true(instance2 instanceof ElementWithMultipleTagNames);
- assert_equals(instance2.localName, 'custom-element-2');
- assert_equals(instance2.nodeName, 'CUSTOM-ELEMENT-2');
-
- assert_throws({'name': 'TypeError'}, function () { new ElementWithMultipleTagNames; },
- 'Instantiating an element interface associated with multiple tag names without specifying the tag name must throw TypeError');
-
-}, 'HTMLElement constructor must allow associating an element interface with multiple tag names');
-
-test(function () {
</del><span class="cx"> class ConcreteCustomElement extends HTMLElement { };
</span><span class="cx"> class SubCustomElement extends ConcreteCustomElement { };
</span><del>- document.defineCustomElement('concrete-custom-element', ConcreteCustomElement);
- document.defineCustomElement('sub-custom-element', SubCustomElement);
</del><ins>+ document.defineElement('concrete-custom-element', ConcreteCustomElement);
+ document.defineElement('sub-custom-element', SubCustomElement);
</ins><span class="cx">
</span><ins>+ var instance = new ConcreteCustomElement();
+ assert_true(instance instanceof ConcreteCustomElement);
+ assert_false(instance instanceof SubCustomElement);
+ assert_equals(instance.localName, 'concrete-custom-element');
+ assert_equals(instance.nodeName, 'CONCRETE-CUSTOM-ELEMENT');
+
</ins><span class="cx"> var instance = new SubCustomElement();
</span><ins>+ assert_true(instance instanceof ConcreteCustomElement);
</ins><span class="cx"> assert_true(instance instanceof SubCustomElement);
</span><span class="cx"> assert_equals(instance.localName, 'sub-custom-element');
</span><span class="cx"> assert_equals(instance.nodeName, 'SUB-CUSTOM-ELEMENT');
</span><span class="lines">@@ -94,9 +66,10 @@
</span><span class="cx"> test(function () {
</span><span class="cx"> class AbstractCustomElement extends HTMLElement { };
</span><span class="cx"> class ConcreteSubCustomElement extends AbstractCustomElement { };
</span><del>- document.defineCustomElement('concrete-sub-custom-element', ConcreteSubCustomElement);
</del><ins>+ document.defineElement('concrete-sub-custom-element', ConcreteSubCustomElement);
</ins><span class="cx">
</span><span class="cx"> var instance = new ConcreteSubCustomElement();
</span><ins>+ assert_true(instance instanceof AbstractCustomElement);
</ins><span class="cx"> assert_true(instance instanceof ConcreteSubCustomElement);
</span><span class="cx"> assert_equals(instance.localName, 'concrete-sub-custom-element');
</span><span class="cx"> assert_equals(instance.nodeName, 'CONCRETE-SUB-CUSTOM-ELEMENT');
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementindocumentwritehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> <script>
</span><span class="cx">
</span><span class="cx"> class MyCustomElement extends HTMLElement { }
</span><del>-document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx">
</span><span class="cx"> document.write('<my-custom-element></my-custom-element>');
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementsynchronouslyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> containerNextSilbingInConstructor = container.nextSibling;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <div id="custom-element-container">
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserconstructscustomelementshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">
</span><span class="cx"> }, 'HTML parser must NOT create a custom element before defineElement is called');
</span><span class="cx">
</span><del>-document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <my-custom-element id="instance2"></my-custom-element>
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserfallsbacktounknownelementhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> return document.createTextNode('some text');
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('returns-text', ReturnsTextNode);
</del><ins>+document.defineElement('returns-text', ReturnsTextNode);
</ins><span class="cx">
</span><span class="cx"> class ReturnsNonElementObject extends HTMLElement {
</span><span class="cx"> constructor() {
</span><span class="lines">@@ -26,19 +26,19 @@
</span><span class="cx"> return {};
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('returns-non-element-object', ReturnsNonElementObject);
</del><ins>+document.defineElement('returns-non-element-object', ReturnsNonElementObject);
</ins><span class="cx">
</span><span class="cx"> class LacksSuperCall extends HTMLElement {
</span><span class="cx"> constructor() { }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('lacks-super-call', LacksSuperCall);
</del><ins>+document.defineElement('lacks-super-call', LacksSuperCall);
</ins><span class="cx">
</span><span class="cx"> class ThrowsException extends HTMLElement {
</span><span class="cx"> constructor() {
</span><span class="cx"> throw 'Bad';
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('throws-exception', ThrowsException);
</del><ins>+document.defineElement('throws-exception', ThrowsException);
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <returns-text></returns-text>
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparsersetsattributesandchildrenhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> numberOfChildNodesInConstructor = this.childNodes.length;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <my-custom-element id="custom-element-id" class="class1 class2">hello <b>world</b></my-custom-element>
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserusesconstructedelementhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> elementCreatedBySuperCall = this;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);
</del><ins>+document.defineElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);
</ins><span class="cx">
</span><span class="cx"> let shouldCreateAnotherInstance = true;
</span><span class="cx"> let anotherInstance = undefined;
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> return this;
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>-document.defineCustomElement('returns-another-instance', ReturnsAnotherInstance);
</del><ins>+document.defineElement('returns-another-instance', ReturnsAnotherInstance);
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <instantiates-itself-before-super></instantiates-itself-before-super>
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsparserparserusesregistryofownerdocumenthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> <script>
</span><span class="cx">
</span><span class="cx"> class MyCustomElement extends HTMLElement { };
</span><del>-document.defineCustomElement('my-custom-element', MyCustomElement);
</del><ins>+document.defineElement('my-custom-element', MyCustomElement);
</ins><span class="cx">
</span><span class="cx"> document.write('<template><my-custom-element></my-custom-element></template>');
</span><span class="cx">
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> }, 'HTML parser must not use the registry of the owner element\'s document inside an iframe');
</span><span class="cx">
</span><span class="cx"> class ElementInIFrame extends iframe.contentWindow.HTMLElement { };
</span><del>-iframe.contentDocument.defineCustomElement('element-in-iframe', ElementInIFrame);
</del><ins>+iframe.contentDocument.defineElement('element-in-iframe', ElementInIFrame);
</ins><span class="cx"> iframe.contentDocument.body.innerHTML = '<element-in-iframe></element-in-iframe>';
</span><span class="cx">
</span><span class="cx"> test(function () {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/ChangeLog        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-03-04 Ryosuke Niwa <rniwa@webkit.org>
+
+ Update defineCustomElement according to the spec rewrite
+ https://bugs.webkit.org/show_bug.cgi?id=155010
+ <rdar://problem/24970878>
+
+ Reviewed by Chris Dumez.
+
+ Updated the implementation of defineCustomElement and HTMLConstructor per recent rewrite of the spec:
+ https://w3c.github.io/webcomponents/spec/custom/#dom-document-defineelement
+ https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor
+
+ defineCustomElement is now called defineElement and we disallow defining multiple custom elements with
+ a single class and throw an exception in defineElement.
+
+ Test: fast/custom-elements/Document-defineElement.html
+
+ * bindings/js/JSDocumentCustom.cpp:
+ (WebCore::JSDocument::defineElement): Renamed from defineCustomElement. Throw an exception when the interface
+ already defines another custom element. Also added FIXME's for missing steps.
+
+ * bindings/js/JSHTMLElementCustom.cpp:
+ (WebCore::constructJSHTMLElement): Removed the support for specifying a tag name in the first argument when
+ a single class defines multiple custom elements since that now results in an exception (in defineElement).
+
+ * dom/CustomElementDefinitions.cpp:
+ (WebCore::CustomElementDefinitions::containsConstructor): Added.
+ * dom/CustomElementDefinitions.h:
+ * dom/Document.idl: Renamed defineCustomElement to defineElement.
+ * html/HTMLElement.idl: Removed the optional tag name from the constructor.
+
</ins><span class="cx"> 2016-03-04 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Begin implementing <attachment> painting on iOS
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDocumentCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span><del>-JSValue JSDocument::defineCustomElement(ExecState& state)
</del><ins>+JSValue JSDocument::defineElement(ExecState& state)
</ins><span class="cx"> {
</span><span class="cx"> AtomicString tagName(state.argument(0).toString(&state)->toAtomicString(&state));
</span><span class="cx"> if (UNLIKELY(state.hadException()))
</span><span class="lines">@@ -163,16 +163,31 @@
</span><span class="cx"> return throwSyntaxError(&state, "Custom element name cannot contain an upper case letter");
</span><span class="cx"> }
</span><span class="cx">
</span><del>- QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI);
</del><span class="cx"> auto& definitions = document.ensureCustomElementDefinitions();
</span><span class="cx"> if (definitions.findInterface(tagName)) {
</span><span class="cx"> throwNotSupportedError(state, "Cannot define multiple custom elements with the same tag name");
</span><span class="cx"> return jsUndefined();
</span><span class="cx"> }
</span><ins>+
+ if (definitions.containsConstructor(object)) {
+ throwNotSupportedError(state, "Cannot define multiple custom elements with the same class");
+ return jsUndefined();
+ }
+
+ // FIXME: 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.
+ // FIXME: 11. If Type(prototype) is not Object, throw a TypeError exception.
+ // FIXME: 12. Let attachedCallback be Get(prototype, "attachedCallback"). Rethrow any exceptions.
+ // FIXME: 13. Let detachedCallback be Get(prototype, "detachedCallback"). Rethrow any exceptions.
+ // FIXME: 14. Let attributeChangedCallback be Get(prototype, "attributeChangedCallback"). Rethrow any exceptions.
+
+ QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI);
</ins><span class="cx"> definitions.defineElement(name, JSCustomElementInterface::create(object, globalObject()));
</span><span class="cx"> PrivateName uniquePrivateName;
</span><span class="cx"> globalObject()->putDirect(globalObject()->vm(), uniquePrivateName, object);
</span><span class="cx">
</span><ins>+ // FIXME: 17. Let map be registry's upgrade candidates map.
+ // FIXME: 18. Upgrade a newly-defined element given map and definition.
+
</ins><span class="cx"> return jsUndefined();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -54,26 +54,9 @@
</span><span class="cx"> JSValue newTargetValue = state->thisValue();
</span><span class="cx"> JSObject* newTarget = newTargetValue.getObject();
</span><span class="cx"> QualifiedName fullName = definitions->findName(newTarget);
</span><del>- if (fullName == nullQName()) {
- if (UNLIKELY(state->argumentCount() < 1))
- return throwVMError(state, createNotEnoughArgumentsError(state));
- }
</del><ins>+ if (fullName == nullQName())
+ return throwVMTypeError(state, "new.target does not define a custom element");
</ins><span class="cx">
</span><del>- if (state->argumentCount()) {
- String name;
- if (!state->argument(0).getString(state, name))
- return throwVMTypeError(state, "The first argument is not a valid custom element name");
-
- auto* interface = definitions->findInterface(name);
- if (!interface)
- return throwVMTypeError(state, "The first argument is not a valid custom element name");
-
- if (newTarget != interface->constructor())
- return throwVMTypeError(state, "Attempt to construct a custom element with a wrong interface");
-
- fullName = QualifiedName(nullAtom, name, HTMLNames::xhtmlNamespaceURI);
- }
-
</del><span class="cx"> auto* globalObject = jsConstructor->globalObject();
</span><span class="cx"> Structure* baseStructure = getDOMStructure<JSHTMLElement>(vm, *globalObject);
</span><span class="cx"> auto* newElementStructure = InternalFunction::createSubclassStructure(state, newTargetValue, baseStructure);
</span></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementDefinitionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CustomElementDefinitions.cpp (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementDefinitions.cpp        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/dom/CustomElementDefinitions.cpp        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -94,6 +94,11 @@
</span><span class="cx"> return it == m_nameMap.end() ? nullptr : it->value.interface.get();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool CustomElementDefinitions::containsConstructor(const JSC::JSObject* constructor) const
+{
+ return m_constructorMap.contains(constructor);
+}
+
</ins><span class="cx"> const QualifiedName& CustomElementDefinitions::findName(const JSC::JSObject* constructor) const
</span><span class="cx"> {
</span><span class="cx"> auto it = m_constructorMap.find(constructor);
</span></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementDefinitionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CustomElementDefinitions.h (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementDefinitions.h        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/dom/CustomElementDefinitions.h        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx">
</span><span class="cx"> JSCustomElementInterface* findInterface(const QualifiedName&) const;
</span><span class="cx"> JSCustomElementInterface* findInterface(const AtomicString&) const;
</span><ins>+ bool containsConstructor(const JSC::JSObject*) const;
</ins><span class="cx"> const QualifiedName& findName(const JSC::JSObject*) const;
</span><span class="cx">
</span><span class="cx"> enum class NameStatus { Valid, ConflictsWithBuiltinNames, NoHyphen, ContainsUpperCase };
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/dom/Document.idl        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -295,7 +295,7 @@
</span><span class="cx">
</span><span class="cx"> #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
</span><span class="cx"> [Custom, RaisesException, Conditional=CUSTOM_ELEMENTS]
</span><del>- void defineCustomElement(DOMString tagName, CustomElementInterface elementInterface);
</del><ins>+ void defineElement(DOMString localName, Function constructor);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // Page visibility API.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.idl (197601 => 197602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.idl        2016-03-05 01:06:19 UTC (rev 197601)
+++ trunk/Source/WebCore/html/HTMLElement.idl        2016-03-05 01:23:42 UTC (rev 197602)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">
</span><span class="cx"> [
</span><span class="cx"> #if defined(ENABLE_CUSTOM_ELEMENTS) && ENABLE_CUSTOM_ELEMENTS
</span><del>- CustomConstructor(optional DOMString localName),
</del><ins>+ CustomConstructor(),
</ins><span class="cx"> #endif
</span><span class="cx"> JSGenerateToNativeObject,
</span><span class="cx"> JSCustomPushEventHandlerScope,
</span></span></pre>
</div>
</div>
</body>
</html>