blob: d4d34c43a89eaa43a81bb4ce5e506de65d65ca18 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Tests calling initMutationEvent() on a mutation event while it is being dispatched and after.");
function eventHandler(ev) {
event = ev;
debug("");
debug("* In event handler");
shouldBeEqualToString("event.type", "foo");
shouldBeTrue("event.bubbles");
shouldBeFalse("event.cancelable");
shouldBe("event.target", "document.body");
shouldBe("event.currentTarget", "document.body");
shouldBe("event.eventPhase", "Event.AT_TARGET");
shouldBe("event.relatedNode", "document.body");
debug("");
// It should not be possible to re-initialize an event being dispatched.
shouldNotThrow('event.initMutationEvent("bar", false, true, document.documentElement)');
shouldBeEqualToString("event.type", "foo");
shouldBeTrue("event.bubbles");
shouldBeFalse("event.cancelable");
shouldBe("event.target", "document.body");
shouldBe("event.currentTarget", "document.body");
shouldBe("event.eventPhase", "Event.AT_TARGET");
shouldBe("event.relatedNode", "document.body");
}
var testEvent = document.createEvent("mutationevent");
shouldBe("testEvent.__proto__", "MutationEvent.prototype");
shouldNotThrow('testEvent.initMutationEvent("foo", true, false, document.body)');
shouldBeEqualToString("testEvent.type", "foo");
shouldBeTrue("testEvent.bubbles");
shouldBeFalse("testEvent.cancelable");
shouldBeNull("testEvent.target");
shouldBeNull("testEvent.currentTarget");
shouldBe("testEvent.eventPhase", "Event.NONE");
shouldBe("testEvent.relatedNode", "document.body");
document.body.addEventListener("foo", eventHandler);
shouldNotThrow('document.body.dispatchEvent(testEvent)');
debug("");
debug("* After event has been dispatched");
shouldBeEqualToString("testEvent.type", "foo");
shouldBeTrue("testEvent.bubbles");
shouldBeFalse("testEvent.cancelable");
shouldBe("testEvent.target", "document.body");
shouldBeNull("testEvent.currentTarget");
shouldBe("testEvent.eventPhase", "Event.NONE");
shouldBe("testEvent.relatedNode", "document.body");
// It should now be possible to re-initialize the event.
debug("");
shouldNotThrow('testEvent.initMutationEvent("bar", false, true, document.documentElement)');
shouldBeEqualToString("testEvent.type", "bar");
shouldBeFalse("testEvent.bubbles");
shouldBeTrue("testEvent.cancelable");
shouldBeNull("testEvent.target");
shouldBeNull("testEvent.currentTarget");
shouldBe("testEvent.eventPhase", "Event.NONE");
shouldBe("testEvent.relatedNode", "document.documentElement");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>