Clarified that instrumenting window.nonExisting object properties is not supported

This commit is contained in:
Fredrik Wollsén 2019-08-13 12:42:41 +03:00
Родитель 22dd48a1a8
Коммит 29d576624e
2 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -301,6 +301,9 @@ export function jsInstruments(event_id, sendMessagesToLogger) {
// Rough implementations of Object.getPropertyDescriptor and Object.getPropertyNames
// See http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api
Object.getPropertyDescriptor = function(subject, name) {
if (subject === undefined) {
throw new Error("Can't get property descriptor for undefined");
}
let pd = Object.getOwnPropertyDescriptor(subject, name);
let proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {

Просмотреть файл

@ -45,6 +45,13 @@
console.log("nonExistingProp1 after set - caught exception: ", e);
}
// call non-existing object method
try {
window.nonExisting.nonExistingMethod1('hello', {'world': true});
} catch (e) {
console.log("call object method - caught exception: ", e);
}
/*
* Interact with partially existing object instrumented non-recursively
*/
@ -111,9 +118,18 @@
// Instrument non-existing object non-recursively
console.log("Instrumenting window.nonExisting!");
// Instrument the window.nonExisting property itself (not its object properties)
window.instrumentObject(window, "window", {
propertiesToInstrument: ["nonExisting"],
});
// Instrument window.nonExisting object properties - currently not supported
// window.instrumentObject(window.nonExisting, "window.nonExisting", {
// propertiesToInstrument: [
// "existingProp",
// "nonExistingProp1",
// "nonExistingMethod1",
// ],
// });
// Instrument partially existing object non-recursively
console.log("Instrumenting window.partiallyExisting!");