2 <script src="../js/resources/js-test-pre.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('Event') instanceof window.Event");
10 shouldBeTrue("document.createEvent('Event').constructor === window.Event");
12 // Events (Event alternative)
13 shouldBeTrue("document.createEvent('Events') instanceof window.Event");
14 shouldBeTrue("document.createEvent('Events').constructor === window.Event");
16 // HTMLEvents (Event alternative)
17 shouldBeTrue("document.createEvent('HTMLEvents') instanceof window.Event");
18 shouldBeTrue("document.createEvent('HTMLEvents').constructor === window.Event");
21 shouldBeTrue("document.createEvent('BeforeLoadEvent') instanceof window.BeforeLoadEvent");
22 shouldBeTrue("document.createEvent('BeforeLoadEvent') instanceof window.Event");
23 shouldBeTrue("document.createEvent('BeforeLoadEvent').constructor === window.BeforeLoadEvent");
26 shouldBeTrue("document.createEvent('CompositionEvent') instanceof window.CompositionEvent");
27 shouldBeTrue("document.createEvent('CompositionEvent') instanceof window.Event");
28 shouldBeTrue("document.createEvent('CompositionEvent').constructor === window.CompositionEvent");
31 shouldBeTrue("document.createEvent('CustomEvent') instanceof window.CustomEvent");
32 shouldBeTrue("document.createEvent('CustomEvent') instanceof window.Event");
33 shouldBeTrue("document.createEvent('CustomEvent').constructor === window.CustomEvent");
36 shouldBeTrue("document.createEvent('ErrorEvent') instanceof window.ErrorEvent");
37 shouldBeTrue("document.createEvent('ErrorEvent') instanceof window.Event");
38 shouldBeTrue("document.createEvent('ErrorEvent').constructor === window.ErrorEvent");
41 shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.HashChangeEvent");
42 shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.Event");
43 shouldBeTrue("document.createEvent('HashChangeEvent').constructor === window.HashChangeEvent");
46 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.KeyboardEvent");
47 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.UIEvent");
48 shouldBeTrue("document.createEvent('KeyboardEvent') instanceof window.Event");
49 shouldBeTrue("document.createEvent('KeyboardEvent').constructor === window.KeyboardEvent");
51 // KeyboardEvents (KeyboardEvent alternative)
52 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.KeyboardEvent");
53 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.UIEvent");
54 shouldBeTrue("document.createEvent('KeyboardEvents') instanceof window.Event");
55 shouldBeTrue("document.createEvent('KeyboardEvents').constructor === window.KeyboardEvent");
58 shouldBeTrue("document.createEvent('MessageEvent') instanceof window.MessageEvent");
59 shouldBeTrue("document.createEvent('MessageEvent') instanceof window.Event");
60 shouldBeTrue("document.createEvent('MessageEvent').constructor === window.MessageEvent");
63 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.MouseEvent");
64 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.UIEvent");
65 shouldBeTrue("document.createEvent('MouseEvent') instanceof window.Event");
66 shouldBeTrue("document.createEvent('MouseEvent').constructor === window.MouseEvent");
68 // MouseEvents (MouseEvent alternative)
69 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.MouseEvent");
70 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.UIEvent");
71 shouldBeTrue("document.createEvent('MouseEvents') instanceof window.Event");
72 shouldBeTrue("document.createEvent('MouseEvents').constructor === window.MouseEvent");
75 shouldBeTrue("document.createEvent('MutationEvent') instanceof window.MutationEvent");
76 shouldBeTrue("document.createEvent('MutationEvent') instanceof window.Event");
77 shouldBeTrue("document.createEvent('MutationEvent').constructor === window.MutationEvent");
79 // MutationEvents (MutationEvent alternative)
80 shouldBeTrue("document.createEvent('MutationEvents') instanceof window.MutationEvent");
81 shouldBeTrue("document.createEvent('MutationEvents') instanceof window.Event");
82 shouldBeTrue("document.createEvent('MutationEvents').constructor === window.MutationEvent");
85 shouldBeTrue("document.createEvent('OverflowEvent') instanceof window.OverflowEvent");
86 shouldBeTrue("document.createEvent('OverflowEvent') instanceof window.Event");
87 shouldBeTrue("document.createEvent('OverflowEvent').constructor === window.OverflowEvent");
89 // PageTransitionEvent
90 shouldBeTrue("document.createEvent('PageTransitionEvent') instanceof window.PageTransitionEvent");
91 shouldBeTrue("document.createEvent('PageTransitionEvent') instanceof window.Event");
92 shouldBeTrue("document.createEvent('PageTransitionEvent').constructor === window.PageTransitionEvent");
95 shouldBeTrue("document.createEvent('PopStateEvent') instanceof window.PopStateEvent");
96 shouldBeTrue("document.createEvent('PopStateEvent') instanceof window.Event");
97 shouldBeTrue("document.createEvent('PopStateEvent').constructor === window.PopStateEvent");
100 shouldBeTrue("document.createEvent('ProgressEvent') instanceof window.ProgressEvent");
101 shouldBeTrue("document.createEvent('ProgressEvent') instanceof window.Event");
102 shouldBeTrue("document.createEvent('ProgressEvent').constructor === window.ProgressEvent");
105 shouldBeTrue("document.createEvent('TextEvent') instanceof window.TextEvent");
106 shouldBeTrue("document.createEvent('TextEvent') instanceof window.UIEvent");
107 shouldBeTrue("document.createEvent('TextEvent') instanceof window.Event");
108 shouldBeTrue("document.createEvent('TextEvent').constructor === window.TextEvent");
111 shouldBeTrue("document.createEvent('UIEvent') instanceof window.UIEvent");
112 shouldBeTrue("document.createEvent('UIEvent') instanceof window.Event");
113 shouldBeTrue("document.createEvent('UIEvent').constructor === window.UIEvent");
115 // UIEvents (UIEvent alternative)
116 shouldBeTrue("document.createEvent('UIEvents') instanceof window.UIEvent");
117 shouldBeTrue("document.createEvent('UIEvents') instanceof window.Event");
118 shouldBeTrue("document.createEvent('UIEvents').constructor === window.UIEvent");
120 // WebKitAnimationEvent
121 shouldBeTrue("document.createEvent('WebKitAnimationEvent') instanceof window.WebKitAnimationEvent");
122 shouldBeTrue("document.createEvent('WebKitAnimationEvent') instanceof window.Event");
123 shouldBeTrue("document.createEvent('WebKitAnimationEvent').constructor === window.WebKitAnimationEvent");
125 // WebKitTransitionEvent
126 shouldBeTrue("document.createEvent('WebKitTransitionEvent') instanceof window.WebKitTransitionEvent");
127 shouldBeTrue("document.createEvent('WebKitTransitionEvent') instanceof window.Event");
128 shouldBeTrue("document.createEvent('WebKitTransitionEvent').constructor === window.WebKitTransitionEvent");
131 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.WheelEvent");
132 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.MouseEvent");
133 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.UIEvent");
134 shouldBeTrue("document.createEvent('WheelEvent') instanceof window.Event");
135 shouldBeTrue("document.createEvent('WheelEvent').constructor === window.WheelEvent");
137 // XMLHttpRequestProgressEvent
138 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.XMLHttpRequestProgressEvent");
139 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.ProgressEvent");
140 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent') instanceof window.Event");
141 shouldBeTrue("document.createEvent('XMLHttpRequestProgressEvent').constructor === window.XMLHttpRequestProgressEvent");
144 shouldBeTrue("document.createEvent('StorageEvent') instanceof window.StorageEvent");
145 shouldBeTrue("document.createEvent('StorageEvent') instanceof window.Event");
146 shouldBeTrue("document.createEvent('StorageEvent').constructor === window.StorageEvent");
149 // SVGEvents (Event alternative)
150 shouldBeTrue("document.createEvent('SVGEvents') instanceof window.Event");
151 shouldBeTrue("document.createEvent('SVGEvents').constructor === window.Event");
155 shouldBeTrue("document.createEvent('SVGZoomEvent') instanceof window.SVGZoomEvent");
156 shouldBeTrue("document.createEvent('SVGZoomEvent') instanceof window.Event");
157 shouldBeTrue("document.createEvent('SVGZoomEvent').constructor === window.SVGZoomEvent");
160 // SVGZoomEvents (SVGZoomEvent alternative)
161 shouldBeTrue("document.createEvent('SVGZoomEvents') instanceof window.SVGZoomEvent");
162 shouldBeTrue("document.createEvent('SVGZoomEvents') instanceof window.Event");
163 shouldBeTrue("document.createEvent('SVGZoomEvents').constructor === window.SVGZoomEvent");
165 // #if ENABLE(WEB_SOCKETS)
167 shouldBeTrue("document.createEvent('CloseEvent') instanceof window.CloseEvent");
168 shouldBeTrue("document.createEvent('CloseEvent') instanceof window.Event");
169 shouldBeTrue("document.createEvent('CloseEvent').constructor === window.CloseEvent");
171 // The following are here for completeness, but won't until there is more widespread support for them.
173 // #if ENABLE(WEB_AUDIO)
174 // AudioProcessingEvent
175 // shouldBeTrue("document.createEvent('AudioProcessingEvent') instanceof window.AudioProcessingEvent");
176 // shouldBeTrue("document.createEvent('AudioProcessingEvent') instanceof window.Event");
177 // shouldBeTrue("document.createEvent('AudioProcessingEvent').constructor === window.AudioProcessingEvent");
179 // #if ENABLE(WEB_AUDIO)
180 // OfflineAudioCompletionEvent
181 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent') instanceof window.OfflineAudioCompletionEvent");
182 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent') instanceof window.Event");
183 // shouldBeTrue("document.createEvent('OfflineAudioCompletionEvent').constructor === window.OfflineAudioCompletionEvent");
185 // #if ENABLE(INPUT_SPEECH)
187 // shouldBeTrue("document.createEvent('MediaStreamEvent') instanceof window.MediaStreamEvent");
188 // shouldBeTrue("document.createEvent('MediaStreamEvent') instanceof window.Event");
189 // shouldBeTrue("document.createEvent('MediaStreamEvent').constructor === window.MediaStreamEvent");
191 // #if ENABLE(INPUT_SPEECH)
193 // shouldBeTrue("document.createEvent('SpeechInputEvent') instanceof window.SpeechInputEvent");
194 // shouldBeTrue("document.createEvent('SpeechInputEvent') instanceof window.Event");
195 // shouldBeTrue("document.createEvent('SpeechInputEvent').constructor === window.SpeechInputEvent");
199 // shouldBeTrue("document.createEvent('WebGLContextEvent') instanceof window.WebGLContextEvent");
200 // shouldBeTrue("document.createEvent('WebGLContextEvent') instanceof window.Event");
201 // shouldBeTrue("document.createEvent('WebGLContextEvent').constructor === window.WebGLContextEvent");
203 // #if ENABLE(TOUCH_EVENTS)
205 // shouldBeTrue("document.createEvent('TouchEvent') instanceof window.TouchEvent");
206 // shouldBeTrue("document.createEvent('TouchEvent') instanceof window.Event");
207 // shouldBeTrue("document.createEvent('TouchEvent').constructor === window.TouchEvent");
209 // #if ENABLE(DEVICE_ORIENTATION)
211 // shouldBeTrue("document.createEvent('DeviceMotionEvent') instanceof window.DeviceMotionEvent");
212 // shouldBeTrue("document.createEvent('DeviceMotionEvent') instanceof window.Event");
213 // shouldBeTrue("document.createEvent('DeviceMotionEvent').constructor === window.DeviceMotionEvent");
215 // #if ENABLE(DEVICE_ORIENTATION)
216 // DeviceOrientationEvent
217 // shouldBeTrue("document.createEvent('DeviceOrientationEvent') instanceof window.DeviceOrientationEvent");
218 // shouldBeTrue("document.createEvent('DeviceOrientationEvent') instanceof window.Event");
219 // shouldBeTrue("document.createEvent('DeviceOrientationEvent').constructor === window.DeviceOrientationEvent");
221 // #if ENABLE(ORIENTATION_EVENTS)
222 // OrientationEvent (Event alternative)
223 // shouldBeTrue("document.createEvent('OrientationEvent') instanceof window.Event");
224 // shouldBeTrue("document.createEvent('OrientationEvent').constructor === window.Event");
227 // We test both a hard coded set and the automated set below (using enumeration) to ensure that a constructor being removed
228 // from the window is caught a regression.
230 var allEventInterfacesCreateEvents = true;
231 for (var propertyName in window) {
232 if (propertyName.match(/Event$/) && window[propertyName].toString().match(/EventConstructor\]$/)) {
234 if (!(document.createEvent(propertyName) instanceof window.Event)) {
235 allEventInterfacesCreateEvents = false;
236 debug("'document.createEvent(propertyName) instanceof window.Event' with propertyName: " + propertyName + " should be true but isn't");
239 allEventInterfacesCreateEvents = false;
240 debug("'document.createEvent(propertyName) instanceof window.Event' with propertyName: " + propertyName + " threw an exception: " + e);
244 if (!(document.createEvent(propertyName) instanceof window[propertyName])) {
245 allEventInterfacesCreateEvents = false;
246 debug("'document.createEvent(propertyName) instanceof window[propertyName]' with propertyName: " + propertyName + " should be true but isn't");
249 allEventInterfacesCreateEvents = false;
250 debug("'document.createEvent(propertyName) instanceof window[propertyName]' with propertyName: " + propertyName + " threw an exception: " + e);
254 if (!(document.createEvent(propertyName).constructor === window[propertyName])) {
255 allEventInterfacesCreateEvents = false;
256 debug("'document.createEvent(propertyName).constructor === window[propertyName]' with propertyName: " + propertyName + " should be true but isn't");
259 allEventInterfacesCreateEvents = false;
260 debug("'document.createEvent(propertyName).constructor === window[propertyName]' with propertyName: " + propertyName + " threw an exception: " + e);
264 shouldBeTrue('allEventInterfacesCreateEvents');
269 <script src="../js/resources/js-test-post.js"></script>