Index: third_party/WebKit/LayoutTests/resources/global-interface-listing.js |
diff --git a/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js b/third_party/WebKit/LayoutTests/resources/global-interface-listing.js |
similarity index 74% |
rename from third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
rename to third_party/WebKit/LayoutTests/resources/global-interface-listing.js |
index 0c4f35c8ae5a633b99550b002d19e5c86382e8d5..1fd3136d47535671b168192c02c3695c71dcb16e 100644 |
--- a/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
+++ b/third_party/WebKit/LayoutTests/resources/global-interface-listing.js |
@@ -1,34 +1,9 @@ |
-// Run all the code in a local scope. |
-(function(globalObject) { |
+// * |globalObject| should be the global (usually |this|). |
+// * |propertyNamesInGlobal| should be a list of properties captured before |
+// other scripts are loaded, using: Object.getOwnPropertyNames(this); |
+// * |outputFunc| is called back with each line of output. |
-// Save the list of property names of the global object before loading other scripts. |
-var propertyNamesInGlobal = globalObject.propertyNamesInGlobal || Object.getOwnPropertyNames(globalObject); |
- |
-if (self.importScripts) { |
- importScripts('../../resources/js-test.js'); |
- |
- if (!self.postMessage) { |
- // Shared worker. Make postMessage send to the newest client, which in |
- // our tests is the only client. |
- |
- // Store messages for sending until we have somewhere to send them. |
- self.postMessage = function(message) { |
- if (typeof self.pendingMessages === "undefined") |
- self.pendingMessages = []; |
- self.pendingMessages.push(message); |
- }; |
- self.onconnect = function(event) { |
- self.postMessage = function(message) { |
- event.ports[0].postMessage(message); |
- }; |
- // Offload any stored messages now that someone has connected to us. |
- if (typeof self.pendingMessages === "undefined") |
- return; |
- while (self.pendingMessages.length) |
- event.ports[0].postMessage(self.pendingMessages.shift()); |
- }; |
- } |
-} |
+function globalInterfaceListing(globalObject, propertyNamesInGlobal, outputFunc) { |
// List of builtin JS constructors; Blink is not controlling what properties these |
// objects have, so exercising them in a Blink test doesn't make sense. |
@@ -142,7 +117,7 @@ function collectPropertyKeys(object) { |
Object.keys(object.__proto__), |
ownEnumerableSymbols(object.prototype), |
ownEnumerableSymbols(object.__proto__))); |
- return propertyKeys = Object.keys(object). |
+ return Object.keys(object). |
concat(ownEnumerableSymbols(object)). |
filter(function(name) { |
return !protoProperties.has(name); |
@@ -152,15 +127,15 @@ function collectPropertyKeys(object) { |
} |
// FIXME: List interfaces with NoInterfaceObject specified in their IDL file. |
-debug('[INTERFACES]'); |
+outputFunc('[INTERFACES]'); |
var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor); |
interfaceNames.sort(); |
interfaceNames.forEach(function(interfaceName) { |
var inheritsFrom = this[interfaceName].__proto__.name; |
if (inheritsFrom) |
- debug('interface ' + interfaceName + ' : ' + inheritsFrom); |
+ outputFunc('interface ' + interfaceName + ' : ' + inheritsFrom); |
else |
- debug('interface ' + interfaceName); |
+ outputFunc('interface ' + interfaceName); |
// List static properties then prototype properties. |
[this[interfaceName], this[interfaceName].prototype].forEach(function(object) { |
var propertyKeys = collectPropertyKeys(object); |
@@ -168,11 +143,11 @@ interfaceNames.forEach(function(interfaceName) { |
propertyKeys.forEach(function(propertyKey) { |
collectPropertyInfo(object, propertyKey, propertyStrings); |
}); |
- propertyStrings.sort().forEach(debug); |
+ propertyStrings.sort().forEach(outputFunc); |
}); |
}); |
-debug('[GLOBAL OBJECT]'); |
+outputFunc('[GLOBAL OBJECT]'); |
var propertyStrings = []; |
var memberNames = propertyNamesInGlobal.filter(function(propertyKey) { |
return !jsBuiltins.has(propertyKey) && !isWebIDLConstructor(propertyKey); |
@@ -180,9 +155,6 @@ var memberNames = propertyNamesInGlobal.filter(function(propertyKey) { |
memberNames.forEach(function(propertyKey) { |
collectPropertyInfo(globalObject, propertyKey, propertyStrings); |
}); |
-propertyStrings.sort().forEach(debug); |
- |
-if (isWorker()) |
- finishJSTest(); |
+propertyStrings.sort().forEach(outputFunc); |
-})(this); // Run all the code in a local scope. |
+} |