OLD | NEW |
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 proto = Object.create(HTMLElement.prototype); | 7 var proto = Object.create(HTMLElement.prototype); |
8 var ctor = document.register('x-a', {prototype: proto}); | 8 var ctor = document.registerElement('x-a', {prototype: proto}); |
9 assert_true(ctor instanceof Function, 'constructor must be a function'); | 9 assert_true(ctor instanceof Function, 'constructor must be a function'); |
10 assert_equals(typeof ctor, 'function', 'constructor must be a function insta
nce'); | 10 assert_equals(typeof ctor, 'function', 'constructor must be a function insta
nce'); |
11 }, 'constructor type'); | 11 }, 'constructor type'); |
12 | 12 |
13 test(function () { | 13 test(function () { |
14 var proto = Object.create(HTMLElement.prototype); | 14 var proto = Object.create(HTMLElement.prototype); |
15 var ctor = document.register('x-b', {prototype: proto}); | 15 var ctor = document.registerElement('x-b', {prototype: proto}); |
16 | 16 |
17 // FIXME: These are not specified yet. Update these assertions | 17 // FIXME: These are not specified yet. Update these assertions |
18 // when the name is specified. | 18 // when the name is specified. |
19 assert_equals(ctor.name, 'x-b', 'the constructor\'s name should match the ty
pe'); | 19 assert_equals(ctor.name, 'x-b', 'the constructor\'s name should match the ty
pe'); |
20 }, 'constructor name'); | 20 }, 'constructor name'); |
21 | 21 |
22 test(function () { | 22 test(function () { |
23 var proto = Object.create(HTMLElement.prototype); | 23 var proto = Object.create(HTMLElement.prototype); |
24 var ctor = document.register('x-c', {prototype: proto}); | 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'); | 25 assert_own_property(proto, 'constructor', 'document.register must configure
the constructor property of the prototype'); |
26 | 26 |
27 assert_equals(proto.constructor, ctor, 'the value of the constructor propert
y must be the constructor function'); | 27 assert_equals(proto.constructor, ctor, 'the value of the constructor propert
y must be the constructor function'); |
28 | 28 |
29 var desc = Object.getOwnPropertyDescriptor(proto, 'constructor'); | 29 var desc = Object.getOwnPropertyDescriptor(proto, 'constructor'); |
30 assert_true(desc.writable, 'constructor property must be writable'); | 30 assert_true(desc.writable, 'constructor property must be writable'); |
31 assert_false(desc.enumerable, 'constructor property must be non-enumerable')
; | 31 assert_false(desc.enumerable, 'constructor property must be non-enumerable')
; |
32 assert_true(desc.configurable, 'constructor property must be configurable'); | 32 assert_true(desc.configurable, 'constructor property must be configurable'); |
33 }, 'prototype "constructor" property'); | 33 }, 'prototype "constructor" property'); |
34 | 34 |
35 test(function () { | 35 test(function () { |
36 var proto = Object.create(HTMLElement.prototype); | 36 var proto = Object.create(HTMLElement.prototype); |
37 var ctor = document.register('x-d', {prototype: proto}); | 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'); | 38 assert_own_property(ctor, 'prototype', 'document.register must configure the
prototype property of the constructor'); |
39 | 39 |
40 assert_equals(ctor.prototype, proto, 'the value of the prototype property mu
st be the prototype object'); | 40 assert_equals(ctor.prototype, proto, 'the value of the prototype property mu
st be the prototype object'); |
41 | 41 |
42 var desc = Object.getOwnPropertyDescriptor(ctor, 'prototype'); | 42 var desc = Object.getOwnPropertyDescriptor(ctor, 'prototype'); |
43 assert_false(desc.writable, 'prototype property must not be writable'); | 43 assert_false(desc.writable, 'prototype property must not be writable'); |
44 assert_false(desc.enumerable, 'prototype property must be non-enumerable'); | 44 assert_false(desc.enumerable, 'prototype property must be non-enumerable'); |
45 assert_false(desc.configurable, 'prototype property must not be configurable
'); | 45 assert_false(desc.configurable, 'prototype property must not be configurable
'); |
46 }, 'constructor "prototype" property'); | 46 }, 'constructor "prototype" property'); |
47 </script> | 47 </script> |
48 | 48 |
OLD | NEW |