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

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

Issue 117313008: Update Custom Elements API to new names. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update for forgotten tests. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script> 2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <body> 4 <body>
5 <script> 5 <script>
6 test(function() { 6 test(function() {
7 var p = Object.create(HTMLDivElement.prototype); 7 var p = Object.create(HTMLDivElement.prototype);
8 var C = document.register('x-div', {extends: 'div', prototype: p}); 8 var C = document.registerElement('x-div', {extends: 'div', prototype: p});
9 assert_equals(new C().outerHTML, '<div is="x-div"></div>', 9 assert_equals(new C().outerHTML, '<div is="x-div"></div>',
10 'type extensions should have an "is" attribute'); 10 'type extensions should have an "is" attribute');
11 assert_equals(new C().tagName, 'DIV', 11 assert_equals(new C().tagName, 'DIV',
12 'tag name should be that of the base element'); 12 'tag name should be that of the base element');
13 }, 'register a type extension'); 13 }, 'register a type extension');
14 14
15 test(function() { 15 test(function() {
16 var p = Object.create(Window.prototype); 16 var p = Object.create(Window.prototype);
17 var C = document.register('x-em', {extends: 'em', prototype: p}); 17 var C = document.registerElement('x-em', {extends: 'em', prototype: p});
18 var e = new C(); 18 var e = new C();
19 Node.prototype.appendChild.call(e, document.createTextNode('Hi!')); 19 Node.prototype.appendChild.call(e, document.createTextNode('Hi!'));
20 assert_equals(e.outerHTML, '<em is="x-em">Hi!</em>', 20 assert_equals(e.outerHTML, '<em is="x-em">Hi!</em>',
21 'the type extension must not depend on the author-' + 21 'the type extension must not depend on the author-' +
22 'specified prototype'); 22 'specified prototype');
23 }, 'register a type extension with a non-element prototype'); 23 }, 'register a type extension with a non-element prototype');
24 24
25 test(function() { 25 test(function() {
26 var p = Object.create(HTMLUnknownElement.prototype); 26 var p = Object.create(HTMLUnknownElement.prototype);
27 var C = document.register('x-unknown', {extends: 'unknown', prototype: p}); 27 var C = document.registerElement('x-unknown', {extends: 'unknown', prototype : p});
28 assert_equals(new C().outerHTML, '<unknown is="x-unknown"></unknown>'); 28 assert_equals(new C().outerHTML, '<unknown is="x-unknown"></unknown>');
29 }, 'register a type extension of an unknown element'); 29 }, 'register a type extension of an unknown element');
30 30
31 test(function() { 31 test(function() {
32 // registering an SVG element requires an SVGElement prototype 32 // registering an SVG element requires an SVGElement prototype
33 var p = Object.create(SVGElement.prototype); 33 var p = Object.create(SVGElement.prototype);
34 var C = document.register('x-use', {extends: 'use', prototype: p}); 34 var C = document.registerElement('x-use', {extends: 'use', prototype: p});
35 assert_equals(new C().namespaceURI, 'http://www.w3.org/2000/svg', 35 assert_equals(new C().namespaceURI, 'http://www.w3.org/2000/svg',
36 'SVG type extensions should have the SVG namespace'); 36 'SVG type extensions should have the SVG namespace');
37 }, 'register a type extension of an SVG element'); 37 }, 'register a type extension of an SVG element');
38 38
39 test(function() { 39 test(function() {
40 var p = Object.create(HTMLElement.prototype); 40 var p = Object.create(HTMLElement.prototype);
41 var C = document.register('x-sect', {extends: 'section', prototype: p}); 41 var C = document.registerElement('x-sect', {extends: 'section', prototype: p });
42 assert_equals(new C().outerHTML, '<section is="x-sect"></section>'); 42 assert_equals(new C().outerHTML, '<section is="x-sect"></section>');
43 }, 'register a type extension of an element whose interface is HTMLElement'); 43 }, 'register a type extension of an element whose interface is HTMLElement');
44 44
45 test(function() { 45 test(function() {
46 var C = document.register('x-augment', {extends: 'ins', prototype: {}}); 46 var C = document.registerElement('x-augment', {extends: 'ins', prototype: {} });
47 assert_equals(new C().outerHTML, '<ins is="x-augment"></ins>'); 47 assert_equals(new C().outerHTML, '<ins is="x-augment"></ins>');
48 var D = document.register('x-elide', {extends: 'del', prototype: {}}); 48 var D = document.registerElement('x-elide', {extends: 'del', prototype: {}}) ;
49 assert_equals(new D().outerHTML, '<del is="x-elide"></del>'); 49 assert_equals(new D().outerHTML, '<del is="x-elide"></del>');
50 }, 'register a type extensions of an interface with multiple element names'); 50 }, 'register a type extensions of an interface with multiple element names');
51 51
52 test(function() { 52 test(function() {
53 var C = document.register('x-ins', {extends: 'InS', prototype: {}}); 53 var C = document.registerElement('x-ins', {extends: 'InS', prototype: {}});
54 assert_equals(new C().tagName, 'INS', 54 assert_equals(new C().tagName, 'INS',
55 'tag name should be that of the base element'); 55 'tag name should be that of the base element');
56 }, 'register a type extension with unusual case'); 56 }, 'register a type extension with unusual case');
57 57
58 test(function() { 58 test(function() {
59 assert_throws( 59 assert_throws(
60 'INVALID_CHARACTER_ERR', 60 'INVALID_CHARACTER_ERR',
61 function() { 61 function() {
62 var p = Object.create(HTMLElement.prototype); 62 var p = Object.create(HTMLElement.prototype);
63 document.register('x-bespoke', {extends: 'x-spoke', prototype: p}); 63 document.registerElement('x-bespoke', {extends: 'x-spoke', prototype : p});
64 }, 64 },
65 'registering a type extension of a custom tag should fail'); 65 'registering a type extension of a custom tag should fail');
66 }, 'registering a type extension of a custom tag should fail'); 66 }, 'registering a type extension of a custom tag should fail');
67 </script> 67 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698