Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>New document without browsing context must not have a registry</title> |
| 5 | <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"> |
| 6 | <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 7 | <meta name="assert" content="In all other cases, new documents must not have a registry."> |
| 8 | <link rel="help" href="http://www.w3.org/TR/custom-elements/#creating-and-passing-registries"> |
| 9 | <script src="/resources/testharness.js"></script> |
| 10 | <script src="/resources/testharnessreport.js"></script> |
| 11 | <script src="../testcommon.js"></script> |
| 12 | <link rel="stylesheet" href="/resources/testharness.css"> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div id="log"></div> |
| 16 | <script> |
| 17 | test(function() { |
| 18 | var doc = document.implementation.createDocument(null, 'test', null); |
| 19 | assert_throws( |
| 20 | 'NotSupportedError', |
| 21 | function() { doc.registerElement('x-element'); }, |
| 22 | 'Registering valid custom element in a document ' + |
| 23 | 'without registry should fail'); |
| 24 | }, 'Document of type other than HTML, not loaded into browsing context, must not have a registry'); |
| 25 | |
| 26 | async_test(function(t) { |
| 27 | var request = new XMLHttpRequest(); |
| 28 | request.onreadystatechange = t.step_func(function() { |
| 29 | if (request.readyState == 4){ |
| 30 | assert_equals(200, request.status, 'Test document is not loaded correctly'); |
| 31 | var doc = request.response; |
| 32 | assert_true(doc instanceof HTMLDocument, |
| 33 | 'XMLHttpRequest\'s asynchronous response should be HTML document'); |
| 34 | assert_throws( |
| 35 | 'NotSupportedError', |
| 36 | function() { doc.registerElement('x-element'); }, |
| 37 | 'Registering valid custom element in ' + |
| 38 | 'an XMLHttpRequest\'s response document should fail'); |
| 39 | t.done(); |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | request.open('GET', '../resources/blank.html', true); |
| 44 | request.responseType = 'document'; |
| 45 | request.send(); |
| 46 | }, 'XMLHttpRequest\'s asynchronous response HTML document must not have a registry'); |
| 47 | </script> |
| 48 | </body> |
| 49 | </html> |