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 = function(descriptor, isOwnProperty, wasThrown, isInternalProperty)
28 WebInspector.Object.call(this);
30 console.assert(descriptor);
31 console.assert(descriptor.name);
32 console.assert(!descriptor.value || descriptor.value instanceof WebInspector.RemoteObject);
33 console.assert(!descriptor.get || descriptor.get instanceof WebInspector.RemoteObject);
34 console.assert(!descriptor.set || descriptor.set instanceof WebInspector.RemoteObject);
36 this._name = descriptor.name;
37 this._value = descriptor.value;
38 this._hasValue = "value" in descriptor;
39 this._get = descriptor.get;
40 this._set = descriptor.set;
42 this._writable = descriptor.writable || false;
43 this._configurable = descriptor.configurable || false;
44 this._enumerable = descriptor.enumerable || false;
46 this._own = isOwnProperty || false;
47 this._wasThrown = wasThrown || false;
48 this._internal = isInternalProperty || false;
51 // Runtime.PropertyDescriptor or Runtime.InternalPropertyDescriptor.
52 WebInspector.PropertyDescriptor.fromPayload = function(payload)
55 payload.value = WebInspector.RemoteObject.fromPayload(payload.value);
57 payload.get = WebInspector.RemoteObject.fromPayload(payload.get);
59 payload.set = WebInspector.RemoteObject.fromPayload(payload.set);
61 if (payload.internal) {
62 console.assert(payload.value);
63 payload.writable = payload.configurable = payload.enumerable = false;
67 return new WebInspector.PropertyDescriptor(payload, payload.isOwn, payload.wasThrown, payload.internal);
70 WebInspector.PropertyDescriptor.prototype = {
71 constructor: WebInspector.PropertyDescriptor,
72 __proto__: WebInspector.Object.prototype,
98 return this._writable;
103 return this._configurable;
108 return this._enumerable;
118 return this._wasThrown;
121 get isInternalProperty()
123 return this._internal;
128 return this._hasValue;
131 hasGetter: function()
133 return this._get && this._get.type === "function";
136 hasSetter: function()
138 return this._set && this._set.type === "function";