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

Side by Side Diff: LayoutTests/imported/web-platform-tests/custom-elements/instantiating-custom-elements/custom-element-constructor-node-document.html

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Custom element constructor sets owner document to the document, where cus tom element type is registered</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Custom element constructor sets custom element node document to the document, where custom element type is registered">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custo m-elements">
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <script src="../testcommon.js"></script>
11 <link rel="stylesheet" href="../../../../resources/testharness.css">
12 </head>
13 <body>
14 <div id="log"></div>
15 <script>
16 test(function() {
17 var doc = newHTMLDocument();
18 var GeneratedConstructor = doc.registerElement('x-a');
19 var customElement = new GeneratedConstructor();
20 assert_equals(customElement.ownerDocument, doc,
21 'Custom element owner document should be the document, where custom elem ent ' +
22 'type is registered');
23 }, 'Custom element constructor sets owner document to the document, where custom element ' +
24 'type is registered');
25
26
27 test(function() {
28 var doc = newHTMLDocument();
29 HTML5_ELEMENTS.forEach(function(tagName) {
30 var obj = doc.createElement(tagName);
31 var name = 'x-b-' + tagName;
32 var proto = Object.create(obj.constructor.prototype);
33 var GeneratedConstructor = doc.registerElement(name, {
34 prototype: proto,
35 extends: tagName
36 });
37 var customElement = new GeneratedConstructor();
38
39 assert_equals(customElement.ownerDocument, doc,
40 'Custom element owner document should be the document, where custom element ' +
41 'type is registered');
42 });
43 }, 'Custom element constructor sets owner document to the document, where custom element ' +
44 'type is registered. Test constructor of extended HTML element');
45
46
47 test(function() {
48 var doc = newHTMLDocument();
49 var sharedRegistryDocument = doc.implementation.createHTMLDocument('Document 2');
50
51 var name = 'x-c';
52 var GeneratedConstructor = doc.registerElement(name);
53 var customElement = new GeneratedConstructor();
54 assert_equals(customElement.ownerDocument, doc,
55 'Custom element owner document should be the document, where custom elem ent ' +
56 'type is registered');
57
58 var name2 = 'x-d';
59 var GeneratedConstructor2 = sharedRegistryDocument.registerElement(name2);
60 var customElement2 = new GeneratedConstructor2();
61 assert_equals(customElement2.ownerDocument, sharedRegistryDocument,
62 'Custom element owner document should be the document, where custom elem ent ' +
63 'type is registered');
64 }, 'Custom element constructor sets owner document to the document, where custom element ' +
65 'type is registered. Test different documents with shared registry');
66
67
68 test(function() {
69 var doc = newHTMLDocument();
70 var sharedRegistryDocument = doc.implementation.createHTMLDocument('Document 2');
71 HTML5_ELEMENTS.forEach(function(tagName) {
72 var obj = doc.createElement(tagName);
73 var name = 'x-e-' + tagName;
74 var proto = Object.create(obj.constructor.prototype);
75 var GeneratedConstructor = doc.registerElement(name, {
76 prototype: proto,
77 extends: tagName
78 });
79 var customElement = new GeneratedConstructor();
80 assert_equals(customElement.ownerDocument, doc,
81 'Custom element owner document should be the document, where custom element ' +
82 'type is registered');
83
84 var obj2 = sharedRegistryDocument.createElement(tagName);
85 var name2 = 'x-f-' + tagName;
86 var proto2 = Object.create(obj2.constructor.prototype);
87 var GeneratedConstructor2 = sharedRegistryDocument.registerElement(name2 , {
88 prototype: proto2,
89 extends: tagName
90 });
91 var customElement2 = new GeneratedConstructor2();
92 assert_equals(customElement2.ownerDocument, sharedRegistryDocument,
93 'Custom element owner document should be the document, where custom element ' +
94 'type is registered');
95 });
96 }, 'Custom element constructor sets owner document to the document, where custom element ' +
97 'type is registered. Test constructor of extended HTML element for different documents ' +
98 'with shared registry');
99 </script>
100 </body>
101 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698