2 <script src="../../resources/js-test.js"></script>
6 description("This tests that document.createEvent is hooked up for all Event interfaces (and alternatives) and creates the right instance.")
9 shouldBeTrue("document.createEvent('AnimationEvent') instanceof window.AnimationEvent");
10 shouldBeTrue("document.createEvent('AnimationEvent') instanceof window.Event");
11 shouldBeTrue("document.createEvent('AnimationEvent').constructor === window.AnimationEvent");
14 shouldBeTrue("document.createEvent('Event') instanceof window.Event");
15 shouldBeTrue("document.createEvent('Event').constructor === window.Event");
16 shouldBeTrue("document.createEvent('EvENt') instanceof window.Event");
17 shouldBeTrue("document.createEvent('EvENt').constructor === window.Event");
19 // Events (Event alternative)
20 shouldBeTrue("document.createEvent('Events') instanceof window.Event");
21 shouldBeTrue("document.createEvent('Events').constructor === window.Event");
22 shouldBeTrue("document.createEvent('EvENts') instanceof window.Event");
23 shouldBeTrue("document.createEvent('EvENts').constructor === window.Event");
25 // HTMLEvents (Event alternative)
26 shouldBeTrue("document.createEvent('HTMLEvents') instanceof window.Event");
27 shouldBeTrue("document.createEvent('HTMLEvents').constructor === window.Event");
28 shouldBeTrue("document.createEvent('HTMLEvENts') instanceof window.Event");
29 shouldBeTrue("document.createEvent('HTMLEvENts').constructor === window.Event");
32 shouldBeTrue("document.createEvent('CompositionEvent') instanceof window.CompositionEvent");
33 shouldBeTrue("document.createEvent('CompositionEvent') instanceof window.Event");
34 shouldBeTrue("document.createEvent('CompositionEvent').constructor === window.CompositionEvent");
37 shouldBeTrue("document.createEvent('CustomEvent') instanceof window.CustomEvent");
38 shouldBeTrue("document.createEvent('CustomEvent') instanceof window.Event");
39 shouldBeTrue("document.createEvent('CustomEvent').constructor === window.CustomEvent");
40 shouldBeTrue("document.createEvent('CustomEvENt') instanceof window.CustomEvent");
41 shouldBeTrue("document.createEvent('CustomEvENt') instanceof window.Event");
42 shouldBeTrue("document.createEvent('CustomEvENt').constructor === window.CustomEvent");
45 shouldBeTrue("document.createEvent('ErrorEvent') instanceof window.ErrorEvent");
46 shouldBeTrue("document.createEvent('ErrorEvent') instanceof window.Event");
47 shouldBeTrue("document.createEvent('ErrorEvent').constructor === window.ErrorEvent");
50 shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.HashChangeEvent");
51 shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.Event");
52 shouldBeTrue("document.createEvent('HashChangeEvent').constructor === window.HashChangeEvent");
55 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.KeyboardEvent");
56 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.UIEvent");
57 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.Event");
58 shouldBeTrue("document.createEvent('KeyboardEvent').constructor === window.KeyboardEvent");
60 // KeyboardEvents (KeyboardEvent alternative)
61 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.KeyboardEvent");
62 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.UIEvent");
63 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.Event");
64 shouldBeTrue("document.createEvent('KeyboardEvents').constructor === window.KeyboardEvent");
67 shouldBeTrue("document.createEvent('MessageEvent') instanceof window.MessageEvent");
68 shouldBeTrue("document.createEvent('MessageEvent') instanceof window.Event");
69 shouldBeTrue("document.createEvent('MessageEvent').constructor === window.MessageEvent");
72 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.MouseEvent");
73 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.UIEvent");
74 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.Event");
75 shouldBeTrue("document.createEvent('MouseEvent').constructor === window.MouseEvent");
76 shouldBeTrue("document.createEvent('MouseEvENt') instanceof window.MouseEvent");
77 shouldBeTrue("document.createEvent('MouseEvENt') instanceof window.UIEvent");
78 shouldBeTrue("document.createEvent('MouseEvENt') instanceof window.Event");
79 shouldBeTrue("document.createEvent('MouseEvENt').constructor === window.MouseEvent");
81 // MouseEvents (MouseEvent alternative)
82 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.MouseEvent");
83 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.UIEvent");
84 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.Event");
85 shouldBeTrue("document.createEvent('MouseEvents').constructor === window.MouseEvent");
86 shouldBeTrue("document.createEvent('MouseEvENts') instanceof window.MouseEvent");
87 shouldBeTrue("document.createEvent('MouseEvENts') instanceof window.UIEvent");
88 shouldBeTrue("document.createEvent('MouseEvENts') instanceof window.Event");
89 shouldBeTrue("document.createEvent('MouseEvENts').constructor === window.MouseEvent");
92 shouldBeTrue("document.createEvent('MutationEvent') instanceof window.MutationEvent");
93 shouldBeTrue("document.createEvent('MutationEvent') instanceof window.Event");
94 shouldBeTrue("document.createEvent('MutationEvent').constructor === window.MutationEvent");
96 // MutationEvents (MutationEvent alternative)
97 shouldBeTrue("document.createEvent('MutationEvents') instanceof window.MutationEvent");
98 shouldBeTrue("document.createEvent('MutationEvents') instanceof window.Event");
99 shouldBeTrue("document.createEvent('MutationEvents').constructor === window.MutationEvent");
102 shouldBeTrue("document.createEvent('OverflowEvent') instanceof window.OverflowEvent");
103 shouldBeTrue("document.createEvent('OverflowEvent') instanceof window.Event");
104 shouldBeTrue("document.createEvent('OverflowEvent').constructor === window.OverflowEvent");
106 // PageTransitionEvent
107 shouldBeTrue("document.createEvent('PageTransitionEvent') instanceof window.PageTransitionEvent");
108 shouldBeTrue("document.createEvent('PageTransitionEvent') instanceof window.Event");
109 shouldBeTrue("document.createEvent('PageTransitionEvent').constructor === window.PageTransitionEvent");
112 shouldBeTrue("document.createEvent('PopStateEvent') instanceof window.PopStateEvent");
113 shouldBeTrue("document.createEvent('PopStateEvent') instanceof window.Event");
114 shouldBeTrue("document.createEvent('PopStateEvent').constructor === window.PopStateEvent");
117 shouldBeTrue("document.createEvent('ProgressEvent') instanceof window.ProgressEvent");
118 shouldBeTrue("document.createEvent('ProgressEvent') instanceof window.Event");
119 shouldBeTrue("document.createEvent('ProgressEvent').constructor === window.ProgressEvent");
122 shouldBeTrue("document.createEvent('TextEvent') instanceof window.TextEvent");
123 shouldBeTrue("document.createEvent('TextEvent') instanceof window.UIEvent");
124 shouldBeTrue("document.createEvent('TextEvent') instanceof window.Event");
125 shouldBeTrue("document.createEvent('TextEvent').constructor === window.TextEvent");
128 shouldBeTrue("document.createEvent('UIEvent') instanceof window.UIEvent");
129 shouldBeTrue("document.createEvent('UIEvent') instanceof window.Event");
130 shouldBeTrue("document.createEvent('UIEvent').constructor === window.UIEvent");
131 shouldBeTrue("document.createEvent('UIEvENt') instanceof window.UIEvent");
132 shouldBeTrue("document.createEvent('UIEvENt') instanceof window.Event");
133 shouldBeTrue("document.createEvent('UIEvENt').constructor === window.UIEvent");
135 // UIEvents (UIEvent alternative)
136 shouldBeTrue("document.createEvent('UIEvents') instanceof window.UIEvent");
137 shouldBeTrue("document.createEvent('UIEvents') instanceof window.Event");
138 shouldBeTrue("document.createEvent('UIEvents').constructor === window.UIEvent");
139 shouldBeTrue("document.createEvent('UIEvENts') instanceof window.UIEvent");
140 shouldBeTrue("document.createEvent('UIEvENts') instanceof window.Event");
141 shouldBeTrue("document.createEvent('UIEvENts').constructor === window.UIEvent");
144 shouldBeTrue("document.createEvent('TransitionEvent') instanceof window.TransitionEvent");
145 shouldBeTrue("document.createEvent('TransitionEvent') instanceof window.Event");
146 shouldBeTrue("document.createEvent('TransitionEvent').constructor === window.TransitionEvent");
148 // WebKitAnimationEvent
149 shouldBeTrue("document.createEvent('WebKitAnimationEvent') instanceof window.WebKitAnimationEvent");
150 shouldBeTrue("document.createEvent('WebKitAnimationEvent') instanceof window.Event");
151 shouldBeTrue("document.createEvent('WebKitAnimationEvent').constructor === window.WebKitAnimationEvent");
153 // WebKitTransitionEvent
154 shouldBeTrue("document.createEvent('WebKitTransitionEvent') instanceof window.WebKitTransitionEvent");
155 shouldBeTrue("document.createEvent('WebKitTransitionEvent') instanceof window.Event");
156 shouldBeTrue("document.createEvent('WebKitTransitionEvent').constructor === window.WebKitTransitionEvent");
159 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.WheelEvent");
160 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.MouseEvent");
161 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.UIEvent");
162 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.Event");
163 shouldBeTrue("document.createEvent('WheelEvent').constructor === window.WheelEvent");
165 // XMLHttpRequestProgressEvent
166 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.XMLHttpRequestProgressEvent");
167 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.ProgressEvent");
168 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.Event");
169 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent').constructor === window.XMLHttpRequestProgressEvent");
172 shouldBeTrue("document.createEvent('StorageEvent') instanceof window.StorageEvent");
173 shouldBeTrue("document.createEvent('StorageEvent') instanceof window.Event");
174 shouldBeTrue("document.createEvent('StorageEvent').constructor === window.StorageEvent");
176 // SVGEvents (Event alternative)
177 shouldBeTrue("document.createEvent('SVGEvents') instanceof window.Event");
178 shouldBeTrue("document.createEvent('SVGEvents').constructor === window.Event");
181 shouldBeTrue("document.createEvent('SVGZoomEvent') instanceof window.SVGZoomEvent");
182 shouldBeTrue("document.createEvent('SVGZoomEvent') instanceof window.Event");
183 shouldBeTrue("document.createEvent('SVGZoomEvent').constructor === window.SVGZoomEvent");
185 // SVGZoomEvents (SVGZoomEvent alternative)
186 shouldBeTrue("document.createEvent('SVGZoomEvents') instanceof window.SVGZoomEvent");
187 shouldBeTrue("document.createEvent('SVGZoomEvents') instanceof window.Event");
188 shouldBeTrue("document.createEvent('SVGZoomEvents').constructor === window.SVGZoomEvent");
191 shouldBeTrue("document.createEvent('CloseEvent') instanceof window.CloseEvent");
192 shouldBeTrue("document.createEvent('CloseEvent') instanceof window.Event");
193 shouldBeTrue("document.createEvent('CloseEvent').constructor === window.CloseEvent");
195 // The following are here for completeness, but won't until there is more widespread support for them.
197 // #if ENABLE(WEB_AUDIO)
198 // AudioProcessingEvent
199 // shouldBeTrue("document.createEvent('AudioProcessingEvent') instanceof window.AudioProcessingEvent");
200 // shouldBeTrue("document.createEvent('AudioProcessingEvent') instanceof window.Event");
201 // shouldBeTrue("document.createEvent('AudioProcessingEvent').constructor === window.AudioProcessingEvent");
203 // #if ENABLE(WEB_AUDIO)
204 // OfflineAudioCompletionEvent
205 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent') instanceof window.OfflineAudioCompletionEvent");
206 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent') instanceof window.Event");
207 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent').constructor === window.OfflineAudioCompletionEvent");
210 // shouldBeTrue("document.createEvent('MediaStreamEvent') instanceof window.MediaStreamEvent");
211 // shouldBeTrue("document.createEvent('MediaStreamEvent') instanceof window.Event");
212 // shouldBeTrue("document.createEvent('MediaStreamEvent').constructor === window.MediaStreamEvent");
216 // shouldBeTrue("document.createEvent('WebGLContextEvent') instanceof window.WebGLContextEvent");
217 // shouldBeTrue("document.createEvent('WebGLContextEvent') instanceof window.Event");
218 // shouldBeTrue("document.createEvent('WebGLContextEvent').constructor === window.WebGLContextEvent");
221 shouldBeTrue("document.createEvent('TouchEvent') instanceof window.TouchEvent");
222 shouldBeTrue("document.createEvent('TouchEvent') instanceof window.Event");
223 shouldBeTrue("document.createEvent('TouchEvent').constructor === window.TouchEvent");
226 // shouldBeTrue("document.createEvent('DeviceMotionEvent') instanceof window.DeviceMotionEvent");
227 // shouldBeTrue("document.createEvent('DeviceMotionEvent') instanceof window.Event");
228 // shouldBeTrue("document.createEvent('DeviceMotionEvent').constructor === window.DeviceMotionEvent");
230 // DeviceOrientationEvent
231 // shouldBeTrue("document.createEvent('DeviceOrientationEvent') instanceof window.DeviceOrientationEvent");
232 // shouldBeTrue("document.createEvent('DeviceOrientationEvent') instanceof window.Event");
233 // shouldBeTrue("document.createEvent('DeviceOrientationEvent').constructor === window.DeviceOrientationEvent");
235 // OrientationEvent (Event alternative)
236 // shouldBeTrue("document.createEvent('OrientationEvent') instanceof window.Event");
237 // shouldBeTrue("document.createEvent('OrientationEvent').constructor === window.Event");
239 // AutocompleteErrorEvent
240 shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.AutocompleteErrorEvent");
241 shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.Event");
242 shouldBeTrue("document.createEvent('AutocompleteErrorEvent').constructor === window.AutocompleteErrorEvent");
244 // We test both a hard coded set and the automated set below (using enumeration) to ensure that a constructor being removed
245 // from the window is caught a regression.
247 var allEventInterfacesCreateEvents = true;
248 for (var propertyName in window) {
249 if (propertyName.match(/Event$/) && window[propertyName].toString().match(/EventConstructor\]$/)) {
251 if (!(document.createEvent(propertyName) instanceof window.Event)) {
252 allEventInterfacesCreateEvents = false;
253 debug("'document.createEvent(propertyName) instanceof window.Event' with propertyName: " + propertyName + " should be true but isn't");
256 allEventInterfacesCreateEvents = false;
257 debug("'document.createEvent(propertyName) instanceof window.Event' with propertyName: " + propertyName + " threw an exception: " + e);
261 if (!(document.createEvent(propertyName) instanceof window[propertyName])) {
262 allEventInterfacesCreateEvents = false;
263 debug("'document.createEvent(propertyName) instanceof window[propertyName]' with propertyName: " + propertyName + " should be true but isn't");
266 allEventInterfacesCreateEvents = false;
267 debug("'document.createEvent(propertyName) instanceof window[propertyName]' with propertyName: " + propertyName + " threw an exception: " + e);
271 if (!(document.createEvent(propertyName).constructor === window[propertyName])) {
272 allEventInterfacesCreateEvents = false;
273 debug("'document.createEvent(propertyName).constructor === window[propertyName]' with propertyName: " + propertyName + " should be true but isn't");
276 allEventInterfacesCreateEvents = false;
277 debug("'document.createEvent(propertyName).constructor === window[propertyName]' with propertyName: " + propertyName + " threw an exception: " + e);
281 shouldBeTrue('allEventInterfacesCreateEvents');