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

Side by Side Diff: LayoutTests/fast/dom/custom/document-register-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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script> 4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div id="container"></div> 7 <div id="container"></div>
8 <form id="testForm"></form> 8 <form id="testForm"></form>
9 <script> 9 <script>
10 description('Testing document.register() type extension behaviours through creat eElement().'); 10 description('Testing document.register() type extension behaviours through creat eElement().');
11 11
12 function isFormControl(element) 12 function isFormControl(element)
13 { 13 {
14 testForm.appendChild(element); 14 testForm.appendChild(element);
15 return element.form == testForm; 15 return element.form == testForm;
16 } 16 }
17 17
18 if (window.testRunner) 18 if (window.testRunner)
19 testRunner.dumpAsText(); 19 testRunner.dumpAsText();
20 20
21 // 21 //
22 // Inheritance here is shaped like this: 22 // Inheritance here is shaped like this:
23 // 23 //
24 // HTMLElement <- input <- x-bar <- x-qux 24 // HTMLElement <- input <- x-bar <- x-qux
25 // <- x-foo <- x-baz 25 // <- x-foo <- x-baz
26 // 26 //
27 27
28 fooConstructor = document.register('x-foo', { prototype: Object.create(HTMLEleme nt.prototype) }); 28 fooConstructor = document.register('x-foo', { prototype: Object.create(HTMLEleme nt.prototype) });
29 barConstructor = document.register('x-bar', { prototype: Object.create(HTMLInput Element.prototype) }); 29 barConstructor = document.register('x-bar', { extends: 'input', prototype: Objec t.create(HTMLInputElement.prototype) });
30 bazConstructor = document.register('x-baz', { prototype: Object.create(fooConstr uctor.prototype) }); 30 bazConstructor = document.register('x-baz', { prototype: Object.create(fooConstr uctor.prototype) });
31 quxConstructor = document.register('x-qux', { prototype: Object.create(barConstr uctor.prototype) }); 31 quxConstructor = document.register('x-qux', { extends: 'input', prototype: Objec t.create(barConstructor.prototype) });
32 32
33 // Same name, different local name 33 // Same name, different local name
34 shouldThrow('document.register("x-foo", { prototype: Object.create(HTMLDivElemen t.prototype) })', '"InvalidStateError: Failed to call \'register\' on \'Document \' for type \'x-foo\': a type with that name is already registered."'); 34 shouldThrow('document.register("x-foo", { prototype: Object.create(HTMLDivElemen t.prototype) })', '"InvalidStateError: Failed to call \'register\' on \'Document \' for type \'x-foo\': a type with that name is already registered."');
35 35
36 // 36 //
37 // Generated constructors 37 // Generated constructors
38 // 38 //
39 39
40 fooNewed = new fooConstructor(); 40 fooNewed = new fooConstructor();
41 fooOuterHTML = '<x-foo></x-foo>'; 41 fooOuterHTML = '<x-foo></x-foo>';
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 shouldBeTrue('namedBarParsed instanceof HTMLElement'); 164 shouldBeTrue('namedBarParsed instanceof HTMLElement');
165 165
166 divBarParsed = createElementFromHTML('<div is="x-bar">') 166 divBarParsed = createElementFromHTML('<div is="x-bar">')
167 shouldBeFalse('divBarParsed instanceof barConstructor'); 167 shouldBeFalse('divBarParsed instanceof barConstructor');
168 shouldBeTrue('divBarParsed instanceof HTMLDivElement'); 168 shouldBeTrue('divBarParsed instanceof HTMLDivElement');
169 169
170 </script> 170 </script>
171 <script src="../../js/resources/js-test-post.js"></script> 171 <script src="../../js/resources/js-test-post.js"></script>
172 </body> 172 </body>
173 </html> 173 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698