OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset="utf-8"> |
| 3 <title></title> |
| 4 <script src="../../../../resources/testharness.js"></script> |
| 5 <script src="../../../../resources/testharnessreport.js"></script> |
| 6 <body> |
| 7 |
| 8 <button></button> |
| 9 <div id="foo"></div> |
| 10 <p data-foo=""></p> |
| 11 |
| 12 <script> |
| 13 test(function() { |
| 14 var buttonElement = document.getElementsByTagName('button')[0]; |
| 15 assert_equals(buttonElement.hasAttributes(), false, 'hasAttributes() on empt
y element must return false.'); |
| 16 |
| 17 var emptyDiv = document.createElement('div'); |
| 18 assert_equals(emptyDiv.hasAttributes(), false, 'hasAttributes() on dynamical
ly created empty element must return false.'); |
| 19 |
| 20 }, 'element.hasAttributes() must return false when the element does not have att
ribute.'); |
| 21 |
| 22 test(function() { |
| 23 var divWithId = document.getElementById('foo'); |
| 24 assert_equals(divWithId.hasAttributes(), true, 'hasAttributes() on element w
ith id attribute must return true.'); |
| 25 |
| 26 var divWithClass = document.createElement('div'); |
| 27 divWithClass.setAttribute('class', 'foo'); |
| 28 assert_equals(divWithClass.hasAttributes(), true, 'hasAttributes() on dynami
cally created element with class attribute must return true.'); |
| 29 |
| 30 var pWithCustomAttr = document.getElementsByTagName('p')[0]; |
| 31 assert_equals(pWithCustomAttr.hasAttributes(), true, 'hasAttributes() on ele
ment with custom attribute must return true.'); |
| 32 |
| 33 var divWithCustomAttr = document.createElement('div'); |
| 34 divWithCustomAttr.setAttribute('data-custom', 'foo'); |
| 35 assert_equals(divWithCustomAttr.hasAttributes(), true, 'hasAttributes() on d
ynamically created element with custom attribute must return true.'); |
| 36 |
| 37 }, 'element.hasAttributes() must return true when the element has attribute.'); |
| 38 |
| 39 </script> |
| 40 </body> |
OLD | NEW |