blob: db122ec529a858d2fad4dcbbf0b28f1c069d7018 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests that the various init*Event() functions work on an event that has already been dispatched.");
function testEventInitFunction(_createEventString, _eventType, _initMethodName)
{
createEventString = _createEventString;
eventType = _eventType;
initMethodName = _initMethodName;
debug("* " + eventType + ".prototype." + initMethodName + "()");
evalAndLog("testEvent = document.createEvent(createEventString)");
shouldBe("testEvent.__proto__", "window[eventType].prototype");
evalAndLog("testEvent[initMethodName]('firstType', true, true)");
shouldBeEqualToString("testEvent.type", "firstType");
shouldBeTrue("testEvent.bubbles");
shouldBeTrue("testEvent.cancelable");
shouldBeTrue("document.body.dispatchEvent(testEvent)");
evalAndLog("testEvent[initMethodName]('secondType', false, false)");
shouldBeEqualToString("testEvent.type", "secondType");
shouldBeFalse("testEvent.bubbles");
shouldBeFalse("testEvent.cancelable");
shouldBeTrue("document.body.dispatchEvent(testEvent)");
debug("");
}
testEventInitFunction("compositionevent", "CompositionEvent", "initCompositionEvent");
testEventInitFunction("hashchangeevent", "HashChangeEvent", "initHashChangeEvent");
testEventInitFunction("keyboardevent", "KeyboardEvent", "initKeyboardEvent");
testEventInitFunction("messageevent", "MessageEvent", "initMessageEvent");
testEventInitFunction("textevent", "TextEvent", "initTextEvent");
testEventInitFunction("uievent", "UIEvent", "initUIEvent");
testEventInitFunction("storageevent", "StorageEvent", "initStorageEvent");
</script>
</body>
</html>