Skip to content

Commit bedbd27

Browse files
committed
Merge pull request #295 from Ms2ger/createEvent-defaults
Test that the result of createEvent has its attributes initialized correctly
2 parents 8bed17c + ff0d6d9 commit bedbd27

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

dom/nodes/Document-createEvent.html

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
<!DOCTYPE html>
22
<meta charset=utf-8>
33
<title>Document.createEvent</title>
4-
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createevent">
4+
<link rel=help href="http://dom.spec.whatwg.org/#dom-document-createevent">
55
<script src="/resources/testharness.js"></script>
66
<script src="/resources/testharnessreport.js"></script>
77
<div id="log"></div>
88
<script>
9-
// TODO: values of attributes
109
function testAlias(arg, iface) {
10+
var ev;
1111
test(function() {
12-
if (iface === "Event" || iface in window) {
13-
var ev = document.createEvent(arg);
14-
assert_true(ev instanceof window[iface]);
15-
assert_true(ev instanceof Event);
16-
}
12+
ev = document.createEvent(arg);
13+
assert_true(ev instanceof window[iface]);
14+
assert_true(ev instanceof Event);
1715
}, arg + " should be an alias for " + iface + ".");
16+
test(function() {
17+
assert_equals(ev.type, "",
18+
"type should be initialized to the empty string");
19+
assert_equals(ev.target, null,
20+
"target should be initialized to null");
21+
assert_equals(ev.currentTarget, null,
22+
"currentTarget should be initialized to null");
23+
assert_equals(ev.eventPhase, 0,
24+
"eventPhase should be initialized to NONE (0)");
25+
assert_equals(ev.bubbles, false,
26+
"bubbles should be initialized to false");
27+
assert_equals(ev.cancelable, false,
28+
"cancelable should be initialized to false");
29+
assert_equals(ev.defaultPrevented, false,
30+
"defaultPrevented should be initialized to false");
31+
assert_equals(ev.isTrusted, false,
32+
"isTrusted should be initialized to false");
33+
}, "createEvent('" + arg + "') should be initialized correctly.");
1834
}
1935
[
36+
["CustomEvent", "CustomEvent"],
2037
["Event", "Event"],
2138
["Events", "Event"],
2239
["HTMLEvents", "Event"],
@@ -38,5 +55,9 @@
3855
// 'LATIN CAPITAL LETTER I WITH DOT ABOVE' (U+0130)
3956
var evt = document.createEvent("U\u0130Event");
4057
});
58+
assert_throws("NOT_SUPPORTED_ERR", function() {
59+
// 'LATIN SMALL LETTER DOTLESS I' (U+0131)
60+
var evt = document.createEvent("U\u0131Event");
61+
});
4162
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
4263
</script>

0 commit comments

Comments
 (0)