Commit 5e52fddf authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Improve global listing tests

Improves global listing tests to show IDL namespaces.

Change-Id: Idaf760eba8dc40728427e7865c7d075cadc87fbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494449Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820681}
parent e9e022ce
...@@ -3921,6 +3921,7 @@ interface WritableStreamDefaultWriter ...@@ -3921,6 +3921,7 @@ interface WritableStreamDefaultWriter
method constructor method constructor
method releaseLock method releaseLock
method write method write
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
attribute console attribute console
attribute globalThis attribute globalThis
......
...@@ -6,6 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -6,6 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
interface Navigator interface Navigator
interface Notification : EventTarget interface Notification : EventTarget
getter image getter image
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -80,6 +80,7 @@ interface BluetoothUUID ...@@ -80,6 +80,7 @@ interface BluetoothUUID
interface Navigator interface Navigator
getter bluetooth getter bluetooth
interface Notification : EventTarget interface Notification : EventTarget
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -81,6 +81,7 @@ interface Navigator ...@@ -81,6 +81,7 @@ interface Navigator
getter bluetooth getter bluetooth
interface Notification : EventTarget interface Notification : EventTarget
getter image getter image
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -6,6 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -6,6 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
interface Navigator interface Navigator
interface Notification : EventTarget interface Notification : EventTarget
getter image getter image
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -77,7 +77,7 @@ var jsBuiltins = new Set([ ...@@ -77,7 +77,7 @@ var jsBuiltins = new Set([
'unescape', 'unescape',
]); ]);
function isWebIDLConstructor(propertyKey) { function isWebIDLInterface(propertyKey) {
if (jsBuiltins.has(propertyKey)) if (jsBuiltins.has(propertyKey))
return false; return false;
var descriptor = Object.getOwnPropertyDescriptor(this, propertyKey); var descriptor = Object.getOwnPropertyDescriptor(this, propertyKey);
...@@ -86,6 +86,18 @@ function isWebIDLConstructor(propertyKey) { ...@@ -86,6 +86,18 @@ function isWebIDLConstructor(propertyKey) {
return descriptor.writable && !descriptor.enumerable && descriptor.configurable; return descriptor.writable && !descriptor.enumerable && descriptor.configurable;
} }
function isWebIDLNamespace(propertyKey) {
if (jsBuiltins.has(propertyKey))
return false;
let object = Object.getOwnPropertyDescriptor(this, propertyKey).value;
if (object == undefined || typeof(object) != 'object' ||
object.prototype != undefined) {
return false;
}
let classString = Object.getOwnPropertyDescriptor(object, Symbol.toStringTag);
return classString && classString.value == propertyKey;
}
var wellKnownSymbols = new Map([ var wellKnownSymbols = new Map([
[Symbol.asyncIterator, "@@asyncIterator"], [Symbol.asyncIterator, "@@asyncIterator"],
[Symbol.hasInstance, "@@hasInstance"], [Symbol.hasInstance, "@@hasInstance"],
...@@ -192,13 +204,7 @@ function outputProperty(property) { ...@@ -192,13 +204,7 @@ function outputProperty(property) {
outputFunc(' ' + property); outputFunc(' ' + property);
} }
// FIXME: List interfaces with LegacyNoInterfaceObject specified in their IDL file. function outputWebIDLInterface(interfaceName) {
outputFunc('[INTERFACES]');
var interfaceNames = Object.getOwnPropertyNames(this)
.filter(isWebIDLConstructor)
.filter(filterPlatformSpecificInterface);
interfaceNames.sort();
interfaceNames.forEach(function(interfaceName) {
var inheritsFrom = this[interfaceName].__proto__.name; var inheritsFrom = this[interfaceName].__proto__.name;
if (inheritsFrom) if (inheritsFrom)
outputFunc('interface ' + interfaceName + ' : ' + inheritsFrom); outputFunc('interface ' + interfaceName + ' : ' + inheritsFrom);
...@@ -215,12 +221,40 @@ interfaceNames.forEach(function(interfaceName) { ...@@ -215,12 +221,40 @@ interfaceNames.forEach(function(interfaceName) {
propertyStrings.filter((property) => filterPlatformSpecificProperty(interfaceName, property)) propertyStrings.filter((property) => filterPlatformSpecificProperty(interfaceName, property))
.sort().forEach(outputProperty); .sort().forEach(outputProperty);
}); });
}); }
function outputWebIDLNamespace(namespaceName) {
outputFunc('namespace ' + namespaceName);
let object = this[namespaceName];
let propertyKeys = collectPropertyKeys(object);
let propertyStrings = [];
propertyKeys.forEach((propertyKey) => {
collectPropertyInfo(object, propertyKey, propertyStrings);
});
propertyStrings.sort().forEach(outputProperty);
}
outputFunc('[INTERFACES]');
var interfaceNames = Object.getOwnPropertyNames(this)
.filter(isWebIDLInterface)
.filter(filterPlatformSpecificInterface);
interfaceNames.sort();
interfaceNames.forEach(outputWebIDLInterface);
outputFunc('[NAMESPACES]');
let namespaceNames = Object.getOwnPropertyNames(this)
.filter(isWebIDLNamespace)
.filter(filterPlatformSpecificInterface);
namespaceNames.sort();
namespaceNames.forEach(outputWebIDLNamespace);
outputFunc('[GLOBAL OBJECT]'); outputFunc('[GLOBAL OBJECT]');
var propertyStrings = []; var propertyStrings = [];
var memberNames = propertyNamesInGlobal.filter(function(propertyKey) { var memberNames = propertyNamesInGlobal.filter(function(propertyKey) {
return !jsBuiltins.has(propertyKey) && !isWebIDLConstructor(propertyKey); return !jsBuiltins.has(propertyKey)
&& !isWebIDLInterface(propertyKey)
&& !isWebIDLNamespace(propertyKey);
}); });
memberNames.forEach(function(propertyKey) { memberNames.forEach(function(propertyKey) {
collectPropertyInfo(globalObject, propertyKey, propertyStrings); collectPropertyInfo(globalObject, propertyKey, propertyStrings);
......
...@@ -2749,6 +2749,7 @@ interface WritableStreamDefaultWriter ...@@ -2749,6 +2749,7 @@ interface WritableStreamDefaultWriter
method constructor method constructor
method releaseLock method releaseLock
method write method write
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
attribute console attribute console
attribute globalThis attribute globalThis
......
...@@ -2794,6 +2794,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -2794,6 +2794,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget [Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] [NAMESPACES]
[Worker] [GLOBAL OBJECT] [Worker] [GLOBAL OBJECT]
[Worker] attribute console [Worker] attribute console
[Worker] attribute globalThis [Worker] attribute globalThis
......
...@@ -9558,6 +9558,7 @@ interface webkitURL ...@@ -9558,6 +9558,7 @@ interface webkitURL
setter protocol setter protocol
setter search setter search
setter username setter username
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
attribute GCController attribute GCController
attribute accessibilityController attribute accessibilityController
......
...@@ -2681,6 +2681,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -2681,6 +2681,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget [Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] [NAMESPACES]
[Worker] [GLOBAL OBJECT] [Worker] [GLOBAL OBJECT]
[Worker] attribute console [Worker] attribute console
[Worker] attribute globalThis [Worker] attribute globalThis
......
...@@ -4071,6 +4071,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -4071,6 +4071,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget [Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] [NAMESPACES]
[Worker] [GLOBAL OBJECT] [Worker] [GLOBAL OBJECT]
[Worker] attribute console [Worker] attribute console
[Worker] attribute globalThis [Worker] attribute globalThis
......
...@@ -11752,6 +11752,7 @@ interface webkitURL ...@@ -11752,6 +11752,7 @@ interface webkitURL
setter protocol setter protocol
setter search setter search
setter username setter username
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
attribute GCController attribute GCController
attribute accessibilityController attribute accessibilityController
......
...@@ -89,6 +89,7 @@ interface Navigator ...@@ -89,6 +89,7 @@ interface Navigator
getter bluetooth getter bluetooth
interface Notification : EventTarget interface Notification : EventTarget
getter image getter image
[NAMESPACES]
[GLOBAL OBJECT] [GLOBAL OBJECT]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -3842,6 +3842,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -3842,6 +3842,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget [Worker] interface XMLHttpRequestUpload : XMLHttpRequestEventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] [NAMESPACES]
[Worker] [GLOBAL OBJECT] [Worker] [GLOBAL OBJECT]
[Worker] attribute console [Worker] attribute console
[Worker] attribute globalThis [Worker] attribute globalThis
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment