OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>onauxclick</title> |
| 3 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> |
| 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#handler-onauxclic
k"> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 |
| 8 <div id="auxclickme1" onauxclick="window.auxClick1Happened = true;"></div> |
| 9 <div id="auxclickme2" onauxclick="window.auxClick2Happened = true;"></div> |
| 10 |
| 11 <script> |
| 12 "use strict"; |
| 13 window.auxClick1Happened = false; |
| 14 window.auxClick2Happened = false; |
| 15 |
| 16 test(() => { |
| 17 for (const location of [window, HTMLElement.prototype, SVGElement.prototype, D
ocument.prototype]) { |
| 18 assert_true(location.hasOwnProperty("onauxclick"), |
| 19 `${location.constructor.name} has an own property named "onauxclick"`); |
| 20 } |
| 21 }, "onauxclick is on the appropriate locations for GlobalEventHandlers"); |
| 22 |
| 23 test(() => { |
| 24 const htmlElement = document.createElement("span"); |
| 25 const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "g")
; |
| 26 |
| 27 for (const location of [window, htmlElement, svgElement, document]) { |
| 28 assert_equals(location.onauxclick, null, |
| 29 `The default value of the property is null for a ${location.constructor.na
me} instance`); |
| 30 } |
| 31 }, "The default value of onauxclick is always null"); |
| 32 |
| 33 test(() => { |
| 34 const element = document.querySelector("#auxclickme1"); |
| 35 const compiledHandler = element.onauxclick; |
| 36 |
| 37 assert_equals(typeof compiledHandler, "function", "The onauxclick property mus
t be a function"); |
| 38 compiledHandler(); |
| 39 assert_true(window.auxClick1Happened, "Calling the handler must run the code")
; |
| 40 }, "The onauxclick content attribute must be compiled into the onauxclick proper
ty"); |
| 41 |
| 42 test(() => { |
| 43 const element = document.querySelector("#auxclickme2"); |
| 44 element.dispatchEvent(new Event("auxclick")); |
| 45 |
| 46 assert_true(window.auxClick2Happened, "Dispatching the event must run the code
"); |
| 47 }, "The onauxclick content attribute must execute when an event is dispatched"); |
| 48 |
| 49 test(() => { |
| 50 const element = document.createElement("meta"); |
| 51 element.onauxclick = e => { |
| 52 assert_equals(e.currentTarget, element, "The event must be fired at the <met
a> element"); |
| 53 }; |
| 54 |
| 55 element.dispatchEvent(new Event("auxclick")); |
| 56 }, "dispatching an auxclick event must trigger element.onauxclick"); |
| 57 |
| 58 </script> |
OLD | NEW |