OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... | |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 */ | 35 */ |
36 WebInspector.RuntimeModel = function(target) | 36 WebInspector.RuntimeModel = function(target) |
37 { | 37 { |
38 WebInspector.SDKModel.call(this, WebInspector.RuntimeModel, target); | 38 WebInspector.SDKModel.call(this, WebInspector.RuntimeModel, target); |
39 | 39 |
40 this._agent = target.runtimeAgent(); | 40 this._agent = target.runtimeAgent(); |
41 this.target().registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(t his)); | 41 this.target().registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(t his)); |
42 if (target.hasJSCapability()) | 42 if (target.hasJSCapability()) |
43 this._agent.enable(); | 43 this._agent.enable(); |
44 /** | 44 /** @type {!Map<number, !WebInspector.ExecutionContext>} */ |
45 * @type {!Object.<number, !WebInspector.ExecutionContext>} | 45 this._executionContextById = new Map(); |
46 */ | |
47 this._executionContextById = {}; | |
48 this._executionContextComparator = WebInspector.ExecutionContext.comparator; | 46 this._executionContextComparator = WebInspector.ExecutionContext.comparator; |
49 | 47 |
50 if (WebInspector.moduleSetting("customFormatters").get()) | 48 if (WebInspector.moduleSetting("customFormatters").get()) |
51 this._agent.setCustomObjectFormatterEnabled(true); | 49 this._agent.setCustomObjectFormatterEnabled(true); |
52 | 50 |
53 WebInspector.moduleSetting("customFormatters").addChangeListener(this._custo mFormattersStateChanged.bind(this)); | 51 WebInspector.moduleSetting("customFormatters").addChangeListener(this._custo mFormattersStateChanged.bind(this)); |
54 } | 52 } |
55 | 53 |
56 WebInspector.RuntimeModel.Events = { | 54 WebInspector.RuntimeModel.Events = { |
57 ExecutionContextCreated: "ExecutionContextCreated", | 55 ExecutionContextCreated: "ExecutionContextCreated", |
58 ExecutionContextDestroyed: "ExecutionContextDestroyed", | 56 ExecutionContextDestroyed: "ExecutionContextDestroyed", |
59 ExecutionContextChanged: "ExecutionContextChanged" | 57 ExecutionContextChanged: "ExecutionContextChanged" |
60 } | 58 } |
61 | 59 |
62 WebInspector.RuntimeModel._privateScript = "private script"; | 60 WebInspector.RuntimeModel._privateScript = "private script"; |
63 | 61 |
64 WebInspector.RuntimeModel.prototype = { | 62 WebInspector.RuntimeModel.prototype = { |
65 | 63 |
66 /** | 64 /** |
67 * @return {!Array.<!WebInspector.ExecutionContext>} | 65 * @return {!Array.<!WebInspector.ExecutionContext>} |
68 */ | 66 */ |
69 executionContexts: function() | 67 executionContexts: function() |
70 { | 68 { |
71 return Object.values(this._executionContextById).sort(this.executionCont extComparator()); | 69 return Array.from(this._executionContextById.values()).sort(this.executi onContextComparator()); |
lushnikov
2016/07/20 03:02:50
valuesArray
kozy
2016/07/20 17:55:18
Done.
| |
72 }, | 70 }, |
73 | 71 |
74 /** | 72 /** |
75 * @param {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionCo ntext)} comparator | 73 * @param {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionCo ntext)} comparator |
76 */ | 74 */ |
77 setExecutionContextComparator: function(comparator) | 75 setExecutionContextComparator: function(comparator) |
78 { | 76 { |
79 this._executionContextComparator = comparator; | 77 this._executionContextComparator = comparator; |
80 }, | 78 }, |
81 | 79 |
82 /** | 80 /** |
83 * @return {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionC ontext)} comparator | 81 * @return {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionC ontext)} comparator |
84 */ | 82 */ |
85 executionContextComparator: function() | 83 executionContextComparator: function() |
86 { | 84 { |
87 return this._executionContextComparator; | 85 return this._executionContextComparator; |
88 }, | 86 }, |
89 | 87 |
90 /** | 88 /** |
91 * @return {?WebInspector.ExecutionContext} | 89 * @return {?WebInspector.ExecutionContext} |
92 */ | 90 */ |
93 defaultExecutionContext: function() | 91 defaultExecutionContext: function() |
94 { | 92 { |
95 for (var context of Object.values(this._executionContextById)) { | 93 for (var context of this._executionContextById.values()) { |
96 if (context.isDefault) | 94 if (context.isDefault) |
97 return context; | 95 return context; |
98 } | 96 } |
99 return null; | 97 return null; |
100 }, | 98 }, |
101 | 99 |
102 /** | 100 /** |
103 * @param {!RuntimeAgent.ExecutionContextId} id | 101 * @param {!RuntimeAgent.ExecutionContextId} id |
104 * @return {?WebInspector.ExecutionContext} | 102 * @return {?WebInspector.ExecutionContext} |
105 */ | 103 */ |
106 executionContext: function(id) | 104 executionContext: function(id) |
107 { | 105 { |
108 return this._executionContextById[id] || null; | 106 return this._executionContextById.get(id) || null; |
109 }, | 107 }, |
110 | 108 |
111 /** | 109 /** |
112 * @param {!RuntimeAgent.ExecutionContextDescription} context | 110 * @param {!RuntimeAgent.ExecutionContextDescription} context |
113 */ | 111 */ |
114 _executionContextCreated: function(context) | 112 _executionContextCreated: function(context) |
115 { | 113 { |
116 // The private script context should be hidden behind an experiment. | 114 // The private script context should be hidden behind an experiment. |
117 if (context.name === WebInspector.RuntimeModel._privateScript && !contex t.origin && !Runtime.experiments.isEnabled("privateScriptInspection")) { | 115 if (context.name === WebInspector.RuntimeModel._privateScript && !contex t.origin && !Runtime.experiments.isEnabled("privateScriptInspection")) { |
118 return; | 116 return; |
119 } | 117 } |
120 var executionContext = new WebInspector.ExecutionContext(this.target(), context.id, context.name, context.origin, context.isDefault, context.frameId); | 118 var executionContext = new WebInspector.ExecutionContext(this.target(), context.id, context.name, context.origin, context.isDefault, context.frameId); |
121 this._executionContextById[executionContext.id] = executionContext; | 119 this._executionContextById.set(executionContext.id, executionContext); |
122 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution ContextCreated, executionContext); | 120 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution ContextCreated, executionContext); |
123 }, | 121 }, |
124 | 122 |
125 /** | 123 /** |
126 * @param {number} executionContextId | 124 * @param {number} executionContextId |
127 */ | 125 */ |
128 _executionContextDestroyed: function(executionContextId) | 126 _executionContextDestroyed: function(executionContextId) |
129 { | 127 { |
130 var executionContext = this._executionContextById[executionContextId]; | 128 var executionContext = this._executionContextById.get(executionContextId ); |
131 if (!executionContext) | 129 if (!executionContext) |
132 return; | 130 return; |
133 delete this._executionContextById[executionContextId]; | 131 this._executionContextById.delete(executionContextId); |
134 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution ContextDestroyed, executionContext); | 132 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution ContextDestroyed, executionContext); |
135 }, | 133 }, |
136 | 134 |
137 _executionContextsCleared: function() | 135 _executionContextsCleared: function() |
138 { | 136 { |
139 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this.target()) ; | 137 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this.target()) ; |
140 if (debuggerModel) | 138 if (debuggerModel) |
141 debuggerModel.globalObjectCleared(); | 139 debuggerModel.globalObjectCleared(); |
142 var contexts = this.executionContexts(); | 140 var contexts = this.executionContexts(); |
143 this._executionContextById = {}; | 141 this._executionContextById.clear(); |
144 for (var i = 0; i < contexts.length; ++i) | 142 for (var i = 0; i < contexts.length; ++i) |
145 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execu tionContextDestroyed, contexts[i]); | 143 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execu tionContextDestroyed, contexts[i]); |
146 }, | 144 }, |
147 | 145 |
148 /** | 146 /** |
149 * @param {!RuntimeAgent.RemoteObject} payload | 147 * @param {!RuntimeAgent.RemoteObject} payload |
150 * @return {!WebInspector.RemoteObject} | 148 * @return {!WebInspector.RemoteObject} |
151 */ | 149 */ |
152 createRemoteObject: function(payload) | 150 createRemoteObject: function(payload) |
153 { | 151 { |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 /** | 1010 /** |
1013 * @return {boolean} | 1011 * @return {boolean} |
1014 */ | 1012 */ |
1015 isNormalListenerType: function() | 1013 isNormalListenerType: function() |
1016 { | 1014 { |
1017 return this._listenerType === "normal"; | 1015 return this._listenerType === "normal"; |
1018 }, | 1016 }, |
1019 | 1017 |
1020 __proto__: WebInspector.SDKObject.prototype | 1018 __proto__: WebInspector.SDKObject.prototype |
1021 } | 1019 } |
OLD | NEW |