OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 <script type="text/javascript"> |
| 6 var formOwner; |
| 7 function hasFormOwner(shouldHaveOwner, haveIt, event) |
| 8 { |
| 9 formOwner = haveIt || "not defined"; |
| 10 debug("Testing " + event.target.tagName); |
| 11 if (shouldHaveOwner) |
| 12 shouldBeEqualToString("formOwner", "defined"); |
| 13 else |
| 14 shouldBeEqualToString("formOwner", "not defined"); |
| 15 } |
| 16 </script> |
| 17 </head> |
| 18 <body> |
| 19 <div style="display: none;"> |
| 20 <form id=topForm> |
| 21 <label form=topForm onerror="" onclick="hasFormOwner(true, typeof canary !== 'un
defined' && canary, event);"><input type="button"/></label> |
| 22 <!-- Form-associated elements per http://whatwg.org/specs/web-apps/current-work/
#form-associated-element --> |
| 23 <button onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, eve
nt);"></button> |
| 24 <fieldset onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, e
vent);"></fieldset> |
| 25 <input type=radio onerror="hasFormOwner(true, typeof canary !== 'undefined' && c
anary, event);"/> |
| 26 <input type=number onerror="hasFormOwner(true, typeof canary !== 'undefined' &&
canary, event);"/> |
| 27 <keygen keytype=rsa onerror="hasFormOwner(true, typeof canary !== 'undefined' &&
canary, event);"></keygen> |
| 28 <label onerror="" onclick="hasFormOwner(true, typeof canary !== 'undefined' && c
anary, event);"><input type="button"/></label> |
| 29 <object onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, eve
nt);"></object> |
| 30 <select onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, eve
nt);"></select> |
| 31 <textarea onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, e
vent);"></textarea> |
| 32 <img onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event)
;"></img> |
| 33 |
| 34 <!-- Elements that aren't associated. --> |
| 35 <option onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, ev
ent);"></option> |
| 36 <div onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event
);"></div> |
| 37 <a onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);
"></a> |
| 38 <p onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);
"></p> |
| 39 </form> |
| 40 |
| 41 <!-- Elements that associated by 'form' reference rather than ancestor. --> |
| 42 <input form=topForm type="number" onerror="hasFormOwner(true, typeof canary !==
'undefined' && canary, event);"/> |
| 43 <keygen form=topForm keytype=rsa onerror="hasFormOwner(true, typeof canary !== '
undefined' && canary, event);"></keygen> |
| 44 <object form=topForm onerror="hasFormOwner(true, typeof canary !== 'undefined' &
& canary, event);"></object> |
| 45 <select form=topForm onerror="hasFormOwner(true, typeof canary !== 'undefined' &
& canary, event);"></select> |
| 46 <pre form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' &&
canary, event);"></pre> |
| 47 <span form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' &&
canary, event);"></span> |
| 48 <img form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' &&
canary, event);"></img> |
| 49 </div> |
| 50 <script> |
| 51 description("Verify that only elements that are 'form associatable' get a form o
wner."); |
| 52 |
| 53 var elements; |
| 54 function testFormAssociation() |
| 55 { |
| 56 document.forms[0].canary = "defined"; |
| 57 elements = document.querySelectorAll("*[onerror]"); |
| 58 shouldBeTrue("elements.length > 0"); |
| 59 for (var i = 0; i < elements.length; ++i) { |
| 60 // <label/> won't handle 'error', use 'click'. |
| 61 var eventType = (elements[i] instanceof HTMLLabelElement) ? "click" : "e
rror"; |
| 62 elements[i].dispatchEvent(new Event(eventType)); |
| 63 } |
| 64 } |
| 65 testFormAssociation(); |
| 66 if (window.testRunner) |
| 67 testRunner.dumpAsText(); |
| 68 </script> |
| 69 </body> |
| 70 </html> |
OLD | NEW |