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

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

Issue 984523003: bindings: Moves most of DOM attributes to prototype chains. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated test results. Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector/tracing/timeline-xhr-event-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var outerHTML = Object.getOwnPropertyDescriptor(Element.prototype, 'outerHTML');
7 var tagName = Object.getOwnPropertyDescriptor(Element.prototype, 'tagName');
8
6 test(function() { 9 test(function() {
7 var p = Object.create(HTMLDivElement.prototype); 10 var p = Object.create(HTMLDivElement.prototype);
8 var C = document.registerElement('x-div', {extends: 'div', prototype: p}); 11 var C = document.registerElement('x-div', {extends: 'div', prototype: p});
9 assert_equals(new C().outerHTML, '<div is="x-div"></div>', 12 assert_equals(new C().outerHTML, '<div is="x-div"></div>',
10 'type extensions should have an "is" attribute'); 13 'type extensions should have an "is" attribute');
11 assert_equals(new C().tagName, 'DIV', 14 assert_equals(new C().tagName, 'DIV',
12 'tag name should be that of the base element'); 15 'tag name should be that of the base element');
13 }, 'register a type extension'); 16 }, 'register a type extension');
14 17
15 test(function() { 18 test(function() {
16 var p = Object.create(Window.prototype); 19 var p = Object.create(Window.prototype);
17 var C = document.registerElement('x-em', {extends: 'em', prototype: p}); 20 var C = document.registerElement('x-em', {extends: 'em', prototype: p});
18 var e = new C(); 21 var e = new C();
19 Node.prototype.appendChild.call(e, document.createTextNode('Hi!')); 22 Node.prototype.appendChild.call(e, document.createTextNode('Hi!'));
20 assert_equals(e.outerHTML, '<em is="x-em">Hi!</em>', 23 assert_equals(outerHTML.get.call(e), '<em is="x-em">Hi!</em>',
21 'the type extension must not depend on the author-' + 24 'the type extension must not depend on the author-' +
22 'specified prototype'); 25 'specified prototype');
23 }, 'register a type extension with a non-element prototype'); 26 }, 'register a type extension with a non-element prototype');
24 27
25 test(function() { 28 test(function() {
26 var p = Object.create(HTMLUnknownElement.prototype); 29 var p = Object.create(HTMLUnknownElement.prototype);
27 var C = document.registerElement('x-unknown', {extends: 'unknown', prototype : p}); 30 var C = document.registerElement('x-unknown', {extends: 'unknown', prototype : p});
28 assert_equals(new C().outerHTML, '<unknown is="x-unknown"></unknown>'); 31 assert_equals(new C().outerHTML, '<unknown is="x-unknown"></unknown>');
29 }, 'register a type extension of an unknown element'); 32 }, 'register a type extension of an unknown element');
30 33
31 test(function() { 34 test(function() {
32 // registering an SVG element requires an SVGElement prototype 35 // registering an SVG element requires an SVGElement prototype
33 var p = Object.create(SVGElement.prototype); 36 var p = Object.create(SVGElement.prototype);
34 var C = document.registerElement('x-use', {extends: 'use', prototype: p}); 37 var C = document.registerElement('x-use', {extends: 'use', prototype: p});
35 assert_equals(new C().namespaceURI, 'http://www.w3.org/2000/svg', 38 assert_equals(new C().namespaceURI, 'http://www.w3.org/2000/svg',
36 'SVG type extensions should have the SVG namespace'); 39 'SVG type extensions should have the SVG namespace');
37 }, 'register a type extension of an SVG element'); 40 }, 'register a type extension of an SVG element');
38 41
39 test(function() { 42 test(function() {
40 var p = Object.create(HTMLElement.prototype); 43 var p = Object.create(HTMLElement.prototype);
41 var C = document.registerElement('x-sect', {extends: 'section', prototype: p }); 44 var C = document.registerElement('x-sect', {extends: 'section', prototype: p });
42 assert_equals(new C().outerHTML, '<section is="x-sect"></section>'); 45 assert_equals(new C().outerHTML, '<section is="x-sect"></section>');
43 }, 'register a type extension of an element whose interface is HTMLElement'); 46 }, 'register a type extension of an element whose interface is HTMLElement');
44 47
45 test(function() { 48 test(function() {
46 var C = document.registerElement('x-augment', {extends: 'ins', prototype: {} }); 49 var C = document.registerElement('x-augment', {extends: 'ins', prototype: {} });
47 assert_equals(new C().outerHTML, '<ins is="x-augment"></ins>'); 50 assert_equals(outerHTML.get.call(new C()), '<ins is="x-augment"></ins>');
48 var D = document.registerElement('x-elide', {extends: 'del', prototype: {}}) ; 51 var D = document.registerElement('x-elide', {extends: 'del', prototype: {}}) ;
49 assert_equals(new D().outerHTML, '<del is="x-elide"></del>'); 52 assert_equals(outerHTML.get.call(new D()), '<del is="x-elide"></del>');
50 }, 'register a type extensions of an interface with multiple element names'); 53 }, 'register a type extensions of an interface with multiple element names');
51 54
52 test(function() { 55 test(function() {
53 var C = document.registerElement('x-ins', {extends: 'InS', prototype: {}}); 56 var C = document.registerElement('x-ins', {extends: 'InS', prototype: {}});
54 assert_equals(new C().tagName, 'INS', 57 assert_equals(tagName.get.call(new C()), 'INS',
55 'tag name should be that of the base element'); 58 'tag name should be that of the base element');
56 }, 'register a type extension with unusual case'); 59 }, 'register a type extension with unusual case');
57 60
58 test(function() { 61 test(function() {
59 assert_throws( 62 assert_throws(
60 'NOT_SUPPORTED_ERR', 63 'NOT_SUPPORTED_ERR',
61 function() { 64 function() {
62 var p = Object.create(HTMLElement.prototype); 65 var p = Object.create(HTMLElement.prototype);
63 document.registerElement('x-bespoke', {extends: 'x-spoke', prototype : p}); 66 document.registerElement('x-bespoke', {extends: 'x-spoke', prototype : p});
64 }, 67 },
65 'registering a type extension of a custom tag should fail'); 68 'registering a type extension of a custom tag should fail');
66 }, 'registering a type extension of a custom tag should fail'); 69 }, 'registering a type extension of a custom tag should fail');
67 </script> 70 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector/tracing/timeline-xhr-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698