Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!doctype html>
<meta charset="utf-8" />
<meta name="author" title="Keith Cirkel" href="mailto:keithamus@github.com" />
<meta name="author" title="Luke Warlow" href="mailto:lwarlow@igalia.com" />
<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="div"></div>
<button id="button"></button>
<script>
test(function () {
const event = new InterestEvent("test");
assert_equals(event.action, "");
assert_readonly(event, "action", "readonly attribute value");
}, "action is a readonly defaulting to ''");
test(function () {
const event = new InterestEvent("test");
assert_equals(event.invoker, null);
assert_readonly(event, "invoker", "readonly attribute value");
}, "invoker is readonly defaulting to null");
test(function () {
const event = new InterestEvent("test", { action: "sAmPle" });
assert_equals(event.action, "sAmPle");
}, "action reflects initialized attribute");
test(function () {
const event = new InterestEvent("test", { action: undefined });
assert_equals(event.action, "");
}, "action set to undefined");
test(function () {
const event = new InterestEvent("test", { action: null });
assert_equals(event.action, "null");
}, "action set to null");
test(function () {
const event = new InterestEvent("test", { action: false });
assert_equals(event.action, "false");
}, "action set to false");
test(function () {
const event = new InterestEvent("test", { action: "" });
assert_equals(event.action, "");
}, "action explicitly set to empty string");
test(function () {
const event = new InterestEvent("test", { action: true });
assert_equals(event.action, "true");
}, "action set to true");
test(function () {
const event = new InterestEvent("test", { action: 0.5 });
assert_equals(event.action, "0.5");
}, "action set to a number");
test(function () {
const event = new InterestEvent("test", { action: [] });
assert_equals(event.action, "");
}, "action set to []");
test(function () {
const event = new InterestEvent("test", { action: [1, 2, 3] });
assert_equals(event.action, "1,2,3");
}, "action set to [1, 2, 3]");
test(function () {
const event = new InterestEvent("test", { action: { sample: 0.5 } });
assert_equals(event.action, "[object Object]");
}, "action set to an object");
test(function () {
const event = new InterestEvent("test", {
action: {
toString() {
return "sample";
},
},
});
assert_equals(event.action, "sample");
}, "action set to an object with a toString function");
test(function () {
const eventInit = { action: "sample", invoker: document.body };
const event = new InterestEvent("test", eventInit);
assert_equals(event.action, "sample");
assert_equals(event.invoker, document.body);
}, "InterestEventInit properties set value");
test(function () {
const eventInit = {
action: "open",
invoker: document.getElementById("div"),
};
const event = new InterestEvent("beforetoggle", eventInit);
assert_equals(event.action, "open");
assert_equals(event.invoker, document.getElementById("div"));
}, "InterestEventInit properties set value 2");
test(function () {
const eventInit = {
action: "closed",
invoker: document.getElementById("button"),
};
const event = new InterestEvent("toggle", eventInit);
assert_equals(event.action, "closed");
assert_equals(event.invoker, document.getElementById("button"));
}, "InterestEventInit properties set value 3");
test(function () {
const event = new InterestEvent("test", { invoker: undefined });
assert_equals(event.invoker, null);
}, "invoker set to undefined");
test(function () {
const event = new InterestEvent("test", { invoker: null });
assert_equals(event.invoker, null);
}, "invoker set to null");
test(function () {
assert_throws_js(
TypeError,
function () {
new InterestEvent("test", { invoker: false });
},
"invoker is not an object",
);
}, "invoker set to false");
test(function () {
assert_throws_js(
TypeError,
function () {
const event = new InterestEvent("test", { invoker: true });
},
"invoker is not an object",
);
}, "invoker set to true");
test(function () {
assert_throws_js(
TypeError,
function () {
const event = new InterestEvent("test", { invoker: {} });
},
"invoker is not an object",
);
}, "invoker set to {}");
test(function () {
assert_throws_js(
TypeError,
function () {
const eventInit = { action: "closed", invoker: new XMLHttpRequest() };
const event = new InterestEvent("toggle", eventInit);
},
"invoker is not an Element",
);
}, "invoker set to non-Element EventTarget");
</script>