Index: third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html |
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..abb31fb5a8b05d49ca41653d1f27ef00a733d061 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html |
@@ -0,0 +1,86 @@ |
+<!DOCTYPE html> |
+<title>Custom Elements: Create an element when definition is non-null and synchronous flag set</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script src="resources/custom-elements-helpers.js"></script> |
+<body> |
+<script> |
+'use strict'; |
+ |
+// https://dom.spec.whatwg.org/#dom-document-createelement |
+// 1. If localName does not match the Name production, then throw an InvalidCharacterError |
+// 2. If context object is an HTML document, let localName be converted to ASCII lowercase |
+// 5. If 'is' is non-null and definition can't be found, then throw a NotFoundError |
+// 6. If 'is' is non-null, then set is attribute to 'is' |
+ |
+function setup(w) { |
+ class A extends w.HTMLElement { |
+ constructor() { |
dominicc (has gone to gerrit)
2016/11/15 07:39:53
There's no need to write super-only constructors l
|
+ super(); |
+ } |
+ } |
+ w.customElements.define('a-a', A); |
+ |
+ class B extends w.HTMLDivElement { |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ w.customElements.define('b-b', B, {extends: 'div'}); |
+} |
+ |
+test_with_window((w) => { |
+ setup(w); |
dominicc (has gone to gerrit)
2016/11/15 07:39:53
Why do you need any custom elements for this test?
|
+ assert_throws_dom_exception(w, 'InvalidCharacterError', () => { |
+ w.document.createElement('.invalid.name.'); |
+ }); |
+}, '1. If localName does not match the Name production, then throw an InvalidCharacterError'); |
+ |
+test_with_window((w) => { |
+ class A extends w.HTMLElement { |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ w.customElements.define('a-a', A); |
+ |
+ class B extends w.HTMLDivElement { |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ w.customElements.define('b-b', B, {extends: 'div'}); |
dominicc (has gone to gerrit)
2016/11/15 07:39:53
Why not use setup?
|
+ |
+ assert_equals(w.document.createElement('A-a').constructor, A); |
+ assert_equals(w.document.createElement('div', {is: 'b-B'}).constructor, B); |
+}, '2. If context object is an HTML document, let localName be converted to ASCII lowercase'); |
dominicc (has gone to gerrit)
2016/11/15 07:39:53
I don't think "is" is a local name. Consider split
|
+ |
+test_with_window((w) => { |
+ setup(w); |
+ assert_throws_dom_exception(w, 'NotFoundError', () => { |
+ w.document.createElement('div', {is: 'a-a'}); |
+ }); |
dominicc (has gone to gerrit)
2016/11/15 07:39:53
These are good test cases.
Add a third parameter
|
+ assert_throws_dom_exception(w, 'NotFoundError', () => { |
+ w.document.createElement('button', {is: 'b-b'}); |
+ }); |
+ assert_throws_dom_exception(w, 'NotFoundError', () => { |
+ w.document.createElement('button', {id: 'b-b'}); |
+ }); |
+ assert_throws_dom_exception(w, 'NotFoundError', () => { |
+ w.document.createElement('div', {is: ''}); |
+ }); |
+ assert_throws_dom_exception(w, 'NotFoundError', () => { |
+ w.document.createElement('div', {}); |
+ }); |
+}, '5. If \'is\' is non-null and definition can not be found, then throw a NotFoundError'); |
+ |
+test_with_window((w) => { |
+ setup(w); |
+ let a = w.document.createElement('a-a'); |
+ let b = w.document.createElement('div', {is : 'b-b'}); |
+ assert_equals(a.getAttribute('is'), null); |
+ assert_equals(b.getAttribute('is'), 'b-b'); |
+}, '6. If \'is\' is non-null, then set is-attribute to \'is\''); |
+ |
+</script> |
+</body> |