Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / custom-elements / instantiating-custom-elements / non-configurable-constructor-property.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>If prototype has a non-configurable property named constructor, Document.registerElement() throws NotSupportedError</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="If  PROTOTYPE has a non-configurable property named constructor, throw a NotSupportedError and stop">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custom-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 proto = Object.create(HTMLElement.prototype);
19     Object.defineProperty(proto, 'constructor', {configurable: false});
20     assert_throws('NotSupportedError', function() {
21         doc.registerElement('x-a', {prototype: proto});
22     }, 'Exception should be thrown in case of attempt to register element ' +
23         'with a non-configurable property named constructor');
24 }, 'Test Document.registerElement() throws NotSupportedError ' +
25     'if prototype has a non-configurable property named constructor');
26
27
28 test(function() {
29     var doc = newHTMLDocument();
30     var proto = Object.create(HTMLElement.prototype);
31     Object.defineProperty(proto, 'constructor', {configurable: true});
32     try {
33         doc.registerElement('x-b', {prototype: proto});
34     } catch (e) {
35         assert_unreached('Exception should not be thrown in case of attempt to register ' +
36             'element with a configurable property named constructor');
37     }
38 }, 'Test Document.registerElement() accepts prototype with a configurable ' +
39     'property named constructor without throwing errors');
40 </script>
41 </body>
42 </html>