gecko/dom/tests/mochitest/general/test_interfaces.html

671 lines
18 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=766694
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 766694</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766694">Mozilla Bug 766694</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 766694 **/
// This is a list of all interfaces that are exposed to every webpage. Please only
// add things to this list with great care.
// IMPORTANT: Do not change this list without review from a JavaScript Engine peer!
var ecmaGlobals =
[
"Array",
"ArrayBuffer",
{name: "ArrayType", nightly: true},
"Boolean",
"DataView",
"Date",
{name: "Data", nightly: true},
"Error",
"EvalError",
"Float32Array",
"Float64Array",
"Function",
"Infinity",
"Int16Array",
"Int32Array",
"Int8Array",
"InternalError",
"Iterator",
"JSON",
"Map",
"Math",
"NaN",
"Number",
"Object",
{name: "ParallelArray", nightly: true},
"Proxy",
"RangeError",
"ReferenceError",
"RegExp",
"Set",
"StopIteration",
"String",
{name: "StructType", nightly: true},
"SyntaxError",
{name: "Type", nightly: true},
"TypeError",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"URIError",
"WeakMap",
];
// IMPORTANT: Do not change this list without review from a JavaScript Engine peer!
// IMPORTANT: Do not change this list without review from a DOM peer!
var interfaceNamesInGlobalScope =
[
"AnalyserNode",
"AnimationEvent",
"ArchiveRequest",
"Attr",
"Audio",
"AudioBuffer",
{name: "AudioChannelManager", b2g: true},
"AudioContext",
"AudioBufferSourceNode",
"AudioDestinationNode",
"AudioListener",
"AudioNode",
"AudioParam",
"AudioProcessingEvent",
"AudioStreamTrack",
"BarProp",
"BatteryManager",
"BeforeUnloadEvent",
"BiquadFilterNode",
"Blob",
"BlobEvent",
{name: "BluetoothAdapter", b2g: true},
{name: "BluetoothDevice", b2g: true},
{name: "BluetoothDeviceEvent", b2g: true},
{name: "BluetoothManager", b2g: true},
{name: "BluetoothStatusChangedEvent", b2g: true},
{name: "BoxObject", xbl: true},
{name: "BrowserFeedWriter", desktop: true},
{name: "CallEvent", b2g: true},
"CameraCapabilities",
"CameraControl",
"CameraManager",
"CanvasGradient",
"CanvasPattern",
"CanvasRenderingContext2D",
"CaretPosition",
"CDATASection",
{name: "CFStateChangeEvent", b2g: true},
"ChannelMergerNode",
"ChannelSplitterNode",
"CharacterData",
{name: "ChromeWindow", xbl: true},
"ClientRect",
"ClientRectList",
"ClipboardEvent",
"CloseEvent",
"CommandEvent",
"Comment",
"CompositionEvent",
"Controllers",
"ConvolverNode",
{name: "CRMFObject", desktop: true},
"Crypto",
"CSS",
"CSS2Properties",
"CSSCharsetRule",
"CSSConditionRule",
"CSSFontFaceRule",
{name: "CSSFontFeatureValuesRule", release: false},
"CSSGroupingRule",
"CSSImportRule",
"CSSMediaRule",
"CSSMozDocumentRule",
"CSSNameSpaceRule",
"CSSPageRule",
"CSSPrimitiveValue",
"CSSRule",
"CSSRuleList",
"CSSStyleDeclaration",
"CSSStyleRule",
"CSSStyleSheet",
"CSSSupportsRule",
"CSSValue",
"CSSValueList",
"CustomEvent",
"DataChannel",
"DataContainerEvent",
{name: "DataErrorEvent", b2g: true},
"DataTransfer",
"DelayNode",
"DesktopNotification",
"DesktopNotificationCenter",
"DeviceAcceleration",
"DeviceLightEvent",
"DeviceMotionEvent",
"DeviceOrientationEvent",
"DeviceProximityEvent",
"DeviceRotationRate",
"DeviceStorage",
"DeviceStorageChangeEvent",
"Document",
"DocumentFragment",
"DocumentType",
{name: "DOMConstructor", xbl: true},
"DOMCursor",
"DOMError",
"DOMException",
"DOMImplementation",
"DOMMMIError",
"DOMParser",
"DOMRequest",
"DOMSettableTokenList",
"DOMStringList",
"DOMStringMap",
"DOMTokenList",
"DOMTransactionEvent",
"DragEvent",
"DynamicsCompressorNode",
"Element",
"ElementReplaceEvent",
"Event",
"EventListenerInfo",
"EventSource",
"EventTarget",
"File",
"FileHandle",
"FileList",
"FileReader",
"FileRequest",
{name: "FMRadio", b2g: true},
"FocusEvent",
"FormData",
"GainNode",
{name: "Gamepad", desktop: true},
{name: "GamepadAxisMoveEvent", desktop: true},
{name: "GamepadButtonEvent", desktop: true},
{name: "GamepadEvent", desktop: true},
"HashChangeEvent",
"History",
"HTMLAnchorElement",
"HTMLAppletElement",
"HTMLAreaElement",
"HTMLAudioElement",
"HTMLBaseElement",
"HTMLBodyElement",
"HTMLBRElement",
"HTMLButtonElement",
"HTMLCanvasElement",
"HTMLCollection",
"HTMLDataElement",
"HTMLDataListElement",
"HTMLDirectoryElement",
"HTMLDivElement",
"HTMLDListElement",
"HTMLDocument",
"HTMLElement",
"HTMLEmbedElement",
"HTMLFieldSetElement",
"HTMLFontElement",
"HTMLFormElement",
"HTMLFrameElement",
"HTMLFrameSetElement",
"HTMLHeadElement",
"HTMLHeadingElement",
"HTMLHRElement",
"HTMLHtmlElement",
"HTMLIFrameElement",
"HTMLImageElement",
"HTMLInputElement",
"HTMLLabelElement",
"HTMLLegendElement",
"HTMLLIElement",
"HTMLLinkElement",
"HTMLMapElement",
"HTMLMediaElement",
"HTMLMenuElement",
"HTMLMenuItemElement",
"HTMLMetaElement",
"HTMLMeterElement",
"HTMLModElement",
"HTMLObjectElement",
"HTMLOListElement",
"HTMLOptGroupElement",
"HTMLOptionElement",
"HTMLOptionsCollection",
"HTMLOutputElement",
"HTMLParagraphElement",
"HTMLParamElement",
"HTMLPreElement",
"HTMLProgressElement",
"HTMLPropertiesCollection",
"HTMLQuoteElement",
"HTMLScriptElement",
"HTMLSelectElement",
"HTMLSourceElement",
"HTMLSpanElement",
"HTMLStyleElement",
"HTMLTableCaptionElement",
"HTMLTableCellElement",
"HTMLTableColElement",
"HTMLTableElement",
"HTMLTableRowElement",
"HTMLTableSectionElement",
"HTMLTemplateElement",
"HTMLTextAreaElement",
"HTMLTimeElement",
"HTMLTitleElement",
"HTMLUListElement",
"HTMLUnknownElement",
"HTMLVideoElement",
{name: "IccCardLockErrorEvent", b2g: true},
"IDBCursor",
"IDBCursorWithValue",
"IDBDatabase",
"IDBFactory",
"IDBFileHandle",
"IDBIndex",
"IDBKeyRange",
"IDBObjectStore",
"IDBOpenDBRequest",
"IDBRequest",
"IDBTransaction",
"IDBVersionChangeEvent",
"Image",
"ImageData",
{name: "InstallTrigger", b2g: false, xbl: false},
"KeyEvent",
"KeyboardEvent",
"LoadStatus",
"LocalMediaStream",
"Location",
"LockedFile",
"MediaElementAudioSourceNode",
"MediaError",
"MediaList",
"MediaQueryList",
"MediaRecorder",
"MediaStream",
"MediaStreamAudioDestinationNode",
"MediaStreamAudioSourceNode",
"MediaStreamEvent",
"MediaStreamTrack",
"MessageEvent",
"MimeType",
"MimeTypeArray",
"ModalContentWindow",
"MouseEvent",
"MouseScrollEvent",
{name: "MozActivity", b2g: true},
"MozApplicationEvent",
{name: "MozCellBroadcast", b2g: true},
{name: "MozCellBroadcastEvent", b2g: true},
"MozConnection",
"mozContact",
"MozContactChangeEvent",
"MozCSSKeyframeRule",
"MozCSSKeyframesRule",
{name: "MozEmergencyCbModeEvent", b2g: true},
{name: "MozIccManager", b2g: true},
{name: "MozInputContext", b2g: true},
{name: "MozInputMethod", b2g: true},
{name: "MozInputMethodManager", b2g: true},
"MozMmsEvent",
"MozMmsMessage",
{name: "MozMobileConnection", b2g: true},
"MozMobileMessageManager",
"MozMobileMessageThread",
"MozNamedAttrMap",
{name: "MozOtaStatusEvent", b2g: true},
"MozPowerManager",
"mozRTCIceCandidate",
"mozRTCPeerConnection",
"mozRTCSessionDescription",
"MozSettingsEvent",
"MozSmsEvent",
"MozSmsFilter",
"MozSmsMessage",
"MozSmsSegmentInfo",
{name: "MozStkCommandEvent", b2g: true},
{name: "MozTimeManager", b2g: true},
{name: "MozVoicemail", b2g: true},
{name: "MozVoicemailEvent", b2g: true},
"MozWakeLock",
{name: "MozWifiConnectionInfoEvent", b2g: true},
{name: "MozWifiStatusChangeEvent", b2g: true},
"MutationEvent",
"MutationObserver",
"MutationRecord",
"Navigator",
"Node",
"NodeFilter",
"NodeIterator",
"NodeList",
"NotifyAudioAvailableEvent",
"Notification",
"NotifyPaintEvent",
"OfflineAudioCompletionEvent",
"OfflineAudioContext",
"OfflineResourceList",
"Option",
"OscillatorNode",
"PageTransitionEvent",
"PaintRequest",
"PaintRequestList",
"PannerNode",
"Performance",
"PerformanceNavigation",
"PerformanceTiming",
"PeriodicWave",
"PhoneNumberService",
"Plugin",
"PluginArray",
"PopStateEvent",
"PopupBlockedEvent",
"ProcessingInstruction",
"ProgressEvent",
{name: "Promise", b2g: false, release: false},
"PropertyNodeList",
"Range",
"RecordErrorEvent",
"Rect",
"RGBColor",
"RTCDataChannelEvent",
"RTCPeerConnectionIceEvent",
"Screen",
"ScriptProcessorNode",
"ScrollAreaEvent",
"Selection",
"SettingsLock",
"SettingsManager",
"SimpleGestureEvent",
{name: "SimpleTest", xbl: false},
"SmartCardEvent",
"SpeechRecognitionError",
"SpeechRecognitionEvent",
"SpeechSynthesisEvent",
{name: "SpeechSynthesis", b2g: true},
{name: "SpeechSynthesisUtterance", b2g: true},
{name: "SpeechSynthesisVoice", b2g: true},
{name: "SpecialPowers", xbl: false},
"Storage",
"StorageEvent",
"StyleRuleChangeEvent",
"StyleSheet",
"StyleSheetApplicableStateChangeEvent",
"StyleSheetChangeEvent",
"StyleSheetList",
"SVGAElement",
"SVGAltGlyphElement",
"SVGAngle",
"SVGAnimatedAngle",
"SVGAnimatedBoolean",
"SVGAnimatedEnumeration",
"SVGAnimatedInteger",
"SVGAnimatedLength",
"SVGAnimatedLengthList",
"SVGAnimatedNumber",
"SVGAnimatedNumberList",
"SVGAnimatedPreserveAspectRatio",
"SVGAnimatedRect",
"SVGAnimatedString",
"SVGAnimatedTransformList",
"SVGAnimateElement",
"SVGAnimateMotionElement",
"SVGAnimateTransformElement",
"SVGAnimationElement",
"SVGCircleElement",
"SVGClipPathElement",
"SVGComponentTransferFunctionElement",
"SVGDefsElement",
"SVGDescElement",
"SVGDocument",
"SVGElement",
"SVGEllipseElement",
"SVGFEBlendElement",
"SVGFEColorMatrixElement",
"SVGFEComponentTransferElement",
"SVGFECompositeElement",
"SVGFEConvolveMatrixElement",
"SVGFEDiffuseLightingElement",
"SVGFEDisplacementMapElement",
"SVGFEDistantLightElement",
"SVGFEFloodElement",
"SVGFEFuncAElement",
"SVGFEFuncBElement",
"SVGFEFuncGElement",
"SVGFEFuncRElement",
"SVGFEGaussianBlurElement",
"SVGFEImageElement",
"SVGFEMergeElement",
"SVGFEMergeNodeElement",
"SVGFEMorphologyElement",
"SVGFEOffsetElement",
"SVGFEPointLightElement",
"SVGFESpecularLightingElement",
"SVGFESpotLightElement",
"SVGFETileElement",
"SVGFETurbulenceElement",
"SVGFilterElement",
"SVGForeignObjectElement",
"SVGGElement",
"SVGGradientElement",
"SVGGraphicsElement",
"SVGImageElement",
"SVGLength",
"SVGLengthList",
"SVGLinearGradientElement",
"SVGLineElement",
"SVGMarkerElement",
"SVGMaskElement",
"SVGMatrix",
"SVGMetadataElement",
"SVGMPathElement",
"SVGNumber",
"SVGNumberList",
"SVGPathElement",
"SVGPathSeg",
"SVGPathSegArcAbs",
"SVGPathSegArcRel",
"SVGPathSegClosePath",
"SVGPathSegCurvetoCubicAbs",
"SVGPathSegCurvetoCubicRel",
"SVGPathSegCurvetoCubicSmoothAbs",
"SVGPathSegCurvetoCubicSmoothRel",
"SVGPathSegCurvetoQuadraticAbs",
"SVGPathSegCurvetoQuadraticRel",
"SVGPathSegCurvetoQuadraticSmoothAbs",
"SVGPathSegCurvetoQuadraticSmoothRel",
"SVGPathSegLinetoAbs",
"SVGPathSegLinetoHorizontalAbs",
"SVGPathSegLinetoHorizontalRel",
"SVGPathSegLinetoRel",
"SVGPathSegLinetoVerticalAbs",
"SVGPathSegLinetoVerticalRel",
"SVGPathSegList",
"SVGPathSegMovetoAbs",
"SVGPathSegMovetoRel",
"SVGPatternElement",
"SVGPoint",
"SVGPointList",
"SVGPolygonElement",
"SVGPolylineElement",
"SVGPreserveAspectRatio",
"SVGRadialGradientElement",
"SVGRect",
"SVGRectElement",
"SVGScriptElement",
"SVGSetElement",
"SVGStopElement",
"SVGStringList",
"SVGStyleElement",
"SVGSVGElement",
"SVGSwitchElement",
"SVGSymbolElement",
"SVGTextContentElement",
"SVGTextElement",
"SVGTextPathElement",
"SVGTextPositioningElement",
"SVGTitleElement",
"SVGTransform",
"SVGTransformList",
"SVGTSpanElement",
"SVGUnitTypes",
"SVGUseElement",
"SVGViewElement",
"SVGZoomAndPan",
"SVGZoomEvent",
{name: "Telephony", b2g: true},
{name: "TelephonyCall", b2g: true},
{name: "TelephonyCallGroup", b2g: true},
"Text",
"TextDecoder",
"TextEncoder",
"TextMetrics",
"TimeEvent",
"TimeRanges",
"Touch",
"TouchEvent",
"TouchList",
"TransitionEvent",
{name: "TreeColumn", xbl: true},
{name: "TreeColumns", xbl: true},
{name: "TreeContentView", xbl: true},
{name: "TreeSelection", xbl: true},
"TreeWalker",
"UIEvent",
"UndoManager",
"URL",
{name: "UserDataHandler", xbl: true},
"UserProximityEvent",
{name: "USSDReceivedEvent", b2g: true},
"ValidityState",
"VideoStreamTrack",
"WaveShaperNode",
"WebGLActiveInfo",
"WebGLBuffer",
"WebGLFramebuffer",
"WebGLProgram",
"WebGLRenderbuffer",
"WebGLRenderingContext",
"WebGLShader",
"WebGLShaderPrecisionFormat",
"WebGLTexture",
"WebGLUniformLocation",
"WebGLVertexArray",
"WebSocket",
"WheelEvent",
"Window",
"WindowUtils",
"XMLDocument",
"XMLHttpRequest",
"XMLHttpRequestUpload",
"XMLSerializer",
"XMLStylesheetProcessingInstruction",
"XPathEvaluator",
"XPathExpression",
"XPathNamespace",
"XPathNSResolver",
"XPathResult",
"XSLTProcessor",
{name: "XULButtonElement", xbl: true},
{name: "XULCheckboxElement", xbl: true},
{name: "XULCommandDispatcher", xbl: true},
{name: "XULCommandEvent", xbl: true},
{name: "XULControlElement", xbl: true},
{name: "XULControllers", xbl: true},
{name: "XULDocument", xbl: true},
{name: "XULElement", xbl: true},
{name: "XULLabeledControlElement", xbl: true},
{name: "XULPopupElement", xbl: true},
{name: "XULTemplateBuilder", xbl: true},
{name: "XULTreeBuilder", xbl: true},
]
// IMPORTANT: Do not change this list without review from a DOM peer!
function createInterfaceMap(isXBLScope) {
var version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
var isNightly = version.endsWith("a1");
var isRelease = !version.contains("a");
var isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
var isB2G = !isDesktop && !navigator.userAgent.contains("Android");
var interfaceMap = {};
for (var entry of ecmaGlobals) {
if (typeof(entry) === "string") {
// Standard ECMAScript global objects are not defined on the XBL scope.
interfaceMap[entry] = !isXBLScope;
} else if (entry.nightly === isNightly) {
interfaceMap[entry.name] = !isXBLScope;
} else {
interfaceMap[entry.name] = false;
}
}
for (var entry of interfaceNamesInGlobalScope) {
if (typeof(entry) === "string") {
interfaceMap[entry] = true;
} else if (entry.xbl === !isXBLScope ||
entry.desktop === !isDesktop ||
entry.b2g === !isB2G ||
entry.release === !isRelease) {
interfaceMap[entry.name] = false;
} else {
interfaceMap[entry.name] = true;
}
}
return interfaceMap;
}
function runTest(isXBLScope) {
var interfaceMap = createInterfaceMap(isXBLScope);
for (var name of Object.getOwnPropertyNames(window)) {
// An interfae name should start with an upper case character.
if (!/^(moz)?[A-Z]/.test(name)) {
continue;
}
ok(interfaceMap[name],
"If this is failing: DANGER, are you sure you want to expose the new interface " + name +
" to all webpages as a property on the window? Do not make a change to this file without a " +
" review from a DOM peer for that specific change!!! (or a JS peer for changes to ecmaGlobals)");
delete interfaceMap[name];
}
for (var name of Object.keys(interfaceMap)) {
ok(name in window === interfaceMap[name],
name + " should " + (interfaceMap[name] ? "" : " NOT") + " be defined on the " + (isXBLScope ? "XBL" : "global") +" scope");
if (!interfaceMap[name]) {
delete interfaceMap[name];
}
}
if (isXBLScope) {
todo_is(Object.keys(interfaceMap).length, 0,
"The following interface(s) are not enumerated: " + Object.keys(interfaceMap).join(", "));
} else {
is(Object.keys(interfaceMap).length, 0,
"The following interface(s) are not enumerated: " + Object.keys(interfaceMap).join(", "));
}
}
runTest(false);
SimpleTest.waitForExplicitFinish();
</script>
<span id="span" style="-moz-binding: url(file_interfaces.xml)"></span>
</pre>
</body>
</html>