Backed out changeset f4e60efc867f (bug 923417) for B2G mochitest-2 failures.
[gecko.git] / dom / tests / mochitest / general / test_interfaces.html
blobe3fce3f48a0e18f605f5b7f2bf397b210dd50e52
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=766694
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 766694</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766694">Mozilla Bug 766694</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 766694 **/
23 // This is a list of all interfaces that are exposed to every webpage. Please only
24 // add things to this list with great care.
26 // IMPORTANT: Do not change this list without review from a JavaScript Engine peer!
27 var ecmaGlobals =
29 "Array",
30 "ArrayBuffer",
31 {name: "ArrayType", nightly: true},
32 "Boolean",
33 "DataView",
34 "Date",
35 {name: "Data", nightly: true},
36 "Error",
37 "EvalError",
38 "Float32Array",
39 "Float64Array",
40 "Function",
41 "Infinity",
42 "Int16Array",
43 "Int32Array",
44 "Int8Array",
45 "InternalError",
46 "Iterator",
47 "JSON",
48 "Map",
49 "Math",
50 "NaN",
51 "Number",
52 "Object",
53 {name: "ParallelArray", nightly: true},
54 "Proxy",
55 "RangeError",
56 "ReferenceError",
57 "RegExp",
58 "Set",
59 "StopIteration",
60 "String",
61 {name: "StructType", nightly: true},
62 "SyntaxError",
63 {name: "Type", nightly: true},
64 "TypeError",
65 "Uint16Array",
66 "Uint32Array",
67 "Uint8Array",
68 "Uint8ClampedArray",
69 "URIError",
70 "WeakMap",
72 // IMPORTANT: Do not change this list without review from a JavaScript Engine peer!
74 // IMPORTANT: Do not change this list without review from a DOM peer!
75 var interfaceNamesInGlobalScope =
77 "AnalyserNode",
78 "AnimationEvent",
79 "ArchiveRequest",
80 "Attr",
81 "Audio",
82 "AudioBuffer",
83 {name: "AudioChannelManager", b2g: true},
84 "AudioContext",
85 "AudioBufferSourceNode",
86 "AudioDestinationNode",
87 "AudioListener",
88 "AudioNode",
89 "AudioParam",
90 "AudioProcessingEvent",
91 "AudioStreamTrack",
92 "BarProp",
93 "BatteryManager",
94 "BeforeUnloadEvent",
95 "BiquadFilterNode",
96 "Blob",
97 "BlobEvent",
98 {name: "BluetoothAdapter", b2g: true},
99 {name: "BluetoothDevice", b2g: true},
100 {name: "BluetoothDeviceEvent", b2g: true},
101 {name: "BluetoothManager", b2g: true},
102 {name: "BluetoothStatusChangedEvent", b2g: true},
103 {name: "BoxObject", xbl: true},
104 {name: "BrowserFeedWriter", desktop: true},
105 {name: "CallEvent", b2g: true},
106 "CameraCapabilities",
107 "CameraControl",
108 "CameraManager",
109 "CanvasGradient",
110 "CanvasPattern",
111 "CanvasRenderingContext2D",
112 "CaretPosition",
113 "CDATASection",
114 {name: "CFStateChangeEvent", b2g: true},
115 "ChannelMergerNode",
116 "ChannelSplitterNode",
117 "CharacterData",
118 {name: "ChromeWindow", xbl: true},
119 "ClipboardEvent",
120 "CloseEvent",
121 "CommandEvent",
122 "Comment",
123 "CompositionEvent",
124 "Controllers",
125 "ConvolverNode",
126 {name: "CRMFObject", desktop: true},
127 "Crypto",
128 "CSS",
129 "CSS2Properties",
130 "CSSCharsetRule",
131 "CSSConditionRule",
132 "CSSFontFaceRule",
133 {name: "CSSFontFeatureValuesRule", release: false},
134 "CSSGroupingRule",
135 "CSSImportRule",
136 "CSSMediaRule",
137 "CSSMozDocumentRule",
138 "CSSNameSpaceRule",
139 "CSSPageRule",
140 "CSSPrimitiveValue",
141 "CSSRule",
142 "CSSRuleList",
143 "CSSStyleDeclaration",
144 "CSSStyleRule",
145 "CSSStyleSheet",
146 "CSSSupportsRule",
147 "CSSValue",
148 "CSSValueList",
149 "CustomEvent",
150 "DataChannel",
151 "DataContainerEvent",
152 {name: "DataErrorEvent", b2g: true},
153 "DataTransfer",
154 "DelayNode",
155 "DesktopNotification",
156 "DesktopNotificationCenter",
157 "DeviceAcceleration",
158 "DeviceLightEvent",
159 "DeviceMotionEvent",
160 "DeviceOrientationEvent",
161 "DeviceProximityEvent",
162 "DeviceRotationRate",
163 "DeviceStorage",
164 "DeviceStorageChangeEvent",
165 "Document",
166 "DocumentFragment",
167 "DocumentType",
168 {name: "DOMConstructor", xbl: true},
169 "DOMCursor",
170 "DOMError",
171 "DOMException",
172 "DOMImplementation",
173 "DOMMMIError",
174 "DOMParser",
175 "DOMRect",
176 "DOMRectList",
177 "DOMRequest",
178 "DOMSettableTokenList",
179 "DOMStringList",
180 "DOMStringMap",
181 "DOMTokenList",
182 "DOMTransactionEvent",
183 "DragEvent",
184 "DynamicsCompressorNode",
185 "Element",
186 "ElementReplaceEvent",
187 "ErrorEvent",
188 "Event",
189 "EventListenerInfo",
190 "EventSource",
191 "EventTarget",
192 "File",
193 "FileHandle",
194 "FileList",
195 "FileReader",
196 "FileRequest",
197 {name: "FMRadio", b2g: true},
198 "FocusEvent",
199 "FormData",
200 "GainNode",
201 {name: "Gamepad", desktop: true},
202 {name: "GamepadAxisMoveEvent", desktop: true},
203 {name: "GamepadButtonEvent", desktop: true},
204 {name: "GamepadEvent", desktop: true},
205 "HashChangeEvent",
206 "History",
207 "HTMLAnchorElement",
208 "HTMLAppletElement",
209 "HTMLAreaElement",
210 "HTMLAudioElement",
211 "HTMLBaseElement",
212 "HTMLBodyElement",
213 "HTMLBRElement",
214 "HTMLButtonElement",
215 "HTMLCanvasElement",
216 "HTMLCollection",
217 "HTMLDataElement",
218 "HTMLDataListElement",
219 "HTMLDirectoryElement",
220 "HTMLDivElement",
221 "HTMLDListElement",
222 "HTMLDocument",
223 "HTMLElement",
224 "HTMLEmbedElement",
225 "HTMLFieldSetElement",
226 "HTMLFontElement",
227 "HTMLFormControlsCollection",
228 "HTMLFormElement",
229 "HTMLFrameElement",
230 "HTMLFrameSetElement",
231 "HTMLHeadElement",
232 "HTMLHeadingElement",
233 "HTMLHRElement",
234 "HTMLHtmlElement",
235 "HTMLIFrameElement",
236 "HTMLImageElement",
237 "HTMLInputElement",
238 "HTMLLabelElement",
239 "HTMLLegendElement",
240 "HTMLLIElement",
241 "HTMLLinkElement",
242 "HTMLMapElement",
243 "HTMLMediaElement",
244 "HTMLMenuElement",
245 "HTMLMenuItemElement",
246 "HTMLMetaElement",
247 "HTMLMeterElement",
248 "HTMLModElement",
249 "HTMLObjectElement",
250 "HTMLOListElement",
251 "HTMLOptGroupElement",
252 "HTMLOptionElement",
253 "HTMLOptionsCollection",
254 "HTMLOutputElement",
255 "HTMLParagraphElement",
256 "HTMLParamElement",
257 "HTMLPreElement",
258 "HTMLProgressElement",
259 "HTMLPropertiesCollection",
260 "HTMLQuoteElement",
261 "HTMLScriptElement",
262 "HTMLSelectElement",
263 "HTMLSourceElement",
264 "HTMLSpanElement",
265 "HTMLStyleElement",
266 "HTMLTableCaptionElement",
267 "HTMLTableCellElement",
268 "HTMLTableColElement",
269 "HTMLTableElement",
270 "HTMLTableRowElement",
271 "HTMLTableSectionElement",
272 "HTMLTemplateElement",
273 "HTMLTextAreaElement",
274 "HTMLTimeElement",
275 "HTMLTitleElement",
276 "HTMLUListElement",
277 "HTMLUnknownElement",
278 "HTMLVideoElement",
279 {name: "IccCardLockErrorEvent", b2g: true},
280 "IDBCursor",
281 "IDBCursorWithValue",
282 "IDBDatabase",
283 "IDBFactory",
284 "IDBFileHandle",
285 "IDBIndex",
286 "IDBKeyRange",
287 "IDBObjectStore",
288 "IDBOpenDBRequest",
289 "IDBRequest",
290 "IDBTransaction",
291 "IDBVersionChangeEvent",
292 "Image",
293 "ImageData",
294 {name: "InstallTrigger", b2g: false, xbl: false},
295 "KeyEvent",
296 "KeyboardEvent",
297 "LoadStatus",
298 "LocalMediaStream",
299 "Location",
300 "LockedFile",
301 "MediaElementAudioSourceNode",
302 "MediaError",
303 "MediaList",
304 "MediaQueryList",
305 "MediaRecorder",
306 "MediaStream",
307 "MediaStreamAudioDestinationNode",
308 "MediaStreamAudioSourceNode",
309 "MediaStreamEvent",
310 "MediaStreamTrack",
311 "MessageEvent",
312 "MimeType",
313 "MimeTypeArray",
314 "ModalContentWindow",
315 "MouseEvent",
316 "MouseScrollEvent",
317 {name: "MozActivity", b2g: true},
318 "MozApplicationEvent",
319 {name: "MozCellBroadcast", b2g: true},
320 {name: "MozCellBroadcastEvent", b2g: true},
321 "MozConnection",
322 "mozContact",
323 "MozContactChangeEvent",
324 "MozCSSKeyframeRule",
325 "MozCSSKeyframesRule",
326 {name: "MozEmergencyCbModeEvent", b2g: true},
327 {name: "MozIccManager", b2g: true},
328 {name: "MozInputContext", b2g: true},
329 {name: "MozInputMethodManager", b2g: true},
330 "MozMmsEvent",
331 "MozMmsMessage",
332 {name: "MozMobileConnection", b2g: true},
333 "MozMobileMessageManager",
334 "MozMobileMessageThread",
335 "MozNamedAttrMap",
336 {name: "MozOtaStatusEvent", b2g: true},
337 "MozPowerManager",
338 "mozRTCIceCandidate",
339 "mozRTCPeerConnection",
340 "mozRTCSessionDescription",
341 "MozSettingsEvent",
342 "MozSmsEvent",
343 "MozSmsFilter",
344 "MozSmsMessage",
345 "MozSmsSegmentInfo",
346 {name: "MozStkCommandEvent", b2g: true},
347 {name: "MozTimeManager", b2g: true},
348 {name: "MozVoicemail", b2g: true},
349 {name: "MozVoicemailEvent", b2g: true},
350 "MozWakeLock",
351 {name: "MozWifiConnectionInfoEvent", b2g: true},
352 {name: "MozWifiStatusChangeEvent", b2g: true},
353 "MutationEvent",
354 "MutationObserver",
355 "MutationRecord",
356 "Navigator",
357 "Node",
358 "NodeFilter",
359 "NodeIterator",
360 "NodeList",
361 "NotifyAudioAvailableEvent",
362 "Notification",
363 "NotifyPaintEvent",
364 "OfflineAudioCompletionEvent",
365 "OfflineAudioContext",
366 "OfflineResourceList",
367 "Option",
368 "OscillatorNode",
369 "PageTransitionEvent",
370 "PaintRequest",
371 "PaintRequestList",
372 "PannerNode",
373 "Performance",
374 "PerformanceNavigation",
375 "PerformanceTiming",
376 "PeriodicWave",
377 "PhoneNumberService",
378 "Plugin",
379 "PluginArray",
380 "PopStateEvent",
381 "PopupBlockedEvent",
382 "ProcessingInstruction",
383 "ProgressEvent",
384 {name: "Promise", b2g: false, release: false},
385 "PropertyNodeList",
386 "Range",
387 "RecordErrorEvent",
388 "Rect",
389 "RGBColor",
390 "RTCDataChannelEvent",
391 "RTCPeerConnectionIceEvent",
392 "Screen",
393 "ScriptProcessorNode",
394 "ScrollAreaEvent",
395 "Selection",
396 "SettingsLock",
397 "SettingsManager",
398 "SimpleGestureEvent",
399 {name: "SimpleTest", xbl: false},
400 "SmartCardEvent",
401 "SpeechRecognitionError",
402 "SpeechRecognitionEvent",
403 "SpeechSynthesisEvent",
404 {name: "SpeechSynthesis", b2g: true},
405 {name: "SpeechSynthesisUtterance", b2g: true},
406 {name: "SpeechSynthesisVoice", b2g: true},
407 {name: "SpecialPowers", xbl: false},
408 "Storage",
409 "StorageEvent",
410 "StyleRuleChangeEvent",
411 "StyleSheet",
412 "StyleSheetApplicableStateChangeEvent",
413 "StyleSheetChangeEvent",
414 "StyleSheetList",
415 "SVGAElement",
416 "SVGAltGlyphElement",
417 "SVGAngle",
418 "SVGAnimatedAngle",
419 "SVGAnimatedBoolean",
420 "SVGAnimatedEnumeration",
421 "SVGAnimatedInteger",
422 "SVGAnimatedLength",
423 "SVGAnimatedLengthList",
424 "SVGAnimatedNumber",
425 "SVGAnimatedNumberList",
426 "SVGAnimatedPreserveAspectRatio",
427 "SVGAnimatedRect",
428 "SVGAnimatedString",
429 "SVGAnimatedTransformList",
430 "SVGAnimateElement",
431 "SVGAnimateMotionElement",
432 "SVGAnimateTransformElement",
433 "SVGAnimationElement",
434 "SVGCircleElement",
435 "SVGClipPathElement",
436 "SVGComponentTransferFunctionElement",
437 "SVGDefsElement",
438 "SVGDescElement",
439 "SVGDocument",
440 "SVGElement",
441 "SVGEllipseElement",
442 "SVGFEBlendElement",
443 "SVGFEColorMatrixElement",
444 "SVGFEComponentTransferElement",
445 "SVGFECompositeElement",
446 "SVGFEConvolveMatrixElement",
447 "SVGFEDiffuseLightingElement",
448 "SVGFEDisplacementMapElement",
449 "SVGFEDistantLightElement",
450 "SVGFEFloodElement",
451 "SVGFEFuncAElement",
452 "SVGFEFuncBElement",
453 "SVGFEFuncGElement",
454 "SVGFEFuncRElement",
455 "SVGFEGaussianBlurElement",
456 "SVGFEImageElement",
457 "SVGFEMergeElement",
458 "SVGFEMergeNodeElement",
459 "SVGFEMorphologyElement",
460 "SVGFEOffsetElement",
461 "SVGFEPointLightElement",
462 "SVGFESpecularLightingElement",
463 "SVGFESpotLightElement",
464 "SVGFETileElement",
465 "SVGFETurbulenceElement",
466 "SVGFilterElement",
467 "SVGForeignObjectElement",
468 "SVGGElement",
469 "SVGGradientElement",
470 "SVGGraphicsElement",
471 "SVGImageElement",
472 "SVGLength",
473 "SVGLengthList",
474 "SVGLinearGradientElement",
475 "SVGLineElement",
476 "SVGMarkerElement",
477 "SVGMaskElement",
478 "SVGMatrix",
479 "SVGMetadataElement",
480 "SVGMPathElement",
481 "SVGNumber",
482 "SVGNumberList",
483 "SVGPathElement",
484 "SVGPathSeg",
485 "SVGPathSegArcAbs",
486 "SVGPathSegArcRel",
487 "SVGPathSegClosePath",
488 "SVGPathSegCurvetoCubicAbs",
489 "SVGPathSegCurvetoCubicRel",
490 "SVGPathSegCurvetoCubicSmoothAbs",
491 "SVGPathSegCurvetoCubicSmoothRel",
492 "SVGPathSegCurvetoQuadraticAbs",
493 "SVGPathSegCurvetoQuadraticRel",
494 "SVGPathSegCurvetoQuadraticSmoothAbs",
495 "SVGPathSegCurvetoQuadraticSmoothRel",
496 "SVGPathSegLinetoAbs",
497 "SVGPathSegLinetoHorizontalAbs",
498 "SVGPathSegLinetoHorizontalRel",
499 "SVGPathSegLinetoRel",
500 "SVGPathSegLinetoVerticalAbs",
501 "SVGPathSegLinetoVerticalRel",
502 "SVGPathSegList",
503 "SVGPathSegMovetoAbs",
504 "SVGPathSegMovetoRel",
505 "SVGPatternElement",
506 "SVGPoint",
507 "SVGPointList",
508 "SVGPolygonElement",
509 "SVGPolylineElement",
510 "SVGPreserveAspectRatio",
511 "SVGRadialGradientElement",
512 "SVGRect",
513 "SVGRectElement",
514 "SVGScriptElement",
515 "SVGSetElement",
516 "SVGStopElement",
517 "SVGStringList",
518 "SVGStyleElement",
519 "SVGSVGElement",
520 "SVGSwitchElement",
521 "SVGSymbolElement",
522 "SVGTextContentElement",
523 "SVGTextElement",
524 "SVGTextPathElement",
525 "SVGTextPositioningElement",
526 "SVGTitleElement",
527 "SVGTransform",
528 "SVGTransformList",
529 "SVGTSpanElement",
530 "SVGUnitTypes",
531 "SVGUseElement",
532 "SVGViewElement",
533 "SVGZoomAndPan",
534 "SVGZoomEvent",
535 {name: "Telephony", b2g: true},
536 {name: "TelephonyCall", b2g: true},
537 {name: "TelephonyCallGroup", b2g: true},
538 "Text",
539 "TextDecoder",
540 "TextEncoder",
541 "TextMetrics",
542 "TimeEvent",
543 "TimeRanges",
544 "Touch",
545 "TouchEvent",
546 "TouchList",
547 "TrackEvent",
548 "TransitionEvent",
549 {name: "TreeColumn", xbl: true},
550 {name: "TreeColumns", xbl: true},
551 {name: "TreeContentView", xbl: true},
552 {name: "TreeSelection", xbl: true},
553 "TreeWalker",
554 "UIEvent",
555 "UndoManager",
556 "URL",
557 {name: "UserDataHandler", xbl: true},
558 "UserProximityEvent",
559 {name: "USSDReceivedEvent", b2g: true},
560 "ValidityState",
561 "VideoStreamTrack",
562 "WaveShaperNode",
563 "WebGLActiveInfo",
564 "WebGLBuffer",
565 "WebGLFramebuffer",
566 "WebGLProgram",
567 "WebGLRenderbuffer",
568 "WebGLRenderingContext",
569 "WebGLShader",
570 "WebGLShaderPrecisionFormat",
571 "WebGLTexture",
572 "WebGLUniformLocation",
573 "WebGLVertexArray",
574 "WebSocket",
575 "WheelEvent",
576 "Window",
577 "WindowUtils",
578 "XMLDocument",
579 "XMLHttpRequest",
580 "XMLHttpRequestUpload",
581 "XMLSerializer",
582 "XMLStylesheetProcessingInstruction",
583 "XPathEvaluator",
584 "XPathExpression",
585 "XPathNamespace",
586 "XPathNSResolver",
587 "XPathResult",
588 "XSLTProcessor",
589 {name: "XULButtonElement", xbl: true},
590 {name: "XULCheckboxElement", xbl: true},
591 {name: "XULCommandDispatcher", xbl: true},
592 {name: "XULCommandEvent", xbl: true},
593 {name: "XULControlElement", xbl: true},
594 {name: "XULControllers", xbl: true},
595 {name: "XULDocument", xbl: true},
596 {name: "XULElement", xbl: true},
597 {name: "XULLabeledControlElement", xbl: true},
598 {name: "XULPopupElement", xbl: true},
599 {name: "XULTemplateBuilder", xbl: true},
600 {name: "XULTreeBuilder", xbl: true},
602 // IMPORTANT: Do not change this list without review from a DOM peer!
604 function createInterfaceMap(isXBLScope) {
605 var version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
606 var isNightly = version.endsWith("a1");
607 var isRelease = !version.contains("a");
608 var isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
609 var isB2G = !isDesktop && !navigator.userAgent.contains("Android");
610 var interfaceMap = {};
611 for (var entry of ecmaGlobals) {
612 if (typeof(entry) === "string") {
613 // Standard ECMAScript global objects are not defined on the XBL scope.
614 interfaceMap[entry] = !isXBLScope;
615 } else if (entry.nightly === isNightly) {
616 interfaceMap[entry.name] = !isXBLScope;
617 } else {
618 interfaceMap[entry.name] = false;
621 for (var entry of interfaceNamesInGlobalScope) {
622 if (typeof(entry) === "string") {
623 interfaceMap[entry] = true;
624 } else if (entry.xbl === !isXBLScope ||
625 entry.desktop === !isDesktop ||
626 entry.b2g === !isB2G ||
627 entry.release === !isRelease) {
628 interfaceMap[entry.name] = false;
629 } else {
630 interfaceMap[entry.name] = true;
633 return interfaceMap;
636 function runTest(isXBLScope) {
637 var interfaceMap = createInterfaceMap(isXBLScope);
638 for (var name of Object.getOwnPropertyNames(window)) {
639 // An interfae name should start with an upper case character.
640 if (!/^(moz)?[A-Z]/.test(name)) {
641 continue;
643 ok(interfaceMap[name],
644 "If this is failing: DANGER, are you sure you want to expose the new interface " + name +
645 " to all webpages as a property on the window? Do not make a change to this file without a " +
646 " review from a DOM peer for that specific change!!! (or a JS peer for changes to ecmaGlobals)");
647 delete interfaceMap[name];
649 for (var name of Object.keys(interfaceMap)) {
650 ok(name in window === interfaceMap[name],
651 name + " should " + (interfaceMap[name] ? "" : " NOT") + " be defined on the " + (isXBLScope ? "XBL" : "global") +" scope");
652 if (!interfaceMap[name]) {
653 delete interfaceMap[name];
656 if (isXBLScope) {
657 todo_is(Object.keys(interfaceMap).length, 0,
658 "The following interface(s) are not enumerated: " + Object.keys(interfaceMap).join(", "));
659 } else {
660 is(Object.keys(interfaceMap).length, 0,
661 "The following interface(s) are not enumerated: " + Object.keys(interfaceMap).join(", "));
665 runTest(false);
666 SimpleTest.waitForExplicitFinish();
668 </script>
669 <span id="span" style="-moz-binding: url(file_interfaces.xml)"></span>
670 </pre>
671 </body>
672 </html>