Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/the-button-element/interest-target/interesttarget-svg-a-event-dispatch.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8" />
<link rel="author" title="Keith Cirkel" href="mailto:keithamus@github.com" >
<link rel="author" title="Luke Warlow" href="mailto:lwarlow@igalia.com" >
<link rel="author" href="mailto:masonf@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/invoker-utils.js"></script>
<div id="interestee"></div>
<a id="nohref" interesttarget="interestee"><text x="50" y="90">SVG A</text></a>
</svg>
<a href="/" id="interestsvga" interesttarget="interestee"><text x="50" y="90">SVG A</text></a>
</svg>
<button id="otherbutton">Other Button</button>
<style>
[interesttarget] {
interest-target-delay: 0s;
}
</style>
<script>
promise_test(async function (t) {
t.add_cleanup(async () => {
await hoverOver(otherbutton);
});
let gotEvent = false;
interestee.addEventListener("interest", () => (gotEvent = true));
await hoverOver(nohref);
assert_false(gotEvent, "InterestEvent should not get fired");
nohref.setAttribute('href','foo');
await hoverOver(nohref);
assert_false(gotEvent, "adding href while the element is already hovered should not fire interest");
await hoverOver(otherbutton);
await hoverOver(nohref);
assert_true(gotEvent, "interest should now be fired");
}, "InterestEvent is not dispatched unless the svg <a> has an href");
promise_test(async function (t) {
t.add_cleanup(async () => {
await hoverOver(otherbutton);
});
let event = null;
interestee.addEventListener("interest", (e) => (event = e), { once: true });
await hoverOver(interestsvga);
assert_true(!!event, "InterestEvent is fired");
assert_true(event instanceof InterestEvent, "event is InterestEvent");
assert_equals(event.type, "interest", "type");
assert_equals(event.bubbles, false, "bubbles");
assert_equals(event.composed, true, "composed");
assert_equals(event.isTrusted, true, "isTrusted");
assert_equals(event.target, interestee, "target");
assert_equals(event.source, interestsvga, "source");
}, "InterestEvent dispatches on svg <a> hover");
</script>