/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * A helper method that creates a property descriptor for the provided object, * properly formatted for sending in a protocol response. * * @param ObjectActor objectActor * The object actor of the object we are current listing properties. * @param string name * The property that the descriptor is generated for. * @param {Number} depth * Current depth in the generated preview object sent to the client. * @param boolean [onlyEnumerable] * Optional: true if you want a descriptor only for an enumerable * property, false otherwise. * @return object|undefined * The property descriptor, or undefined if objectActor is not an enumerable * property and onlyEnumerable=true.
*/ function propertyDescriptor(objectActor, name, depth, onlyEnumerable) { if (!DevToolsUtils.isSafeDebuggerObject(objectActor.obj)) { return undefined;
}
let desc; try {
desc = objectActor.obj.getOwnPropertyDescriptor(name);
} catch (e) { // Calling getOwnPropertyDescriptor on wrapped native prototypes is not // allowed (bug 560072). Inform the user with a bogus, but hopefully // explanatory, descriptor. return {
configurable: false,
writable: false,
enumerable: false,
value: e.name,
};
}
if (isStorage(objectActor.obj)) { if (name === "length") { return undefined;
} return desc;
}
if (!desc || (onlyEnumerable && !desc.enumerable)) { return undefined;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.