Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / custom / document-register-constructor.html
blob88b7f7257ddfb59bb3c34c486a0bf878b0911743
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <body>
5 <script>
6 test(function () {
7 var proto = Object.create(HTMLElement.prototype);
8 var ctor = document.registerElement('x-a', {prototype: proto});
9 assert_true(ctor instanceof Function, 'constructor must be a function');
10 assert_equals(typeof ctor, 'function', 'constructor must be a function instance');
11 }, 'constructor type');
13 test(function () {
14 var proto = Object.create(HTMLElement.prototype);
15 var ctor = document.registerElement('x-b', {prototype: proto});
17 // FIXME: These are not specified yet. Update these assertions
18 // when the name is specified.
19 assert_equals(ctor.name, 'x-b', 'the constructor\'s name should match the type');
20 }, 'constructor name');
22 test(function () {
23 var proto = Object.create(HTMLElement.prototype);
24 var ctor = document.registerElement('x-c', {prototype: proto});
25 assert_own_property(proto, 'constructor', 'document.register must configure the constructor property of the prototype');
27 assert_equals(proto.constructor, ctor, 'the value of the constructor property must be the constructor function');
29 var desc = Object.getOwnPropertyDescriptor(proto, 'constructor');
30 assert_true(desc.writable, 'constructor property must be writable');
31 assert_false(desc.enumerable, 'constructor property must be non-enumerable');
32 assert_true(desc.configurable, 'constructor property must be configurable');
33 }, 'prototype "constructor" property');
35 test(function () {
36 var proto = Object.create(HTMLElement.prototype);
37 var ctor = document.registerElement('x-d', {prototype: proto});
38 assert_own_property(ctor, 'prototype', 'document.register must configure the prototype property of the constructor');
40 assert_equals(ctor.prototype, proto, 'the value of the prototype property must be the prototype object');
42 var desc = Object.getOwnPropertyDescriptor(ctor, 'prototype');
43 assert_false(desc.writable, 'prototype property must not be writable');
44 assert_false(desc.enumerable, 'prototype property must be non-enumerable');
45 assert_false(desc.configurable, 'prototype property must not be configurable');
46 }, 'constructor "prototype" property');
47 </script>