haikuwebkit/LayoutTests/inspector/runtime/getDisplayableProperties.html

151 lines
4.9 KiB
HTML
Raw Permalink Normal View History

Web Inspector: Better handling for large arrays and collections in Object Trees https://bugs.webkit.org/show_bug.cgi?id=143589 <rdar://problem/16135388> Reviewed by Joseph Pecoraro. Source/JavaScriptCore: Adds two buttons before the "Prototype" item in expanded object/collection previews: - Show %d More - Show All (%d More) The default `fetchCount` increment is `100`. The first button will only be shown if there are more than `100` items remaining (haven't been shown). * inspector/InjectedScriptSource.js: (InjectedScript.prototype.getProperties): (InjectedScript.prototype.getDisplayableProperties): (InjectedScript.prototype.getCollectionEntries): (InjectedScript.prototype._getProperties): (InjectedScript.prototype._internalPropertyDescriptors): (InjectedScript.prototype._propertyDescriptors): (InjectedScript.prototype._propertyDescriptors.createFakeValueDescriptor): (InjectedScript.prototype._propertyDescriptors.processProperties): (InjectedScript.prototype._getSetEntries): (InjectedScript.prototype._getMapEntries): (InjectedScript.prototype._getWeakMapEntries): (InjectedScript.prototype._getWeakSetEntries): (InjectedScript.prototype._getIteratorEntries): (InjectedScript.prototype._entries): (RemoteObject.prototype._generatePreview): (InjectedScript.prototype._propertyDescriptors.arrayIndexPropertyNames): Deleted. Don't include boolean property descriptor values if they are `false. * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::weakMapEntries): (Inspector::JSInjectedScriptHost::weakSetEntries): * inspector/InjectedScript.h: * inspector/InjectedScript.cpp: (Inspector::InjectedScript::getProperties): (Inspector::InjectedScript::getDisplayableProperties): (Inspector::InjectedScript::getCollectionEntries): * inspector/agents/InspectorRuntimeAgent.h: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::asInt): Added. (Inspector::InspectorRuntimeAgent::getProperties): (Inspector::InspectorRuntimeAgent::getDisplayableProperties): (Inspector::InspectorRuntimeAgent::getCollectionEntries): * inspector/protocol/Runtime.json: Add `fetchStart`/`fetchCount` to `getProperties`/`getDisplayableProperties`/`getCollectionEntries`. Mark boolean properties as optional so they can be omitted if `false`. Source/WebInspectorUI: Adds two buttons before the "Prototype" item in expanded object/collection previews: - Show %d More - Show All (%d More) The default `fetchCount` increment is `100`. The first button will only be shown if there are more than `100` items remaining (haven't been shown). * UserInterface/Protocol/RemoteObject.js: (WI.RemoteObject.prototype.getPropertyDescriptors): (WI.RemoteObject.prototype.getDisplayablePropertyDescriptors): (WI.RemoteObject.prototype.getCollectionEntries): (WI.RemoteObject.prototype.getOwnPropertyDescriptor.wrappedCallback): (WI.RemoteObject.prototype._getProperties): Added. (WI.RemoteObject.prototype._getDisplayableProperties): Added. * UserInterface/Views/ObjectTreeView.js: (WI.ObjectTreeView): (WI.ObjectTreeView.showMoreFetchCount): Added. (WI.ObjectTreeView.addShowMoreIfNeeded): Added. (WI.ObjectTreeView.prototype.update): (WI.ObjectTreeView.prototype._updateChildren): (WI.ObjectTreeView.prototype._updateEntries): (WI.ObjectTreeView.prototype._updateProperties): * UserInterface/Views/ObjectTreeView.css: (.tree-outline.object li > button[disabled] + .indeterminate-progress-spinner): Added. Avoid duplicating the button creation logic in `WI.ObjectTreePropertyTreeElement` by using a `static` function. This expects the existence of and requires access to "private" values. * UserInterface/Views/ObjectTreePropertyTreeElement.js: (WI.ObjectTreePropertyTreeElement): (WI.ObjectTreePropertyTreeElement.prototype.onpopulate): (WI.ObjectTreePropertyTreeElement.prototype._updateChildren): (WI.ObjectTreePropertyTreeElement.prototype._updateEntries): (WI.ObjectTreePropertyTreeElement.prototype._updateProperties): (WI.ObjectTreePropertyTreeElement.prototype._updateChildrenInternal): Deleted. * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.evaluated): (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.receivedArrayPropertyNames): Deleted. * UserInterface/Controllers/RuntimeManager.js: (WI.RuntimeManager.prototype.getPropertiesForRemoteObject): Deleted. Remove unused function. * Localizations/en.lproj/localizedStrings.js: LayoutTests: * inspector/runtime/getCollectionEntries.html: Added. * inspector/runtime/getCollectionEntries-expected.txt: Added. * inspector/runtime/getDisplayableProperties.html: Added. * inspector/runtime/getDisplayableProperties-expected.txt: Added. * inspector/runtime/getProperties.html: * inspector/runtime/getProperties-expected.txt: * inspector/runtime/resources/property-descriptor-utilities.js: Added. (makeArray): (makeObject): (makeMap): (makeSet): (makeWeakMap): (makeWeakSet): (TestPage.registerInitializer.ProtocolTest.PropertyDescriptorUtilities.logForEach): (TestPage.registerInitializer.ProtocolTest.PropertyDescriptorUtilities.stringifyRemoteObject): * inspector/model/remote-object-weak-collection.html: Canonical link: https://commits.webkit.org/215604@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-19 05:58:27 +00:00
<html>
<head>
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script src="resources/property-descriptor-utilities.js"></script>
<script>
if (window.internals)
window.internals.settings.setUnhandledPromiseRejectionToConsoleEnabled(false);
function test()
{
let suite = ProtocolTest.createAsyncSuite("Runtime.getDisplayableProperties");
function addTestCase({name, expression, fetchStart, fetchCount}) {
suite.addTestCase({
name,
async test() {
ProtocolTest.log(`Evaluating expression...`);
let evaluateResponse = await InspectorProtocol.awaitCommand({
method: "Runtime.evaluate",
params: {expression},
});
ProtocolTest.assert(!evaluateResponse.wasThrown);
let log = "Getting displayable properties";
if (fetchStart)
log += ` with fetchStart ${fetchStart}`;
if (fetchCount)
log += ` with fetchCount ${fetchCount}`;
ProtocolTest.log(log + "...");
let getDisplayablePropertiesResponse = await InspectorProtocol.awaitCommand({
method: "Runtime.getDisplayableProperties",
params: {
objectId: evaluateResponse.result.objectId,
fetchStart,
fetchCount,
},
});
let properties = getDisplayablePropertiesResponse.properties;
if (properties) {
Web Inspector: REGRESSION(r250087): inspector/model/remote-object.html is timing out https://bugs.webkit.org/show_bug.cgi?id=202934 <rdar://problem/56270900> Reviewed by Timothy Hatcher. Source/JavaScriptCore: In r250087, the inspector injected script was changed so that remote objects actually iterate the keys of an array and generate a property descriptor for each. While this worked fine (and was performant) for fetching remote objects, this was not efficient when creating object previews, as that path wouldn't be limited by any sort of `fetchCount`, meaning that a descriptor for every index would be created even though only the first 10 would be used. Refactor the inspector injected script code so that both the fetch and preview paths only examine exactly the number of properties desired instead of considering all of them and then slicing to fit. * inspector/InjectedScriptSource.js: (InjectedScript.prototype._getProperties): (InjectedScript.prototype._forEachPropertyDescriptor): Added. (InjectedScript.prototype._forEachPropertyDescriptor.createFakeValueDescriptor): Added. (InjectedScript.prototype._forEachPropertyDescriptor.processDescriptor): Added. (InjectedScript.prototype._forEachPropertyDescriptor.processProperty): Added. (RemoteObject.prototype._generatePreview): (RemoteObject.prototype._appendPropertyPreview): Added. (RemoteObject.prototype._appendPropertyPreview.appendPreview): Added. (InjectedScript.prototype._propertyDescriptors): Deleted. (InjectedScript.prototype._propertyDescriptors.processProperties): Deleted. (InjectedScript.prototype._propertyDescriptors.arrayIndexPropertyNames): Deleted. (RemoteObject.prototype._appendPropertyPreviews): Deleted. Source/WebInspectorUI: * UserInterface/Views/ObjectTreeView.js: (WI.ObjectTreeView.addShowMoreIfNeeded): Drive-by: ensure that the indeterminate progress spinner is added after the last button. LayoutTests: Split inspector/model/remote-object.html into separate tests for each type of object being tested, as well as specialized tests for extremely large values. This allows us to better know which specific expression can cause a timeout. * inspector/model/remote-object.html: Removed. * inspector/model/remote-object-expected.txt: Removed. * platform/mac-wk1/inspector/model/remote-object-expected.txt: Removed. * inspector/model/remote-object/array.html: Added. * inspector/model/remote-object/array-expected.txt: Added. * inspector/model/remote-object/array-large.html: Added. * inspector/model/remote-object/array-large-expected.txt: Added. * inspector/model/remote-object/boolean.html: Added. * inspector/model/remote-object/boolean-expected.txt: Added. * inspector/model/remote-object/class.html: Added. * inspector/model/remote-object/class-expected.txt: Added. * inspector/model/remote-object/date.html: Added. * inspector/model/remote-object/date-expected.txt: Added. * inspector/model/remote-object/error.html: Added. * inspector/model/remote-object/error-expected.txt: Added. * inspector/model/remote-object/function.html: Added. * inspector/model/remote-object/function-expected.txt: Added. * inspector/model/remote-object/immutable.html: Added. * inspector/model/remote-object/immutable-expected.txt: Added. * inspector/model/remote-object/iterator.html: Added. * inspector/model/remote-object/iterator-expected.txt: Added. * inspector/model/remote-object/iterator-large.html: Added. * inspector/model/remote-object/iterator-large-expected.txt: Added. * inspector/model/remote-object/map.html: Added. * inspector/model/remote-object/map-expected.txt: Added. * inspector/model/remote-object/map-large.html: Added. * inspector/model/remote-object/map-large-expected.txt: Added. * inspector/model/remote-object/null.html: Added. * inspector/model/remote-object/null-expected.txt: Added. * inspector/model/remote-object/number.html: Added. * inspector/model/remote-object/number-expected.txt: Added. * platform/mac-wk1/inspector/number-expected.txt: Added. * inspector/model/remote-object/object.html: Added. * inspector/model/remote-object/object-expected.txt: Added. * inspector/model/remote-object/object-large.html: Added. * inspector/model/remote-object/object-large-expected.txt: Added. * inspector/model/remote-object/promise.html: Added. * inspector/model/remote-object/promise-expected.txt: Added. * inspector/model/remote-object/regexp.html: Added. * inspector/model/remote-object/regexp-expected.txt: Added. * inspector/model/remote-object/set.html: Added. * inspector/model/remote-object/set-expected.txt: Added. * inspector/model/remote-object/set-large.html: Added. * inspector/model/remote-object/set-large-expected.txt: Added. * inspector/model/remote-object/string.html: Added. * inspector/model/remote-object/string-expected.txt: Added. * inspector/model/remote-object/string-large.html: Added. * inspector/model/remote-object/string-large-expected.txt: Added. * inspector/model/remote-object/undefined.html: Added. * inspector/model/remote-object/undefined-expected.txt: Added. * inspector/model/remote-object/dom.html: Renamed from LayoutTests/inspector/model/remote-object-dom.html. * inspector/model/remote-object/dom-expected.txt: Renamed from LayoutTests/inspector/model/remote-object-dom-expected.txt. * inspector/model/remote-object/iterators-mutated.html: Renamed from LayoutTests/inspector/model/remote-object-mutated-iterators.html. * inspector/model/remote-object/iterators-mutated-expected.txt: Renamed from LayoutTests/inspector/model/remote-object-mutated-iterators-expected.txt. * inspector/model/remote-object/resources/remote-object-utilities.js: Renamed from LayoutTests/inspector/model/resources/remote-object-utilities.js. * inspector/runtime/getDisplayableProperties.html: * inspector/runtime/getDisplayableProperties-expected.txt: * inspector/runtime/getProperties.html: * inspector/runtime/getProperties-expected.txt: Drive-by: fix assertion for when the `__proto__` is included if `fetchStart` is 0. * TestExpectations: Canonical link: https://commits.webkit.org/217300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-07 20:36:51 +00:00
ProtocolTest.assert(!fetchCount || properties.length <= fetchCount + (fetchStart ? 0 : 1), `Should only get ${fetchCount} properties.`);
Web Inspector: Better handling for large arrays and collections in Object Trees https://bugs.webkit.org/show_bug.cgi?id=143589 <rdar://problem/16135388> Reviewed by Joseph Pecoraro. Source/JavaScriptCore: Adds two buttons before the "Prototype" item in expanded object/collection previews: - Show %d More - Show All (%d More) The default `fetchCount` increment is `100`. The first button will only be shown if there are more than `100` items remaining (haven't been shown). * inspector/InjectedScriptSource.js: (InjectedScript.prototype.getProperties): (InjectedScript.prototype.getDisplayableProperties): (InjectedScript.prototype.getCollectionEntries): (InjectedScript.prototype._getProperties): (InjectedScript.prototype._internalPropertyDescriptors): (InjectedScript.prototype._propertyDescriptors): (InjectedScript.prototype._propertyDescriptors.createFakeValueDescriptor): (InjectedScript.prototype._propertyDescriptors.processProperties): (InjectedScript.prototype._getSetEntries): (InjectedScript.prototype._getMapEntries): (InjectedScript.prototype._getWeakMapEntries): (InjectedScript.prototype._getWeakSetEntries): (InjectedScript.prototype._getIteratorEntries): (InjectedScript.prototype._entries): (RemoteObject.prototype._generatePreview): (InjectedScript.prototype._propertyDescriptors.arrayIndexPropertyNames): Deleted. Don't include boolean property descriptor values if they are `false. * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::weakMapEntries): (Inspector::JSInjectedScriptHost::weakSetEntries): * inspector/InjectedScript.h: * inspector/InjectedScript.cpp: (Inspector::InjectedScript::getProperties): (Inspector::InjectedScript::getDisplayableProperties): (Inspector::InjectedScript::getCollectionEntries): * inspector/agents/InspectorRuntimeAgent.h: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::asInt): Added. (Inspector::InspectorRuntimeAgent::getProperties): (Inspector::InspectorRuntimeAgent::getDisplayableProperties): (Inspector::InspectorRuntimeAgent::getCollectionEntries): * inspector/protocol/Runtime.json: Add `fetchStart`/`fetchCount` to `getProperties`/`getDisplayableProperties`/`getCollectionEntries`. Mark boolean properties as optional so they can be omitted if `false`. Source/WebInspectorUI: Adds two buttons before the "Prototype" item in expanded object/collection previews: - Show %d More - Show All (%d More) The default `fetchCount` increment is `100`. The first button will only be shown if there are more than `100` items remaining (haven't been shown). * UserInterface/Protocol/RemoteObject.js: (WI.RemoteObject.prototype.getPropertyDescriptors): (WI.RemoteObject.prototype.getDisplayablePropertyDescriptors): (WI.RemoteObject.prototype.getCollectionEntries): (WI.RemoteObject.prototype.getOwnPropertyDescriptor.wrappedCallback): (WI.RemoteObject.prototype._getProperties): Added. (WI.RemoteObject.prototype._getDisplayableProperties): Added. * UserInterface/Views/ObjectTreeView.js: (WI.ObjectTreeView): (WI.ObjectTreeView.showMoreFetchCount): Added. (WI.ObjectTreeView.addShowMoreIfNeeded): Added. (WI.ObjectTreeView.prototype.update): (WI.ObjectTreeView.prototype._updateChildren): (WI.ObjectTreeView.prototype._updateEntries): (WI.ObjectTreeView.prototype._updateProperties): * UserInterface/Views/ObjectTreeView.css: (.tree-outline.object li > button[disabled] + .indeterminate-progress-spinner): Added. Avoid duplicating the button creation logic in `WI.ObjectTreePropertyTreeElement` by using a `static` function. This expects the existence of and requires access to "private" values. * UserInterface/Views/ObjectTreePropertyTreeElement.js: (WI.ObjectTreePropertyTreeElement): (WI.ObjectTreePropertyTreeElement.prototype.onpopulate): (WI.ObjectTreePropertyTreeElement.prototype._updateChildren): (WI.ObjectTreePropertyTreeElement.prototype._updateEntries): (WI.ObjectTreePropertyTreeElement.prototype._updateProperties): (WI.ObjectTreePropertyTreeElement.prototype._updateChildrenInternal): Deleted. * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.evaluated): (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.receivedArrayPropertyNames): Deleted. * UserInterface/Controllers/RuntimeManager.js: (WI.RuntimeManager.prototype.getPropertiesForRemoteObject): Deleted. Remove unused function. * Localizations/en.lproj/localizedStrings.js: LayoutTests: * inspector/runtime/getCollectionEntries.html: Added. * inspector/runtime/getCollectionEntries-expected.txt: Added. * inspector/runtime/getDisplayableProperties.html: Added. * inspector/runtime/getDisplayableProperties-expected.txt: Added. * inspector/runtime/getProperties.html: * inspector/runtime/getProperties-expected.txt: * inspector/runtime/resources/property-descriptor-utilities.js: Added. (makeArray): (makeObject): (makeMap): (makeSet): (makeWeakMap): (makeWeakSet): (TestPage.registerInitializer.ProtocolTest.PropertyDescriptorUtilities.logForEach): (TestPage.registerInitializer.ProtocolTest.PropertyDescriptorUtilities.stringifyRemoteObject): * inspector/model/remote-object-weak-collection.html: Canonical link: https://commits.webkit.org/215604@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-19 05:58:27 +00:00
ProtocolTest.log("Properties:");
properties.forEach(ProtocolTest.PropertyDescriptorUtilities.logForEach);
}
let internalProperties = getDisplayablePropertiesResponse.internalProperties;
if (internalProperties) {
ProtocolTest.log("Internal Properties:");
internalProperties.forEach(ProtocolTest.PropertyDescriptorUtilities.logForEach);
}
},
});
}
addTestCase({
name: "Runtime.getDisplayableProperties.Object",
expression: `(function() { let r = Object(5); r.foo = "cat"; return r; })()`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.Array",
expression: `['red', 'green', 'blue']`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.Constructor",
expression: `(class Test { })`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundConstructor",
expression: `(class Test { }).bind(null)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundConstructorArguments",
expression: `(class Test { }).bind(null, 1, 2, 3)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.Function",
expression: `(function(a, b, c){})`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.FunctionNoParameters",
expression: `(function(){})`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundFunction",
expression: `(function(a, b, c){}).bind(null)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundFunctionWithArguments",
expression: `(function(a, b, c){}).bind(null, 1, 2, 3)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundFunctionNoParameters",
expression: `(function(){}).bind(null)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.BoundFunctionNoParametersWithArguments",
expression: `(function(){}).bind(null, 1, 2, 3)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.Promise.Resolved",
expression: `Promise.resolve(123)`,
});
addTestCase({
name: "Runtime.getDisplayableProperties.Promise.Rejected",
expression: `Promise.reject(123)`,
});
for (let type of ["Object", "Array"]) {
addTestCase({
name: `Runtime.getDisplayableProperties.fetchStart.${type}`,
expression: `make${type}(10)`,
fetchStart: 5,
});
addTestCase({
name: `Runtime.getDisplayableProperties.fetchCount.${type}`,
expression: `make${type}(10)`,
fetchCount: 5,
});
addTestCase({
name: `Runtime.getDisplayableProperties.fetchStartCount.${type}`,
expression: `make${type}(10)`,
fetchStart: 3,
fetchCount: 4,
});
}
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onLoad="runTest()">
<p>Tests for the Runtime.getDisplayableProperties command.</p>
</body>
</html>