aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-07-07 16:18:57 +0200
committerMs2ger <Ms2ger@gmail.com>2016-07-07 16:20:43 +0200
commitb17ff481fed752905afa8f8aaa2a129b246f9a79 (patch)
tree9c0ef0191a79489bfc7d9a1a605f212e2914eaec
parent4fafcb121f807c31593bd2f8731358c68b3b7810 (diff)
downloadservo-b17ff481fed752905afa8f8aaa2a129b246f9a79.tar.gz
servo-b17ff481fed752905afa8f8aaa2a129b246f9a79.zip
Add a test for interfaces exposed in web workers.
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json6
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.html97
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.js87
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.worker.js185
4 files changed, 282 insertions, 93 deletions
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 32d55768235..de6186327f9 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -6576,6 +6576,12 @@
"url": "/_mozilla/mozilla/interfaces.html"
}
],
+ "mozilla/interfaces.worker.js": [
+ {
+ "path": "mozilla/interfaces.worker.js",
+ "url": "/_mozilla/mozilla/interfaces.worker"
+ }
+ ],
"mozilla/lenient_this.html": [
{
"path": "mozilla/lenient_this.html",
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html
index ac5d564bef8..9ccdbe882ec 100644
--- a/tests/wpt/mozilla/tests/mozilla/interfaces.html
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html
@@ -3,64 +3,14 @@
<title>Interfaces exposed on the window</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
+<script src="interfaces.js"></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
// 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!
-var interfaceNamesInGlobalScope = [
+test_interfaces([
"Attr",
"BeforeUnloadEvent",
"Blob",
@@ -234,44 +184,5 @@ var interfaceNamesInGlobalScope = [
"XMLHttpRequest",
"XMLHttpRequestEventTarget",
"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>
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.js b/tests/wpt/mozilla/tests/mozilla/interfaces.js
new file mode 100644
index 00000000000..4e1ecf8b918
--- /dev/null
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.js
@@ -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(", "));
+ });
+}
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
new file mode 100644
index 00000000000..47c9e6a6052
--- /dev/null
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
@@ -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();