Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: LayoutTests/fast/dom/custom/type-extensions.html

Issue 23717043: Implement Custom Elements 'extends' option. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/custom/type-extensions.html
diff --git a/LayoutTests/fast/dom/custom/type-extensions.html b/LayoutTests/fast/dom/custom/type-extensions.html
new file mode 100644
index 0000000000000000000000000000000000000000..265593435f5194e371d79c00624baf1e6279c004
--- /dev/null
+++ b/LayoutTests/fast/dom/custom/type-extensions.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<body>
+<script>
+test(function() {
+ var p = Object.create(HTMLDivElement.prototype);
+ var C = document.register('x-div', {extends: 'div', prototype: p});
+ assert_equals(new C().outerHTML, '<div is="x-div"></div>',
+ 'type extensions should have an "is" attribute');
+ assert_equals(new C().tagName, 'DIV',
+ 'tag name should be that of the base element');
+}, 'register a type extension');
+
+test(function() {
+ var p = Object.create(Window.prototype);
+ var C = document.register('x-em', {extends: 'em', prototype: p});
+ var e = new C();
+ Node.prototype.appendChild.call(e, document.createTextNode('Hi!'));
+ assert_equals(e.outerHTML, '<em is="x-em">Hi!</em>',
+ 'the type extension must not depend on the author-' +
+ 'specified prototype');
+}, 'register a type extension with a non-element prototype');
+
+test(function() {
+ var p = Object.create(HTMLUnknownElement.prototype);
+ var C = document.register('x-unknown', {extends: 'unknown', prototype: p});
+ assert_equals(new C().outerHTML, '<unknown is="x-unknown"></unknown>');
+}, 'register a type extension of an unknown element');
+
+test(function() {
+ // registering an SVG element requires an SVGElement prototype
+ var p = Object.create(SVGElement.prototype);
+ var C = document.register('x-use', {extends: 'use', prototype: p});
+ assert_equals(new C().namespaceURI, 'http://www.w3.org/2000/svg',
+ 'SVG type extensions should have the SVG namespace');
+}, 'register a type extension of an SVG element');
+
+test(function() {
+ var p = Object.create(HTMLElement.prototype);
+ var C = document.register('x-sect', {extends: 'section', prototype: p});
+ assert_equals(new C().outerHTML, '<section is="x-sect"></section>');
+}, 'register a type extension of an element whose interface is HTMLElement');
+
+test(function() {
+ var C = document.register('x-augment', {extends: 'ins', prototype: {}});
+ assert_equals(new C().outerHTML, '<ins is="x-augment"></ins>');
+ var D = document.register('x-elide', {extends: 'del', prototype: {}});
+ assert_equals(new D().outerHTML, '<del is="x-elide"></del>');
+}, 'register a type extensions of an interface with multiple element names');
+
+test(function() {
+ var C = document.register('x-ins', {extends: 'InS', prototype: {}});
+ assert_equals(new C().tagName, 'INS',
+ 'tag name should be that of the base element');
+}, 'register a type extension with unusual case');
+
+test(function() {
+ assert_throws(
+ 'INVALID_CHARACTER_ERR',
+ function() {
+ var p = Object.create(HTMLElement.prototype);
+ document.register('x-bespoke', {extends: 'x-spoke', prototype: p});
+ },
+ 'registering a type extension of a custom tag should fail');
+}, 'registering a type extension of a custom tag should fail');
+</script>

Powered by Google App Engine
This is Rietveld 408576698