Commit 6caa6321 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

custom-elements: Create appropriate HTMLElement subclasses for custom built-in elements.

Add custom built-in element support to <embed>, <object>, and <form>.

Bug: 805281, 806184, 806185, 806187
Change-Id: I920ea11ed0b5884c69d3c1aee04e18f7fa62e9f2
Reviewed-on: https://chromium-review.googlesource.com/895234Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533234}
parent 841b1d49
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught TypeError: Illegal constructor: localName does not match the HTML element interface
Found 442 tests; 414 PASS, 28 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 442 tests; 423 PASS, 19 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS a: Define a customized built-in element
PASS a: Operator 'new' should instantiate a customized built-in element
PASS a: document.createElement() should instantiate a customized built-in element
......@@ -129,17 +129,9 @@ PASS em: Operator 'new' should instantiate a customized built-in element
PASS em: document.createElement() should instantiate a customized built-in element
PASS em: innerHTML should instantiate a customized built-in element
PASS embed: Define a customized built-in element
FAIL embed: Operator 'new' should instantiate a customized built-in element Illegal constructor
FAIL embed: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class MyEmbed extends HTMLEmbedElement {
constructor() {
super();
}
}" but got function "function HTMLEmbedElement() { [native code] }"
FAIL embed: innerHTML should instantiate a customized built-in element assert_equals: expected function "class MyEmbed extends HTMLEmbedElement {
constructor() {
super();
}
}" but got function "function HTMLEmbedElement() { [native code] }"
PASS embed: Operator 'new' should instantiate a customized built-in element
PASS embed: document.createElement() should instantiate a customized built-in element
PASS embed: innerHTML should instantiate a customized built-in element
PASS fieldset: Define a customized built-in element
PASS fieldset: Operator 'new' should instantiate a customized built-in element
PASS fieldset: document.createElement() should instantiate a customized built-in element
......@@ -157,17 +149,9 @@ PASS footer: Operator 'new' should instantiate a customized built-in element
PASS footer: document.createElement() should instantiate a customized built-in element
PASS footer: innerHTML should instantiate a customized built-in element
PASS form: Define a customized built-in element
FAIL form: Operator 'new' should instantiate a customized built-in element Illegal constructor
FAIL form: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class MyForm extends HTMLFormElement {
constructor() {
super();
}
}" but got function "function HTMLFormElement() { [native code] }"
FAIL form: innerHTML should instantiate a customized built-in element assert_equals: expected function "class MyForm extends HTMLFormElement {
constructor() {
super();
}
}" but got function "function HTMLFormElement() { [native code] }"
PASS form: Operator 'new' should instantiate a customized built-in element
PASS form: document.createElement() should instantiate a customized built-in element
PASS form: innerHTML should instantiate a customized built-in element
PASS h1: Define a customized built-in element
PASS h1: Operator 'new' should instantiate a customized built-in element
PASS h1: document.createElement() should instantiate a customized built-in element
......@@ -288,17 +272,9 @@ FAIL noscript: innerHTML should instantiate a customized built-in element assert
}
}" but got function "function HTMLElement() { [native code] }"
PASS object: Define a customized built-in element
FAIL object: Operator 'new' should instantiate a customized built-in element Illegal constructor
FAIL object: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class MyObject extends HTMLObjectElement {
constructor() {
super();
}
}" but got function "function HTMLObjectElement() { [native code] }"
FAIL object: innerHTML should instantiate a customized built-in element assert_equals: expected function "class MyObject extends HTMLObjectElement {
constructor() {
super();
}
}" but got function "function HTMLObjectElement() { [native code] }"
PASS object: Operator 'new' should instantiate a customized built-in element
PASS object: document.createElement() should instantiate a customized built-in element
PASS object: innerHTML should instantiate a customized built-in element
PASS ol: Define a customized built-in element
PASS ol: Operator 'new' should instantiate a customized built-in element
PASS ol: document.createElement() should instantiate a customized built-in element
......
......@@ -23,7 +23,8 @@
// TODO(yukishiino): HTMLEmbedElement should not have [OverrideBuiltins].
[
OverrideBuiltins,
ActiveScriptWrappable
ActiveScriptWrappable,
HTMLConstructor
] interface HTMLEmbedElement : HTMLElement {
[CEReactions, Reflect, URL] attribute DOMString src;
[CEReactions, Reflect] attribute DOMString type;
......
......@@ -23,7 +23,8 @@
// TODO(yukishiino): HTMLObjectElement should not have [OverrideBuiltins].
[
OverrideBuiltins,
ActiveScriptWrappable
ActiveScriptWrappable,
HTMLConstructor
] interface HTMLObjectElement : HTMLElement {
[CEReactions, Reflect, URL] attribute DOMString data;
[CEReactions, Reflect] attribute DOMString type;
......
......@@ -92,13 +92,14 @@ void CustomElementDefinition::CheckConstructorResult(
HTMLElement* CustomElementDefinition::CreateElementForConstructor(
Document& document) {
// TODO(kojii): When HTMLElementFactory has an option not to queue
// upgrade, call that instead of HTMLElement. HTMLElement is enough
// for now, but type extension will require HTMLElementFactory.
HTMLElement* element =
HTMLElement* element = HTMLElementFactory::CreateRawHTMLElement(
Descriptor().LocalName(), document, kCreatedByCreateElement);
if (!element) {
element =
HTMLElement::Create(QualifiedName(g_null_atom, Descriptor().LocalName(),
HTMLNames::xhtmlNamespaceURI),
document);
}
// TODO(davaajav): write this as one call to setCustomElementState instead of
// two
element->SetCustomElementState(CustomElementState::kUndefined);
......
......@@ -21,6 +21,7 @@
// https://html.spec.whatwg.org/#the-form-element
[
HTMLConstructor,
OverrideBuiltins
] interface HTMLFormElement : HTMLElement {
[CEReactions, Reflect=accept_charset] attribute DOMString acceptCharset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment