2 * Copyright (C) 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 WebInspector.PropertyDescriptor = class PropertyDescriptor extends WebInspector.Object
28 constructor(descriptor, isOwnProperty, wasThrown, nativeGetter, isInternalProperty)
32 console.assert(descriptor);
33 console.assert(descriptor.name);
34 console.assert(!descriptor.value || descriptor.value instanceof WebInspector.RemoteObject);
35 console.assert(!descriptor.get || descriptor.get instanceof WebInspector.RemoteObject);
36 console.assert(!descriptor.set || descriptor.set instanceof WebInspector.RemoteObject);
38 this._name = descriptor.name;
39 this._value = descriptor.value;
40 this._hasValue = "value" in descriptor;
41 this._get = descriptor.get;
42 this._set = descriptor.set;
44 this._writable = descriptor.writable || false;
45 this._configurable = descriptor.configurable || false;
46 this._enumerable = descriptor.enumerable || false;
48 this._own = isOwnProperty || false;
49 this._wasThrown = wasThrown || false;
50 this._nativeGetterValue = nativeGetter || false;
51 this._internal = isInternalProperty || false;
56 // Runtime.PropertyDescriptor or Runtime.InternalPropertyDescriptor (second argument).
57 static fromPayload(payload, internal)
60 payload.value = WebInspector.RemoteObject.fromPayload(payload.value);
62 payload.get = WebInspector.RemoteObject.fromPayload(payload.get);
64 payload.set = WebInspector.RemoteObject.fromPayload(payload.set);
67 console.assert(payload.value);
68 payload.writable = payload.configurable = payload.enumerable = false;
72 return new WebInspector.PropertyDescriptor(payload, payload.isOwn, payload.wasThrown, payload.nativeGetter, internal);
99 return this._writable;
104 return this._configurable;
109 return this._enumerable;
119 return this._wasThrown;
124 return this._nativeGetterValue;
127 get isInternalProperty()
129 return this._internal;
134 return this._hasValue;
139 return this._get && this._get.type === "function";
144 return this._set && this._set.type === "function";
149 return !isNaN(Number(this._name));