details.html (1495B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>HTML details element API</title> 5 <style>#one, #two { visibility: hidden; }</style> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <div id="log"></div> 11 12 <!-- Used in parsing tests --> 13 <div id='one'><details></details><details></details></div> 14 <div id='two'><p><details></details></div> 15 16 <script type="text/javascript"> 17 18 function makeDetails () { 19 return document.createElement('details'); 20 } 21 22 23 // <details> 24 test(function () { 25 var times = document.getElementById('one').getElementsByTagName('details'); 26 assert_equals( times.length, 2 ); 27 }, 'HTML parsing should locate 2 details elements in this document'); 28 29 test(function () { 30 assert_equals( document.getElementById('two').getElementsByTagName('p')[0].innerHTML, '' ); 31 }, 'HTML parsing should close an unclosed <p> before <details>'); 32 33 test(function () { 34 assert_true( !!window.HTMLDetailsElement ); 35 }, 'HTMLDetailsElement should be exposed for prototyping'); 36 37 test(function () { 38 assert_true( makeDetails() instanceof window.HTMLDetailsElement); 39 }, 'a dynamically created details element should be instanceof HTMLDetailsElement'); 40 41 test(function () { 42 assert_true( document.getElementById('one').getElementsByTagName('details')[0] instanceof window.HTMLDetailsElement); 43 }, 'a details element from the parser should be instanceof HTMLDetailsElement'); 44 </script> 45 46 </body> 47 </html>