hash-name-reference.html (1887B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>parsing a hash-name reference for img and object</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <style> 7 body { margin-top: 0 } 8 iframe { height: 600px; width:50px; border-top: none } 9 </style> 10 11 <div id="log"></div> 12 13 <iframe data-name="HTML (standards)" src="hash-name-reference-test-data.html?pipe=sub&doctype=html"></iframe> 14 <iframe data-name="HTML (quirks)" src="hash-name-reference-test-data.html?pipe=sub&doctype=quirks"></iframe> 15 <iframe data-name="XHTML" src="hash-name-reference-test-data.html?pipe=sub|header(Content-Type, application/xhtml%2Bxml)&doctype=html"></iframe> 16 17 <script> 18 setup({explicit_done: true}); 19 20 onload = function() { 21 var iframes = document.querySelectorAll('iframe'); 22 iframes.forEach(function(iframe) { 23 var iframeName = iframe.getAttribute('data-name'); 24 var doc = iframe.contentDocument; 25 var divs = doc.querySelectorAll('div[data-expect]'); 26 var div, img, object; 27 for (var i = 0; i < divs.length; ++i) { 28 div = divs[i]; 29 img = div.querySelector('img'); 30 object = div.querySelector('object'); 31 [img, object].forEach(function(elm) { 32 test(function(t) { 33 var expected = div.getAttribute('data-expect'); 34 var expected_elm = (expected === 'no match' || elm === object) ? elm : div.querySelector('area[href="#' + expected + '"]'); 35 var got_elm = doc.elementFromPoint(elm.offsetLeft, elm.offsetTop); 36 assert_not_equals(expected_elm, null, 'sanity check (data-expect value wrong?)'); 37 assert_not_equals(got_elm, null, 'sanity check (too many tests to fit in viewport?)'); 38 assert_equals(got_elm, expected_elm); 39 }, iframeName + ' ' + elm.tagName + ' usemap=' + format_value(elm.useMap)); 40 }); 41 } 42 }); 43 done(); 44 }; 45 </script>