Changeset 202566 in webkit
- Timestamp:
- Jun 28, 2016 8:12:10 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202565 r202566 1 2016-06-28 Brian Burg <bburg@apple.com> 2 3 Web Inspector: QuickConsole should update its selection when RuntimeManager.defaultExecutionContextIdentifier changes 4 https://bugs.webkit.org/show_bug.cgi?id=159183 5 6 Reviewed by Timothy Hatcher. 7 8 Add a new test case for reverting to the top-level execution context when the selected context is destroyed. 9 10 * inspector/runtime/change-execution-context-identifier-expected.txt: 11 * inspector/runtime/change-execution-context-identifier.html: 12 1 13 2016-06-28 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 14 -
trunk/LayoutTests/inspector/runtime/change-execution-context-identifier-expected.txt
r202522 r202566 1 2 1 Test that RuntimeManager.evaluateInInspectedWindow respects the selected execution context. 3 2 … … 20 19 PASS: The passphrase should match the phrase defined in the main frame. 21 20 21 -- Running test case: ScriptExecutionContextRemoveSubframe 22 PASS: The test page should only have one sub-frame. 23 PASS: The test page should now have no sub-frames. 24 PASS: When a selected non-top-level execution context is removed, the default execution context should revert to the top-level context. 25 -
trunk/LayoutTests/inspector/runtime/change-execution-context-identifier.html
r202522 r202566 37 37 test: (resolve, reject) => { 38 38 let mainFrame = WebInspector.frameResourceManager.mainFrame; 39 let subframes = WebInspector.frameResourceManager.frames.filter((frame) => frame != mainFrame);39 let subframes = WebInspector.frameResourceManager.frames.filter((frame) => frame !== mainFrame); 40 40 InspectorTest.expectThat(subframes.length === 1, "The test page should only have one sub-frame."); 41 41 … … 64 64 }); 65 65 66 suite.addTestCase({ 67 name: "ScriptExecutionContextRemoveSubframe", 68 description: "Test that evaluateInInspectedWindow works when the defaultExecutionContextIdentifier is destroyed and reverts to the top-level context.", 69 test: (resolve, reject) => { 70 let mainFrame = WebInspector.frameResourceManager.mainFrame; 71 let subframes = WebInspector.frameResourceManager.frames.filter((frame) => frame !== mainFrame); 72 InspectorTest.expectThat(subframes.length === 1, "The test page should only have one sub-frame."); 73 74 // Set the execution context to the subframe so we can switch away from it when the frame is detached. 75 WebInspector.runtimeManager.defaultExecutionContextIdentifier = subframes[0].pageExecutionContext.id; 76 77 // Force-override the contextId, otherwise we won't be able to access the iframe's DOM element when evaluating in the iframe execution context. 78 let expression = `document.getElementById("subframe").remove();`; 79 let objectGroup = "test"; 80 let contextId = WebInspector.RuntimeManager.TopLevelExecutionContextIdentifier; 81 RuntimeAgent.evaluate.invoke({expression, objectGroup, contextId}, () => { 82 InspectorTest.expectThat(WebInspector.frameResourceManager.frames.length === 1, "The test page should now have no sub-frames."); 83 InspectorTest.expectThat(WebInspector.runtimeManager.defaultExecutionContextIdentifier === WebInspector.RuntimeManager.TopLevelExecutionContextIdentifier, "When a selected non-top-level execution context is removed, the default execution context should revert to the top-level context."); 84 resolve(); 85 }); 86 } 87 }); 88 66 89 suite.runTestCasesAndFinish(); 67 90 } … … 69 92 </head> 70 93 <body> 71 <iframe src="resources/change-execution-context-identifier-subframe.html" onload="runTest()"></iframe>94 <iframe id="subframe" src="resources/change-execution-context-identifier-subframe.html" onload="runTest()"></iframe> 72 95 <p>Test that RuntimeManager.evaluateInInspectedWindow respects the selected execution context.</p> 73 96 </body> -
trunk/Source/WebInspectorUI/ChangeLog
r202529 r202566 1 2016-06-28 Brian Burg <bburg@apple.com> 2 3 Web Inspector: QuickConsole should update its selection when RuntimeManager.defaultExecutionContextIdentifier changes 4 https://bugs.webkit.org/show_bug.cgi?id=159183 5 6 Reviewed by Timothy Hatcher. 7 8 Currently, the UI listens for state changes in the Frame tree to decide when to reset 9 the selected execution context back to its default value. This is no good, because this 10 should happen even if we have no UI (i.e., testing models only). The UI should simply 11 display changes to the model rather than driving them based on other model changes. 12 13 Move the logic to reset the execution context into RuntimeManager. When the selected 14 context changes, an event is fired which causes the QuickConsole to rebuild its path components. 15 16 * UserInterface/Controllers/RuntimeManager.js: 17 (WebInspector.RuntimeManager): 18 (WebInspector.RuntimeManager.prototype.set defaultExecutionContextIdentifier): 19 Fire an event when the execution context actually changes. 20 21 (WebInspector.RuntimeManager.prototype._frameExecutionContextsCleared): 22 Added. If the selected context was cleared, reset back to default. 23 24 * UserInterface/Models/Frame.js: 25 (WebInspector.Frame.prototype.clearExecutionContexts): 26 Include the contexts that were cleared so clients can match against them. 27 28 * UserInterface/Views/QuickConsole.js: 29 (WebInspector.QuickConsole): 30 Use the proper constant name. Both the old and new names evaluated to `undefined`. 31 No need to keep track of the selected path component, it will always match the 32 defaultExecutionContextIdentifier in RuntimeManager. 33 34 (WebInspector.QuickConsole.prototype.get selectedExecutionContextIdentifier): 35 (WebInspector.QuickConsole.prototype.set selectedExecutionContextIdentifier): 36 Forward to RuntimeManager. This name is less awkward for the UI code that manages selections. 37 38 (WebInspector.QuickConsole.prototype._executionContextPathComponentsToDisplay): 39 Special-case for the main frame execution context. 40 41 (WebInspector.QuickConsole.prototype._framePageExecutionContextsChanged): 42 Remove indirection. 43 44 (WebInspector.QuickConsole.prototype._frameExecutionContextsCleared): 45 Fix the guard to handle undefined execution contexts in the case where it represents the main frame (undefined). 46 47 (WebInspector.QuickConsole.prototype._defaultExecutionContextChanged): 48 Rebuild when the model changes. 49 50 (WebInspector.QuickConsole.prototype._pathComponentSelected): Simplify. 51 (WebInspector.QuickConsole.prototype.get executionContextIdentifier): 52 (WebInspector.QuickConsole.prototype._removeExecutionContextPathComponentForFrame): 53 Move the fallback selection behavior into RuntimeManager. 54 55 (WebInspector.QuickConsole.prototype._updateExecutionContextPathComponentForFrame): Deleted. 56 This has been dead code ever since we removed iOS 6 legacy support. 57 1 58 2016-06-27 Joseph Pecoraro <pecoraro@apple.com> 2 59 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
r202522 r202566 32 32 // Enable the RuntimeAgent to receive notification of execution contexts. 33 33 RuntimeAgent.enable(); 34 35 WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this); 34 36 } 35 37 … … 125 127 126 128 get defaultExecutionContextIdentifier() { return this._defaultExecutionContextIdentifier; } 127 set defaultExecutionContextIdentifier(value) { this._defaultExecutionContextIdentifier = value; } 129 set defaultExecutionContextIdentifier(value) 130 { 131 if (this._defaultExecutionContextIdentifier === value) 132 return; 133 134 this._defaultExecutionContextIdentifier = value; 135 this.dispatchEventToListeners(WebInspector.RuntimeManager.Event.DefaultExecutionContextChanged); 136 } 137 138 // Private 139 140 _frameExecutionContextsCleared(event) 141 { 142 let contexts = event.data.contexts || []; 143 144 let currentContextWasDestroyed = contexts.some((context) => context.id === this._defaultExecutionContextIdentifier); 145 if (currentContextWasDestroyed) 146 this.defaultExecutionContextIdentifier = WebInspector.RuntimeManager.TopLevelExecutionContextIdentifier; 147 } 128 148 }; 129 149 … … 131 151 132 152 WebInspector.RuntimeManager.Event = { 133 DidEvaluate: "runtime-manager-did-evaluate" 153 DidEvaluate: Symbol("runtime-manager-did-evaluate"), 154 DefaultExecutionContextChanged: Symbol("runtime-manager-default-execution-context-changed"), 134 155 }; 135 156 -
trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js
r200065 r202566 207 207 { 208 208 if (this._executionContextList.contexts.length) { 209 let contexts = this._executionContextList.contexts.slice(); 209 210 this._executionContextList.clear(); 210 this.dispatchEventToListeners(WebInspector.Frame.Event.ExecutionContextsCleared, {committingProvisionalLoad:!!committingProvisionalLoad });211 this.dispatchEventToListeners(WebInspector.Frame.Event.ExecutionContextsCleared, {committingProvisionalLoad:!!committingProvisionalLoad, contexts}); 211 212 } 212 213 } -
trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js
r202522 r202566 1 1 /* 2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 this._toggleOrFocusKeyboardShortcut = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape, this._toggleOrFocus.bind(this)); 33 33 34 var mainFrameExecutionContext = new WebInspector.ExecutionContext(WebInspector.QuickConsole.MainFrameContextExecutionIdentifier, WebInspector.UIString("Main Frame"), true, null);34 let mainFrameExecutionContext = new WebInspector.ExecutionContext(WebInspector.RuntimeManager.TopLevelContextExecutionIdentifier, WebInspector.UIString("Main Frame"), true, null); 35 35 this._mainFrameExecutionContextPathComponent = this._createExecutionContextPathComponent(mainFrameExecutionContext.name, mainFrameExecutionContext.identifier); 36 this._selectedExecutionContextPathComponent = this._mainFrameExecutionContextPathComponent;37 36 38 37 this._otherExecutionContextPathComponents = []; … … 71 70 72 71 WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, this._debuggerActiveCallFrameDidChange, this); 72 73 WebInspector.runtimeManager.addEventListener(WebInspector.RuntimeManager.Event.DefaultExecutionContextChanged, this._defaultExecutionContextChanged, this); 73 74 } 74 75 … … 80 81 } 81 82 82 get executionContextIdentifier() 83 { 84 return this._selectedExecutionContextPathComponent._executionContextIdentifier; 83 get selectedExecutionContextIdentifier() 84 { 85 return WebInspector.runtimeManager.defaultExecutionContextIdentifier; 86 } 87 88 set selectedExecutionContextIdentifier(value) 89 { 90 if (value === this.selectedExecutionContextIdentifier) 91 return; 92 93 WebInspector.runtimeManager.defaultExecutionContextIdentifier = value; 85 94 } 86 95 … … 125 134 return []; 126 135 127 return [this._selectedExecutionContextPathComponent]; 136 if (this.selectedExecutionContextIdentifier === this._mainFrameExecutionContextPathComponent._executionContextIdentifier) 137 return [this._mainFrameExecutionContextPathComponent]; 138 139 return this._otherExecutionContextPathComponents.filter((component) => component._executionContextIdentifier === this.selectedExecutionContextIdentifier); 128 140 } 129 141 … … 148 160 149 161 if (shouldAutomaticallySelect) { 150 delete this._restoreSelectedExecutionContextForFrame; 151 this._selectedExecutionContextPathComponent = newExecutionContextPathComponent; 152 WebInspector.runtimeManager.defaultExecutionContextIdentifier = this.executionContextIdentifier; 153 this._rebuildExecutionContextPathComponents(); 162 this._restoreSelectedExecutionContextForFrame = null; 163 this.selectedExecutionContextIdentifier = newExecutionContextPathComponent._executionContextIdentifier; 154 164 } 155 165 } … … 157 167 _frameExecutionContextsCleared(event) 158 168 { 159 varframe = event.target;169 let frame = event.target; 160 170 161 171 // If this frame is navigating and it is selected in the UI we want to reselect its new item after navigation. 162 172 if (event.data.committingProvisionalLoad && !this._restoreSelectedExecutionContextForFrame) { 163 varexecutionContextPathComponent = this._frameIdentifierToExecutionContextPathComponentMap[frame.id];164 if ( this._selectedExecutionContextPathComponent === executionContextPathComponent) {173 let executionContextPathComponent = this._frameIdentifierToExecutionContextPathComponentMap[frame.id]; 174 if (executionContextPathComponent && executionContextPathComponent._executionContextIdentifier === this.selectedExecutionContextIdentifier) { 165 175 this._restoreSelectedExecutionContextForFrame = frame; 166 176 // As a fail safe, if the frame never gets an execution context, clear the restore value. 167 setTimeout( function() { delete this._restoreSelectedExecutionContextForFrame; }.bind(this), 10);177 setTimeout(() => { this._restoreSelectedExecutionContextForFrame = false; }, 10); 168 178 } 169 179 } 170 180 171 181 this._removeExecutionContextPathComponentForFrame(frame); 182 } 183 184 _defaultExecutionContextChanged(event) 185 { 186 this._rebuildExecutionContextPathComponents(); 172 187 } 173 188 … … 262 277 next.previousSibling = prev; 263 278 264 if (this._selectedExecutionContextPathComponent === executionContextPathComponent) {265 this._selectedExecutionContextPathComponent = this._mainFrameExecutionContextPathComponent;266 WebInspector.runtimeManager.defaultExecutionContextIdentifier = this.executionContextIdentifier;267 }268 269 279 this._otherExecutionContextPathComponents.remove(executionContextPathComponent, true); 270 280 delete this._frameIdentifierToExecutionContextPathComponentMap[frame.id]; … … 274 284 } 275 285 276 _updateExecutionContextPathComponentForFrame(frame)277 {278 if (frame.isMainFrame())279 return;280 281 var executionContextPathComponent = this._frameIdentifierToExecutionContextPathComponentMap[frame.id];282 if (!executionContextPathComponent)283 return;284 285 var wasSelected = this._selectedExecutionContextPathComponent === executionContextPathComponent;286 287 this._removeExecutionContextPathComponentForFrame(frame, true);288 var newExecutionContextPathComponent = this._insertExecutionContextPathComponentForFrame(frame, true);289 290 if (wasSelected) {291 this._selectedExecutionContextPathComponent = newExecutionContextPathComponent;292 WebInspector.runtimeManager.defaultExecutionContextIdentifier = this.executionContextIdentifier;293 }294 295 this._rebuildExecutionContextPathComponents();296 }297 298 286 _pathComponentSelected(event) 299 287 { 300 if (event.data.pathComponent === this._selectedExecutionContextPathComponent) 301 return; 302 303 this._selectedExecutionContextPathComponent = event.data.pathComponent; 304 WebInspector.runtimeManager.defaultExecutionContextIdentifier = this.executionContextIdentifier; 305 306 this._rebuildExecutionContextPathComponents(); 288 this.selectedExecutionContextIdentifier = event.data.pathComponent._executionContextIdentifier; 307 289 } 308 290
Note: See TracChangeset
for help on using the changeset viewer.