| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script src='../../../resources/testharness.js'></script> | |
| 3 <script src='../../../resources/testharnessreport.js'></script> | |
| 4 <script> | |
| 5 'use strict'; | |
| 6 | |
| 7 const safelist = ['custom-element', | |
| 8 'article', 'aside', 'blockquote', 'body', 'div', 'footer', | |
| 9 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', | |
| 10 'header', 'nav', 'p', 'section', 'span']; | |
| 11 | |
| 12 test(() => { | |
| 13 safelist.forEach((tag) => { | |
| 14 ['open', 'closed'].forEach((mode) => { | |
| 15 const sr = document.createElement(tag).attachShadow({mode: mode}); | |
| 16 assert_true(sr instanceof ShadowRoot, "attachShadow is supported for " + t
ag); | |
| 17 }); | |
| 18 }); | |
| 19 }, 'attachShadow should not fail for an element in the safelist'); | |
| 20 | |
| 21 test(() => { | |
| 22 // Retrieve possible tag names from window object's own property names | |
| 23 Object.getOwnPropertyNames(window).forEach((p) => { | |
| 24 const res = /^HTML(.*)Element$/.exec(p); | |
| 25 if (!res) | |
| 26 return; | |
| 27 const maybeTagName = res[1].toLowerCase(); | |
| 28 if (safelist.includes(maybeTagName) || maybeTagName.indexOf('-') != -1) | |
| 29 return; | |
| 30 var element; | |
| 31 try { | |
| 32 element = document.createElement(maybeTagName); | |
| 33 } catch (e) { | |
| 34 // Okay to ignore when document.createElement fails | |
| 35 return; | |
| 36 } | |
| 37 ['open', 'closed'].forEach((mode) => { | |
| 38 assert_throws({name: 'NotSupportedError'}, () => { | |
| 39 element.attachShadow({mode: mode}); | |
| 40 }), 'attachShadow should throw NotSupportdeError for ' + maybeTagName; | |
| 41 }); | |
| 42 }); | |
| 43 }, 'attachShadow should throw an exception for an element which is not in the sa
felist'); | |
| 44 </script> | |
| OLD | NEW |