mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add a test for interfaces exposed in web workers.
This commit is contained in:
parent
4fafcb121f
commit
b17ff481fe
4 changed files with 282 additions and 93 deletions
|
@ -6576,6 +6576,12 @@
|
||||||
"url": "/_mozilla/mozilla/interfaces.html"
|
"url": "/_mozilla/mozilla/interfaces.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/interfaces.worker.js": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/interfaces.worker.js",
|
||||||
|
"url": "/_mozilla/mozilla/interfaces.worker"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/lenient_this.html": [
|
"mozilla/lenient_this.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/lenient_this.html",
|
"path": "mozilla/lenient_this.html",
|
||||||
|
|
|
@ -3,64 +3,14 @@
|
||||||
<title>Interfaces exposed on the window</title>
|
<title>Interfaces exposed on the window</title>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="interfaces.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// This is a list of all interfaces that are exposed to every webpage.
|
// This is a list of interfaces that are exposed to every webpage.
|
||||||
// Please only add things to this list with great care and proper review
|
// Please only add things to this list with great care and proper review
|
||||||
// from the associated module peers.
|
// from the associated module peers.
|
||||||
|
|
||||||
// IMPORTANT: Do not change this list without review from
|
|
||||||
// a JavaScript Engine peer!
|
|
||||||
var ecmaGlobals = [
|
|
||||||
"Array",
|
|
||||||
"ArrayBuffer",
|
|
||||||
"Atomics",
|
|
||||||
"Boolean",
|
|
||||||
"Crypto",
|
|
||||||
"DataView",
|
|
||||||
"Date",
|
|
||||||
"Error",
|
|
||||||
"EvalError",
|
|
||||||
"Float32Array",
|
|
||||||
"Float64Array",
|
|
||||||
"Function",
|
|
||||||
"Infinity",
|
|
||||||
"Int16Array",
|
|
||||||
"Int32Array",
|
|
||||||
"Int8Array",
|
|
||||||
"InternalError",
|
|
||||||
"Iterator",
|
|
||||||
"JSON",
|
|
||||||
"Map",
|
|
||||||
"Math",
|
|
||||||
"NaN",
|
|
||||||
"Number",
|
|
||||||
"Object",
|
|
||||||
"Proxy",
|
|
||||||
"RangeError",
|
|
||||||
"ReferenceError",
|
|
||||||
"Reflect",
|
|
||||||
"RegExp",
|
|
||||||
"SIMD",
|
|
||||||
"Set",
|
|
||||||
"SharedArrayBuffer",
|
|
||||||
"StopIteration",
|
|
||||||
"String",
|
|
||||||
"Symbol",
|
|
||||||
"SyntaxError",
|
|
||||||
"TypeError",
|
|
||||||
"TypedObject",
|
|
||||||
"URIError",
|
|
||||||
"Uint16Array",
|
|
||||||
"Uint32Array",
|
|
||||||
"Uint8Array",
|
|
||||||
"Uint8ClampedArray",
|
|
||||||
"Uint8ClampedArray",
|
|
||||||
"WeakMap",
|
|
||||||
"WeakSet",
|
|
||||||
];
|
|
||||||
|
|
||||||
// IMPORTANT: Do not change the list below without review from a DOM peer!
|
// IMPORTANT: Do not change the list below without review from a DOM peer!
|
||||||
var interfaceNamesInGlobalScope = [
|
test_interfaces([
|
||||||
"Attr",
|
"Attr",
|
||||||
"BeforeUnloadEvent",
|
"BeforeUnloadEvent",
|
||||||
"Blob",
|
"Blob",
|
||||||
|
@ -234,44 +184,5 @@ var interfaceNamesInGlobalScope = [
|
||||||
"XMLHttpRequest",
|
"XMLHttpRequest",
|
||||||
"XMLHttpRequestEventTarget",
|
"XMLHttpRequestEventTarget",
|
||||||
"XMLHttpRequestUpload",
|
"XMLHttpRequestUpload",
|
||||||
];
|
]);
|
||||||
|
|
||||||
function createInterfaceMap() {
|
|
||||||
var interfaceMap = {};
|
|
||||||
|
|
||||||
function addInterfaces(interfaces)
|
|
||||||
{
|
|
||||||
for (var entry of interfaces) {
|
|
||||||
interfaceMap[entry] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addInterfaces(ecmaGlobals);
|
|
||||||
addInterfaces(interfaceNamesInGlobalScope);
|
|
||||||
addInterfaces(["EventWatcher"]);
|
|
||||||
return interfaceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
test(function() {
|
|
||||||
var interfaceMap = createInterfaceMap();
|
|
||||||
for (var name of Object.getOwnPropertyNames(window)) {
|
|
||||||
if (!/^[A-Z]/.test(name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
assert_true(name in interfaceMap,
|
|
||||||
"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 review from jdm or Ms2ger " +
|
|
||||||
"for that specific change!");
|
|
||||||
if (name in interfaceMap) {
|
|
||||||
delete interfaceMap[name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var name of Object.keys(interfaceMap)) {
|
|
||||||
assert_true(name in window, name + " should be defined on the global scope");
|
|
||||||
}
|
|
||||||
assert_equals(Object.keys(interfaceMap).length, 0,
|
|
||||||
"The following interface(s) are not enumerated: " +
|
|
||||||
Object.keys(interfaceMap).join(", "));
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
87
tests/wpt/mozilla/tests/mozilla/interfaces.js
Normal file
87
tests/wpt/mozilla/tests/mozilla/interfaces.js
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
function test_interfaces(interfaceNamesInGlobalScope) {
|
||||||
|
test(function() {
|
||||||
|
// This is a list of interfaces that are exposed to every webpage by SpiderMonkey.
|
||||||
|
// IMPORTANT: Do not change this list without review from a JavaScript Engine peer!
|
||||||
|
var ecmaGlobals = [
|
||||||
|
"Array",
|
||||||
|
"ArrayBuffer",
|
||||||
|
"Atomics",
|
||||||
|
"Boolean",
|
||||||
|
"Crypto",
|
||||||
|
"DataView",
|
||||||
|
"Date",
|
||||||
|
"Error",
|
||||||
|
"EvalError",
|
||||||
|
"Float32Array",
|
||||||
|
"Float64Array",
|
||||||
|
"Function",
|
||||||
|
"Infinity",
|
||||||
|
"Int16Array",
|
||||||
|
"Int32Array",
|
||||||
|
"Int8Array",
|
||||||
|
"InternalError",
|
||||||
|
"Iterator",
|
||||||
|
"JSON",
|
||||||
|
"Map",
|
||||||
|
"Math",
|
||||||
|
"NaN",
|
||||||
|
"Number",
|
||||||
|
"Object",
|
||||||
|
"Proxy",
|
||||||
|
"RangeError",
|
||||||
|
"ReferenceError",
|
||||||
|
"Reflect",
|
||||||
|
"RegExp",
|
||||||
|
"SIMD",
|
||||||
|
"Set",
|
||||||
|
"SharedArrayBuffer",
|
||||||
|
"StopIteration",
|
||||||
|
"String",
|
||||||
|
"Symbol",
|
||||||
|
"SyntaxError",
|
||||||
|
"TypeError",
|
||||||
|
"TypedObject",
|
||||||
|
"URIError",
|
||||||
|
"Uint16Array",
|
||||||
|
"Uint32Array",
|
||||||
|
"Uint8Array",
|
||||||
|
"Uint8ClampedArray",
|
||||||
|
"Uint8ClampedArray",
|
||||||
|
"WeakMap",
|
||||||
|
"WeakSet",
|
||||||
|
];
|
||||||
|
|
||||||
|
var sources = [
|
||||||
|
ecmaGlobals,
|
||||||
|
interfaceNamesInGlobalScope,
|
||||||
|
["EventWatcher"],
|
||||||
|
];
|
||||||
|
|
||||||
|
var interfaceMap = {};
|
||||||
|
for (var source of sources) {
|
||||||
|
for (var entry of source) {
|
||||||
|
interfaceMap[entry] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var name of Object.getOwnPropertyNames(self)) {
|
||||||
|
if (!/^[A-Z]/.test(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert_true(name in interfaceMap,
|
||||||
|
"If this is failing: DANGER, are you sure you want to expose the new " +
|
||||||
|
"interface " + name + " to all webpages as a property on the global? " +
|
||||||
|
"Do not make a change to this file without review from jdm or Ms2ger " +
|
||||||
|
"for that specific change!");
|
||||||
|
if (name in interfaceMap) {
|
||||||
|
delete interfaceMap[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var name of Object.keys(interfaceMap)) {
|
||||||
|
assert_true(name in self, name + " should be defined on the global scope");
|
||||||
|
}
|
||||||
|
assert_equals(Object.keys(interfaceMap).length, 0,
|
||||||
|
"The following interface(s) are not enumerated: " +
|
||||||
|
Object.keys(interfaceMap).join(", "));
|
||||||
|
});
|
||||||
|
}
|
185
tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
Normal file
185
tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
importScripts("/resources/testharness.js");
|
||||||
|
importScripts("interfaces.js");
|
||||||
|
|
||||||
|
// This is a list of interfaces that are exposed to every web worker.
|
||||||
|
// Please only add things to this list with great care and proper review
|
||||||
|
// from the associated module peers.
|
||||||
|
|
||||||
|
// IMPORTANT: Do not change the list below without review from a DOM peer!
|
||||||
|
test_interfaces([
|
||||||
|
"Attr",
|
||||||
|
"BeforeUnloadEvent",
|
||||||
|
"Blob",
|
||||||
|
"CanvasGradient",
|
||||||
|
"CanvasRenderingContext2D",
|
||||||
|
"CanvasPattern",
|
||||||
|
"CharacterData",
|
||||||
|
"CloseEvent",
|
||||||
|
"CSS",
|
||||||
|
"CSSStyleDeclaration",
|
||||||
|
"DOMPoint",
|
||||||
|
"DOMPointReadOnly",
|
||||||
|
"DOMQuad",
|
||||||
|
"DOMRect",
|
||||||
|
"DOMRectReadOnly",
|
||||||
|
"Comment",
|
||||||
|
"Console",
|
||||||
|
"CustomEvent",
|
||||||
|
"DedicatedWorkerGlobalScope",
|
||||||
|
"Document",
|
||||||
|
"DocumentFragment",
|
||||||
|
"DocumentType",
|
||||||
|
"DOMException",
|
||||||
|
"DOMImplementation",
|
||||||
|
"DOMParser",
|
||||||
|
"DOMTokenList",
|
||||||
|
"DOMStringMap",
|
||||||
|
"Element",
|
||||||
|
"ErrorEvent",
|
||||||
|
"Event",
|
||||||
|
"EventSource",
|
||||||
|
"EventTarget",
|
||||||
|
"File",
|
||||||
|
"FileList",
|
||||||
|
"FileReader",
|
||||||
|
"FocusEvent",
|
||||||
|
"FormData",
|
||||||
|
"HashChangeEvent",
|
||||||
|
"HTMLAnchorElement",
|
||||||
|
"HTMLAppletElement",
|
||||||
|
"HTMLAreaElement",
|
||||||
|
"HTMLAudioElement",
|
||||||
|
"HTMLBaseElement",
|
||||||
|
"HTMLBodyElement",
|
||||||
|
"HTMLBRElement",
|
||||||
|
"HTMLButtonElement",
|
||||||
|
"HTMLCanvasElement",
|
||||||
|
"HTMLCollection",
|
||||||
|
"HTMLDataElement",
|
||||||
|
"HTMLDataListElement",
|
||||||
|
"HTMLDetailsElement",
|
||||||
|
"HTMLDialogElement",
|
||||||
|
"HTMLDirectoryElement",
|
||||||
|
"HTMLDivElement",
|
||||||
|
"HTMLDListElement",
|
||||||
|
"HTMLElement",
|
||||||
|
"HTMLEmbedElement",
|
||||||
|
"HTMLFieldSetElement",
|
||||||
|
"HTMLFontElement",
|
||||||
|
"HTMLFormControlsCollection",
|
||||||
|
"HTMLFormElement",
|
||||||
|
"HTMLFrameElement",
|
||||||
|
"HTMLFrameSetElement",
|
||||||
|
"HTMLHeadElement",
|
||||||
|
"HTMLHeadingElement",
|
||||||
|
"HTMLHRElement",
|
||||||
|
"HTMLHtmlElement",
|
||||||
|
"HTMLIFrameElement",
|
||||||
|
"HTMLImageElement",
|
||||||
|
"HTMLInputElement",
|
||||||
|
"HTMLLabelElement",
|
||||||
|
"HTMLLegendElement",
|
||||||
|
"HTMLLIElement",
|
||||||
|
"HTMLLinkElement",
|
||||||
|
"HTMLMapElement",
|
||||||
|
"HTMLMediaElement",
|
||||||
|
"HTMLMetaElement",
|
||||||
|
"HTMLMeterElement",
|
||||||
|
"HTMLModElement",
|
||||||
|
"HTMLObjectElement",
|
||||||
|
"HTMLOListElement",
|
||||||
|
"HTMLOptGroupElement",
|
||||||
|
"HTMLOptionElement",
|
||||||
|
"HTMLOutputElement",
|
||||||
|
"HTMLParagraphElement",
|
||||||
|
"HTMLParamElement",
|
||||||
|
"HTMLPreElement",
|
||||||
|
"HTMLProgressElement",
|
||||||
|
"HTMLQuoteElement",
|
||||||
|
"HTMLScriptElement",
|
||||||
|
"HTMLSelectElement",
|
||||||
|
"HTMLSourceElement",
|
||||||
|
"HTMLSpanElement",
|
||||||
|
"HTMLStyleElement",
|
||||||
|
"HTMLTableCaptionElement",
|
||||||
|
"HTMLTableCellElement",
|
||||||
|
"HTMLTableColElement",
|
||||||
|
"HTMLTableDataCellElement",
|
||||||
|
"HTMLTableElement",
|
||||||
|
"HTMLTableHeaderCellElement",
|
||||||
|
"HTMLTableRowElement",
|
||||||
|
"HTMLTableSectionElement",
|
||||||
|
"HTMLTemplateElement",
|
||||||
|
"HTMLTextAreaElement",
|
||||||
|
"HTMLTimeElement",
|
||||||
|
"HTMLTitleElement",
|
||||||
|
"HTMLTrackElement",
|
||||||
|
"HTMLUListElement",
|
||||||
|
"HTMLUnknownElement",
|
||||||
|
"HTMLVideoElement",
|
||||||
|
"ImageData",
|
||||||
|
"Image",
|
||||||
|
"KeyboardEvent",
|
||||||
|
"Location",
|
||||||
|
"MediaError",
|
||||||
|
"MessageEvent",
|
||||||
|
"MimeType",
|
||||||
|
"MimeTypeArray",
|
||||||
|
"MouseEvent",
|
||||||
|
"NamedNodeMap",
|
||||||
|
"Navigator",
|
||||||
|
"Node",
|
||||||
|
"NodeFilter",
|
||||||
|
"NodeIterator",
|
||||||
|
"NodeList",
|
||||||
|
"PageTransitionEvent",
|
||||||
|
"Performance",
|
||||||
|
"PerformanceTiming",
|
||||||
|
"Plugin",
|
||||||
|
"PluginArray",
|
||||||
|
"PopStateEvent",
|
||||||
|
"ProcessingInstruction",
|
||||||
|
"ProgressEvent",
|
||||||
|
"RadioNodeList",
|
||||||
|
"Range",
|
||||||
|
"Screen",
|
||||||
|
"Storage",
|
||||||
|
"StorageEvent",
|
||||||
|
"StyleSheet",
|
||||||
|
"StyleSheetList",
|
||||||
|
"Text",
|
||||||
|
"TextDecoder",
|
||||||
|
"TextEncoder",
|
||||||
|
"Touch",
|
||||||
|
"TouchEvent",
|
||||||
|
"TouchList",
|
||||||
|
"TreeWalker",
|
||||||
|
"UIEvent",
|
||||||
|
"URL",
|
||||||
|
"URLSearchParams",
|
||||||
|
"ValidityState",
|
||||||
|
"WebGLRenderingContext",
|
||||||
|
"WebGLUniformLocation",
|
||||||
|
"WebGLBuffer",
|
||||||
|
"WebGLContextEvent",
|
||||||
|
"WebGLFramebuffer",
|
||||||
|
"WebGLRenderbuffer",
|
||||||
|
"WebGLTexture",
|
||||||
|
"WebGLProgram",
|
||||||
|
"WebGLShader",
|
||||||
|
"WebGLObject",
|
||||||
|
"WebGLActiveInfo",
|
||||||
|
"WebGLShaderPrecisionFormat",
|
||||||
|
"WebSocket",
|
||||||
|
"Window",
|
||||||
|
"Worker",
|
||||||
|
"WorkerGlobalScope",
|
||||||
|
"WorkerLocation",
|
||||||
|
"WorkerNavigator",
|
||||||
|
"XMLDocument",
|
||||||
|
"XMLHttpRequest",
|
||||||
|
"XMLHttpRequestEventTarget",
|
||||||
|
"XMLHttpRequestUpload",
|
||||||
|
]);
|
||||||
|
|
||||||
|
done();
|
Loading…
Add table
Add a link
Reference in a new issue