HTMLMetaElement.html (2876B)
1 <!DOCTYPE html> 2 <title>Custom Elements: CEReactions on HTMLMetaElement interface</title> 3 <link rel="author" title="Intel" href="http://www.intel.com"> 4 <meta name="assert" content="name, httpEquiv, content of 5 HTMLMetaElement interface must have CEReactions"> 6 <meta name="help" content="https://html.spec.whatwg.org/#the-meta-element"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="../../resources/custom-elements-helpers.js"></script> 10 <script src="../resources/reactions.js"></script> 11 12 <script> 13 14 function getParentElement() { 15 return document.head; 16 } 17 18 function setAttributes(instance, attribute, value) { 19 instance.setAttribute(attribute, value); 20 } 21 22 testReflectAttributeWithDependentAttributes( 23 'name', 'name', 'description', 24 'keywords', 'name on HTMLMetaElement', 'meta', 25 getParentElement, 26 instance => setAttributes(instance, 'content', 'HTMLMetaElement'), 27 HTMLMetaElement 28 ); 29 testReflectAttributeWithDependentAttributes( 30 'content', 'content', 'name1', 31 'name2', 'content on HTMLMetaElement', 'meta', 32 getParentElement, instance => setAttributes(instance, 'name', 'author'), 33 HTMLMetaElement 34 ); 35 36 test(() => { 37 let element = define_build_in_custom_element( 38 ['http-equiv'], HTMLMetaElement, 'meta' 39 ); 40 let instance = document.createElement('meta', { is: element.name }); 41 42 assert_array_equals(element.takeLog().types(), ['constructed']); 43 document.head.appendChild(instance); 44 assert_array_equals(element.takeLog().types(), ['connected']); 45 instance['content'] = '300'; 46 instance['httpEquiv'] = 'refresh'; 47 let logEntries = element.takeLog(); 48 assert_array_equals(logEntries.types(), ['attributeChanged']); 49 assert_attribute_log_entry(logEntries.last(), { 50 name: 'http-equiv', oldValue: null, newValue: 'refresh', namespace: null 51 }); 52 }, 'httpEquiv on HTMLMetaElement must enqueue an attributeChanged' 53 + ' reaction when adding a new attribute'); 54 55 test(() => { 56 let element = define_build_in_custom_element( 57 ['http-equiv'], HTMLMetaElement, 'meta' 58 ); 59 let instance = document.createElement('meta', { is: element.name }); 60 document.head.appendChild(instance); 61 62 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']); 63 instance['content'] = 'text/html; charset=UTF-8'; 64 instance['httpEquiv'] = 'content-type'; 65 assert_array_equals(element.takeLog().types(), ['attributeChanged']); 66 instance['content'] = '300'; 67 instance['httpEquiv'] = 'refresh'; 68 let logEntries = element.takeLog(); 69 assert_array_equals(logEntries.types(), ['attributeChanged']); 70 assert_attribute_log_entry(logEntries.last(), { 71 name: 'http-equiv', oldValue: 'content-type', 72 newValue: 'refresh', namespace: null 73 }); 74 }, 'httpEquiv on HTMLMetaElement must enqueue an attributeChanged' 75 + ' reaction when replacing an existing attribute'); 76 77 </script>