Changeset 127412 in webkit
- Timestamp:
- Sep 3, 2012 1:54:43 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r127410 r127412 1 2012-08-31 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: get rid of context execution id fallback. 4 https://bugs.webkit.org/show_bug.cgi?id=95567 5 6 Reviewed by Yury Semikhatsky. 7 8 * http/tests/inspector/console-cd-completions.html: 9 * http/tests/inspector/console-cd.html: 10 1 11 2012-09-03 Yoshifumi Inoue <yosin@chromium.org> 2 12 -
trunk/LayoutTests/http/tests/inspector/console-cd-completions.html
r122557 r127412 8 8 { 9 9 InspectorTest.showConsolePanel(); 10 var selector = WebInspector.consoleView._ contextSelector._selectElement;10 var selector = WebInspector.consoleView._frameSelector._selectElement; 11 11 var option = selector.firstChild; 12 12 while (option) { … … 21 21 } 22 22 option.selected = true; 23 23 WebInspector.consoleView._frameChanged(); 24 24 25 25 WebInspector.consoleView.completionsForExpression("", "myGlob", false, checkCompletions.bind(this)); -
trunk/LayoutTests/http/tests/inspector/console-cd.html
r122557 r127412 9 9 { 10 10 InspectorTest.showConsolePanel(); 11 var selector = WebInspector.consoleView._ contextSelector._selectElement;11 var selector = WebInspector.consoleView._frameSelector._selectElement; 12 12 var option = selector.firstChild; 13 13 while (option) { … … 22 22 } 23 23 option.selected = true; 24 WebInspector.consoleView._frameChanged(); 25 24 26 InspectorTest.evaluateInConsoleAndDump("foo", finish); 25 27 function finish() -
trunk/Source/WebCore/ChangeLog
r127404 r127412 1 2012-08-31 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: get rid of context execution id fallback. 4 https://bugs.webkit.org/show_bug.cgi?id=95567 5 6 Reviewed by Yury Semikhatsky. 7 8 We now assign execution context id upon changes in the UI. 9 10 * inspector/front-end/ConsoleView.js: 11 (WebInspector.ConsoleView.prototype.get statusBarItems): 12 (WebInspector.ConsoleView.prototype._contextAdded): 13 (WebInspector.ConsoleView.prototype._addContextList): 14 (WebInspector.ConsoleView.prototype._contextListRemoved): 15 (WebInspector.ConsoleView.prototype._updateExecutionContextSelector): 16 (WebInspector.ConsoleView.prototype._appendExecutionContextOption): 17 (WebInspector.ConsoleView.prototype._executionContextChanged): 18 (WebInspector.ConsoleView.prototype._contextListUpdated): 19 (WebInspector.ConsoleView.prototype._addedExecutionContext): 20 (WebInspector.ConsoleView.prototype.evalInInspectedWindow.evalCallback): 21 (WebInspector.ConsoleView.prototype.evalInInspectedWindow): 22 (WebInspector.ConsoleView.prototype._enterKeyPressed): 23 * inspector/front-end/JavaScriptContextManager.js: 24 (WebInspector.JavaScriptContextManager): 25 (WebInspector.JavaScriptContextManager.prototype.contextLists): 26 (WebInspector.JavaScriptContextManager.prototype.contextByFrameAndSecurityOrigin): 27 (WebInspector.JavaScriptContextManager.prototype._frameAdded): 28 (WebInspector.JavaScriptContextManager.prototype._frameNavigated): 29 (WebInspector.JavaScriptContextManager.prototype._frameDetached): 30 (WebInspector.JavaScriptContextManager.prototype.isolatedContextCreated): 31 (WebInspector.FrameExecutionContextList): 32 (WebInspector.FrameExecutionContextList.prototype._frameNavigated): 33 (WebInspector.FrameExecutionContextList.prototype._addExecutionContext): 34 (WebInspector.FrameExecutionContextList.prototype.executionContexts): 35 (WebInspector.FrameExecutionContextList.prototype.contextBySecurityOrigin): 36 1 37 2012-09-03 Grzegorz Czajkowski <g.czajkowski@samsung.com> 2 38 -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r126709 r127412 45 45 this._clearConsoleButton.addEventListener("click", this._requestClearMessages, this); 46 46 47 this._ contextSelector = new WebInspector.StatusBarComboBox(this._updateIsolatedWorldSelector.bind(this), "console-context");48 this._ isolatedWorldSelector = new WebInspector.StatusBarComboBox(null, "console-context");47 this._frameSelector = new WebInspector.StatusBarComboBox(this._frameChanged.bind(this), "console-context"); 48 this._contextSelector = new WebInspector.StatusBarComboBox(this._contextChanged.bind(this), "console-context"); 49 49 50 50 if (hideContextSelector) { 51 this._frameSelector.element.addStyleClass("hidden"); 51 52 this._contextSelector.element.addStyleClass("hidden"); 52 this._isolatedWorldSelector.element.addStyleClass("hidden");53 53 } 54 54 … … 74 74 this._filterBarElement.className = "scope-bar status-bar-item"; 75 75 76 function createDividerElement() { 76 function createDividerElement() 77 { 77 78 var dividerElement = document.createElement("div"); 78 79 dividerElement.addStyleClass("scope-bar-divider"); … … 81 82 82 83 var updateFilterHandler = this._updateFilter.bind(this); 83 function createFilterElement(category, label) { 84 85 function createFilterElement(category, label) 86 { 84 87 var categoryElement = document.createElement("li"); 85 88 categoryElement.category = category; … … 119 122 this.prompt.setHistoryData(WebInspector.settings.consoleHistory.get()); 120 123 121 WebInspector.javaScriptContextManager.context s().forEach(this._addContext, this);122 WebInspector.javaScriptContextManager.addEventListener(WebInspector.JavaScriptContextManager.Events.Frame ContextAdded, this._contextAdded, this);123 WebInspector.javaScriptContextManager.addEventListener(WebInspector.JavaScriptContextManager.Events.Frame ContextRemoved, this._contextRemoved, this);124 WebInspector.javaScriptContextManager.contextLists().forEach(this._addFrame, this); 125 WebInspector.javaScriptContextManager.addEventListener(WebInspector.JavaScriptContextManager.Events.FrameExecutionContextListAdded, this._frameAdded, this); 126 WebInspector.javaScriptContextManager.addEventListener(WebInspector.JavaScriptContextManager.Events.FrameExecutionContextListRemoved, this._frameRemoved, this); 124 127 } 125 128 … … 132 135 get statusBarItems() 133 136 { 134 return [this._clearConsoleButton.element, this._contextSelector.element, this._isolatedWorldSelector.element, this._filterBarElement]; 137 return [this._clearConsoleButton.element, this._frameSelector.element, this._contextSelector.element, this._filterBarElement]; 138 }, 139 140 /** 141 * @param {WebInspector.Event} event 142 */ 143 _frameAdded: function(event) 144 { 145 var contextList = /** @type {WebInspector.FrameExecutionContextList} */ event.data; 146 this._addFrame(contextList); 147 }, 148 149 /** 150 * @param {WebInspector.FrameExecutionContextList} contextList 151 */ 152 _addFrame: function(contextList) 153 { 154 var option = document.createElement("option"); 155 option.text = contextList.displayName; 156 option.title = contextList.url; 157 option._contextList = contextList; 158 contextList._consoleOption = option; 159 this._frameSelector.addOption(option); 160 contextList.addEventListener(WebInspector.FrameExecutionContextList.EventTypes.ContextsUpdated, this._frameUpdated, this); 161 contextList.addEventListener(WebInspector.FrameExecutionContextList.EventTypes.ContextAdded, this._contextAdded, this); 162 this._frameChanged(); 163 }, 164 165 /** 166 * @param {WebInspector.Event} event 167 */ 168 _frameRemoved: function(event) 169 { 170 var contextList = /** @type {WebInspector.FrameExecutionContextList} */ event.data; 171 this._frameSelector.removeOption(contextList._consoleOption); 172 this._frameChanged(); 173 }, 174 175 _frameChanged: function() 176 { 177 var context = this._currentFrame(); 178 if (!context) { 179 delete this._currentExecutionContext; 180 this._contextSelector.element.addStyleClass("hidden"); 181 return; 182 } 183 184 var executionContexts = context.executionContexts(); 185 if (executionContexts.length) 186 this._currentExecutionContext = executionContexts[0]; 187 188 if (executionContexts.length === 1) { 189 this._contextSelector.element.addStyleClass("hidden"); 190 return; 191 } 192 this._contextSelector.element.removeStyleClass("hidden"); 193 this._contextSelector.removeOptions(); 194 for (var i = 0; i < executionContexts.length; i++) 195 this._appendContextOption(executionContexts[i]); 196 }, 197 198 /** 199 * @param {WebInspector.ExecutionContext} executionContext 200 */ 201 _appendContextOption: function(executionContext) 202 { 203 if (!this._currentExecutionContext) 204 this._currentExecutionContext = executionContext; 205 var option = document.createElement("option"); 206 option.text = executionContext.name; 207 option.title = executionContext.id; 208 option._executionContext = executionContext; 209 this._contextSelector.addOption(option); 210 }, 211 212 /** 213 * @param {Event} event 214 */ 215 _contextChanged: function(event) 216 { 217 var option = this._contextSelector.selectedOption(); 218 this._currentExecutionContext = option ? option._executionContext : undefined; 219 }, 220 221 /** 222 * @param {WebInspector.Event} event 223 */ 224 _frameUpdated: function(event) 225 { 226 var contextList = /** {WebInspector.FrameExecutionContextList */ event.data; 227 var option = contextList._consoleOption; 228 option.text = contextList.displayName; 229 option.title = contextList.url; 135 230 }, 136 231 … … 140 235 _contextAdded: function(event) 141 236 { 142 var context = /** @type {WebInspector.FrameEvaluationContext} */ event.data; 143 this._addContext(context); 237 var contextList = /** {WebInspector.FrameExecutionContextList */ event.data; 238 if (contextList === this._currentFrame()) 239 this._frameChanged(); 144 240 }, 145 241 146 242 /** 147 * @ param {WebInspector.FrameEvaluationContext} context243 * @return {WebInspector.FrameExecutionContextList|undefined} 148 244 */ 149 _addContext: function(context) 150 { 151 var option = document.createElement("option"); 152 option.text = context.displayName; 153 option.title = context.url; 154 option._context = context; 155 context._consoleOption = option; 156 this._contextSelector.addOption(option); 157 context.addEventListener(WebInspector.FrameEvaluationContext.EventTypes.Updated, this._contextUpdated, this); 158 context.addEventListener(WebInspector.FrameEvaluationContext.EventTypes.AddedExecutionContext, this._addedExecutionContext, this); 159 this._updateIsolatedWorldSelector(); 160 }, 161 162 /** 163 * @param {WebInspector.Event} event 164 */ 165 _contextRemoved: function(event) 166 { 167 var context = /** @type {WebInspector.FrameEvaluationContext} */ event.data; 168 this._contextSelector.removeOption(context._consoleOption); 169 this._updateIsolatedWorldSelector(); 170 }, 171 172 _updateIsolatedWorldSelector: function() 173 { 174 var context = this._currentEvaluationContext(); 175 if (!context) { 176 this._isolatedWorldSelector.element.addStyleClass("hidden"); 177 return; 178 } 179 180 var isolatedContexts = context.isolatedContexts(); 181 if (!isolatedContexts.length) { 182 this._isolatedWorldSelector.element.addStyleClass("hidden"); 183 return; 184 } 185 this._isolatedWorldSelector.element.removeStyleClass("hidden"); 186 this._isolatedWorldSelector.removeOptions(); 187 this._appendIsolatedContextOption(context.mainWorldContext()); 188 for (var i = 0; i < isolatedContexts.length; i++) 189 this._appendIsolatedContextOption(isolatedContexts[i]); 190 }, 191 192 _appendIsolatedContextOption: function(isolatedContext) 193 { 194 if (!isolatedContext) 195 return; 196 var option = document.createElement("option"); 197 option.text = isolatedContext.name; 198 option.title = isolatedContext.id; 199 option._executionContextId = isolatedContext.id; 200 this._isolatedWorldSelector.addOption(option); 201 }, 202 203 _contextUpdated: function(event) 204 { 205 var context = event.data; 206 var option = context._consoleOption; 207 option.text = context.displayName; 208 option.title = context.url; 209 }, 210 211 _addedExecutionContext: function(event) 212 { 213 var context = event.data; 214 if (context === this._currentEvaluationContext()) 215 this._updateIsolatedWorldSelector(); 216 }, 217 218 _currentEvaluationContextId: function() 219 { 220 var result = this._currentIsolatedContextId(); 221 if (result !== undefined) 222 return result; 223 var context = this._currentEvaluationContext(); 224 if (context && context.mainWorldContext()) 225 return context.mainWorldContext().id; 226 return undefined; 227 }, 228 229 _currentEvaluationContext: function() 230 { 231 var option = this._contextSelector.selectedOption(); 232 if (!option) 233 return undefined; 234 return option._context; 235 }, 236 237 _currentIsolatedContextId: function() 238 { 239 if (this._isolatedWorldSelector.element.hasStyleClass("hidden")) 240 return undefined; 241 var option = this._isolatedWorldSelector.selectedOption(); 242 if (!option) 243 return undefined; 244 return option._executionContextId; 245 _currentFrame: function() 246 { 247 var option = this._frameSelector.selectedOption(); 248 return option ? option._contextList : undefined; 245 249 }, 246 250 … … 707 711 callback(WebInspector.RemoteObject.fromPayload(result), !!wasThrown); 708 712 } 709 var contextId = this._currentEvaluationContextId(); 710 RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, contextId, returnByValue, evalCallback); 713 RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this._currentExecutionContext ? this._currentExecutionContext.id : undefined, returnByValue, evalCallback); 711 714 }, 712 715 … … 733 736 runScript: function(scriptId) 734 737 { 735 var contextId = WebInspector.consoleView._currentEvaluationContextId(); 736 DebuggerAgent.runScript(scriptId, contextId, "console", false, runCallback.bind(this)); 738 DebuggerAgent.runScript(scriptId, this._currentExecutionContext ? this._currentExecutionContext.id : undefined, "console", false, runCallback.bind(this)); 737 739 WebInspector.userMetrics.ConsoleEvaluated.record(); 738 740 -
trunk/Source/WebCore/inspector/front-end/JavaScriptContextManager.js
r126709 r127412 40 40 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this); 41 41 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._didLoadCachedResources, this); 42 this._frameIdToContext = {};42 this._frameIdToContextList = {}; 43 43 } 44 44 45 45 WebInspector.JavaScriptContextManager.Events = { 46 Frame ContextAdded: "FrameContextAdded",47 Frame ContextRemoved: "FrameContextRemoved",46 FrameExecutionContextListAdded: "FrameExecutionContextListAdded", 47 FrameExecutionContextListRemoved: "FrameExecutionContextListRemoved", 48 48 } 49 49 50 50 WebInspector.JavaScriptContextManager.prototype = { 51 51 /** 52 * @return {Array.<WebInspector.FrameE valuationContext>}53 */ 54 context s: function()55 { 56 return Object.values(this._frameIdToContext );52 * @return {Array.<WebInspector.FrameExecutionContextList>} 53 */ 54 contextLists: function() 55 { 56 return Object.values(this._frameIdToContextList); 57 57 }, 58 58 … … 63 63 contextByFrameAndSecurityOrigin: function(frame, securityOrigin) 64 64 { 65 var frameContext = this._frameIdToContext [frame.id];65 var frameContext = this._frameIdToContextList[frame.id]; 66 66 return frameContext && frameContext.contextBySecurityOrigin(securityOrigin); 67 67 }, … … 70 70 { 71 71 var frame = event.data; 72 var context = new WebInspector.FrameE valuationContext(frame);73 this._frameIdToContext [frame.id] = context;74 this.dispatchEventToListeners(WebInspector.JavaScriptContextManager.Events.Frame ContextAdded, context);72 var context = new WebInspector.FrameExecutionContextList(frame); 73 this._frameIdToContextList[frame.id] = context; 74 this.dispatchEventToListeners(WebInspector.JavaScriptContextManager.Events.FrameExecutionContextListAdded, context); 75 75 }, 76 76 … … 78 78 { 79 79 var frame = event.data; 80 var context = this._frameIdToContext [frame.id];80 var context = this._frameIdToContextList[frame.id]; 81 81 if (context) 82 82 context._frameNavigated(frame); … … 86 86 { 87 87 var frame = event.data; 88 var context = this._frameIdToContext [frame.id];88 var context = this._frameIdToContextList[frame.id]; 89 89 if (!context) 90 90 return; 91 this.dispatchEventToListeners(WebInspector.JavaScriptContextManager.Events.Frame ContextRemoved, context);92 delete this._frameIdToContext [frame.id];91 this.dispatchEventToListeners(WebInspector.JavaScriptContextManager.Events.FrameExecutionContextListRemoved, context); 92 delete this._frameIdToContextList[frame.id]; 93 93 }, 94 94 … … 101 101 isolatedContextCreated: function(context) 102 102 { 103 var frameEvaluationContext = this._frameIdToContext[context.frameId];103 var contextList = this._frameIdToContextList[context.frameId]; 104 104 // FIXME(85708): this should never happen 105 if (! frameEvaluationContext)105 if (!contextList) 106 106 return; 107 frameEvaluationContext._addExecutionContext(new WebInspector.ExecutionContext(context.id, context.name, context.isPageContext));107 contextList._addExecutionContext(new WebInspector.ExecutionContext(context.id, context.name, context.isPageContext)); 108 108 } 109 109 } … … 163 163 * @extends {WebInspector.Object} 164 164 */ 165 WebInspector.FrameE valuationContext = function(frame)165 WebInspector.FrameExecutionContextList = function(frame) 166 166 { 167 167 this._frame = frame; 168 this._mainWorldContext = null; 169 this._isolatedContexts = []; 170 } 171 172 WebInspector.FrameEvaluationContext.EventTypes = { 173 Updated: "Updated", 174 AddedExecutionContext: "AddedExecutionContext" 175 } 176 177 WebInspector.FrameEvaluationContext.prototype = 168 this._executionContexts = []; 169 } 170 171 WebInspector.FrameExecutionContextList.EventTypes = { 172 ContextsUpdated: "ContextsUpdated", 173 ContextAdded: "ContextAdded" 174 } 175 176 WebInspector.FrameExecutionContextList.prototype = 178 177 { 179 178 _frameNavigated: function(frame) 180 179 { 181 180 this._frame = frame; 182 this._mainWorldContext = null; 183 this._isolatedContexts = []; 184 this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.Updated, this); 181 this._executionContexts = []; 182 this.dispatchEventToListeners(WebInspector.FrameExecutionContextList.EventTypes.ContextsUpdated, this); 185 183 }, 186 184 … … 190 188 _addExecutionContext: function(context) 191 189 { 192 if (context.isMainWorldContext) 193 this._mainWorldContext = context; 194 else { 195 var insertAt = insertionIndexForObjectInListSortedByFunction(context, this._isolatedContexts, WebInspector.ExecutionContext.comparator); 196 this._isolatedContexts.splice(insertAt, 0, context); 197 } 198 this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.AddedExecutionContext, this); 199 }, 200 201 mainWorldContext: function() 202 { 203 return this._mainWorldContext; 204 }, 205 206 isolatedContexts: function() 207 { 208 return this._isolatedContexts; 190 var insertAt = insertionIndexForObjectInListSortedByFunction(context, this._executionContexts, WebInspector.ExecutionContext.comparator); 191 this._executionContexts.splice(insertAt, 0, context); 192 this.dispatchEventToListeners(WebInspector.FrameExecutionContextList.EventTypes.ContextAdded, this); 193 }, 194 195 executionContexts: function() 196 { 197 return this._executionContexts; 209 198 }, 210 199 … … 214 203 contextBySecurityOrigin: function(securityOrigin) 215 204 { 216 for (var i = 0; i < this._ isolatedContexts.length; ++i) {217 var context = this._ isolatedContexts[i];205 for (var i = 0; i < this._executionContexts.length; ++i) { 206 var context = this._executionContexts[i]; 218 207 if (!context.isMainWorldContext && context.name === securityOrigin) 219 208 return context; … … 246 235 } 247 236 248 WebInspector.FrameE valuationContext.prototype.__proto__ = WebInspector.Object.prototype;237 WebInspector.FrameExecutionContextList.prototype.__proto__ = WebInspector.Object.prototype;
Note: See TracChangeset
for help on using the changeset viewer.