LayoutTests/ChangeLog

 12011-07-27 Yury Semikhatsky <yurys@chromium.org>
 2
 3 Inspector should support cd(window) in the command line
 4 https://bugs.webkit.org/show_bug.cgi?id=19872
 5
 6 Added a test for console evaluation in an iframe.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 * http/tests/inspector/console-cd-expected.txt: Added.
 11 * http/tests/inspector/console-cd.html: Added.
 12 * http/tests/inspector/resources/console-cd-iframe.html: Added.
 13
1142011-07-26 Sheriff Bot <webkit.review.bot@gmail.com>
215
316 Unreviewed, rolling out r91805.

LayoutTests/http/tests/inspector/console-cd-expected.txt

 1Tests that console evaluation can be performed in an iframe context.Bug 19872.
 2
 3
 4foo = 2011
 5

LayoutTests/http/tests/inspector/console-cd.html

 1<html>
 2<head>
 3<script src="console-test.js"></script>
 4<script src="inspector-test.js"></script>
 5
 6<script>
 7
 8function test()
 9{
 10 InspectorTest.showConsolePanel();
 11 var selector = WebInspector.console._contextSelectElement;
 12 var option = selector.firstChild;
 13 while (option) {
 14 if (option.textContent && option.textContent.indexOf("myIFrame") === 0)
 15 break;
 16 option = option.nextSibling;
 17 }
 18 if (!option) {
 19 InspectorTest.addResult("FAILED: myIFrame not found in the context list");
 20 InspectorTest.completeTest();
 21 return;
 22 }
 23 option.selected = true;
 24 InspectorTest.evaluateInConsoleAndDump("foo", finish);
 25 function finish()
 26 {
 27 InspectorTest.completeTest();
 28 }
 29}
 30
 31</script>
 32</head>
 33
 34<body>
 35<p>
 36Tests that console evaluation can be performed in an iframe context.<a href="https://bugs.webkit.org/show_bug.cgi?id=19872">Bug 19872.</a>
 37</p>
 38<iframe name="myIFrame" src="http://localhost:8000/inspector/resources/console-cd-iframe.html" onload="runTest()"></iframe>
 39
 40</body>
 41</html>

LayoutTests/http/tests/inspector/console-test.js

11var initialize_ConsoleTest = function() {
22
 3InspectorTest.showConsolePanel = function()
 4{
 5 WebInspector.showPanel("console");
 6 WebInspector.drawer.immediatelyFinishAnimation();
 7}
 8
39InspectorTest.dumpConsoleMessages = function()
410{
511 var result = [];

@@InspectorTest.expandConsoleMessages = function()
3844 }
3945}
4046
41 }
4247\ No newline at end of file
 48}

LayoutTests/http/tests/inspector/resources/console-cd-iframe.html

 1<script>
 2var foo = 2011;
 3</script>

Source/WebCore/ChangeLog

 12011-07-27 Yury Semikhatsky <yurys@chromium.org>
 2
 3 Inspector should support cd(window) in the command line
 4 https://bugs.webkit.org/show_bug.cgi?id=19872
 5
 6 Added dropdown list with all iframes to allow selecting current evaluation context for console expressions.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 Test: http/tests/inspector/console-cd.html
 11
 12 * WebCore.gypi:
 13 * inspector/Inspector.json:
 14 * inspector/InspectorController.cpp:
 15 (WebCore::InspectorController::InspectorController):
 16 * inspector/InspectorRuntimeAgent.cpp:
 17 (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
 18 (WebCore::InspectorRuntimeAgent::evaluate):
 19 * inspector/InspectorRuntimeAgent.h:
 20 * inspector/WorkerInspectorController.cpp:
 21 * inspector/front-end/ConsoleView.js:
 22 (WebInspector.ConsoleView.prototype.addContext):
 23 (WebInspector.ConsoleView.prototype.removeContext):
 24 (WebInspector.ConsoleView.prototype._contextUpdated):
 25 (WebInspector.ConsoleView.prototype.get _currentEvaluationContextId):
 26 (WebInspector.ConsoleView.prototype.evalInInspectedWindow):
 27 * inspector/front-end/ContextManager.js: Added.
 28 (WebInspector.ContextManager):
 29 (WebInspector.ContextManager.prototype._frameAdded):
 30 (WebInspector.ContextManager.prototype._frameNavigated):
 31 (WebInspector.ContextManager.prototype._frameDetached):
 32 (WebInspector.FrameEvaluationContext):
 33 (WebInspector.FrameEvaluationContext.prototype._frameNavigated):
 34 (WebInspector.FrameEvaluationContext.prototype.get id):
 35 (WebInspector.FrameEvaluationContext.prototype.get url):
 36 (WebInspector.FrameEvaluationContext.prototype.get displayName):
 37 * inspector/front-end/ResourceTreeModel.js:
 38 (WebInspector.ResourceTreeModel.prototype._cleanupFramesAfterNavigation):
 39 (WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
 40 * inspector/front-end/WebKit.qrc:
 41 * inspector/front-end/inspector.html:
 42 * inspector/front-end/inspector.js:
 43
1442011-07-26 James Robinson <jamesr@chromium.org>
245
346 [chromium] REGRESSION(90963): Content layers are not redrawn after losing the compositor context

Source/WebCore/WebCore.gypi

63216321 'inspector/front-end/Color.js',
63226322 'inspector/front-end/ConsolePanel.js',
63236323 'inspector/front-end/ConsoleView.js',
 6324 'inspector/front-end/JavaScriptContextManager.js',
63246325 'inspector/front-end/ContextMenu.js',
63256326 'inspector/front-end/CookieItemsView.js',
63266327 'inspector/front-end/CookieParser.js',

Source/WebCore/inspector/Inspector.json

262262 { "name": "expression", "type": "string", "description": "Expression to evaluate." },
263263 { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
264264 { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." },
265  { "name": "doNotPauseOnExceptions", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions. Overrides setPauseOnException state." }
 265 { "name": "doNotPauseOnExceptions", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions. Overrides setPauseOnException state." },
 266 { "name": "frameId", "type": "string", "optional": true, "description": "Specifies in which frame to perform evaluation." }
266267 ],
267268 "returns": [
268269 { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },

Source/WebCore/inspector/InspectorController.cpp

@@namespace {
7272
7373class PageRuntimeAgent : public InspectorRuntimeAgent {
7474public:
75  PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* page)
76  : InspectorRuntimeAgent(injectedScriptManager)
 75 PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent)
 76 : InspectorRuntimeAgent(injectedScriptManager, pageAgent)
7777 , m_inspectedPage(page) { }
7878 virtual ~PageRuntimeAgent() { }
7979

@@InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
103103 , m_applicationCacheAgent(adoptPtr(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page)))
104104#endif
105105 , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), inspectorClient, m_state.get()))
106  , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_injectedScriptManager.get(), page)))
 106 , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_injectedScriptManager.get(), page, m_pageAgent.get())))
107107 , m_consoleAgent(adoptPtr(new InspectorConsoleAgent(m_instrumentingAgents.get(), m_inspectorAgent.get(), m_state.get(), m_injectedScriptManager.get(), m_domAgent.get())))
108108#if ENABLE(JAVASCRIPT_DEBUGGER)
109109 , m_debuggerAgent(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()))

Source/WebCore/inspector/InspectorRuntimeAgent.cpp

3535
3636#include "InjectedScript.h"
3737#include "InjectedScriptManager.h"
 38#include "InspectorPageAgent.h"
3839#include "InspectorValues.h"
3940#include <wtf/PassRefPtr.h>
4041

4546
4647namespace WebCore {
4748
48 InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager)
 49InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager, InspectorPageAgent* pageAgent)
4950 : m_injectedScriptManager(injectedScriptManager)
5051#if ENABLE(JAVASCRIPT_DEBUGGER)
5152 , m_scriptDebugServer(0)
5253#endif
 54 , m_pageAgent(pageAgent)
5355{
5456}
5557

@@InspectorRuntimeAgent::~InspectorRuntimeAgent()
5759{
5860}
5961
60 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, RefPtr<InspectorObject>* result, bool* wasThrown)
 62void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, RefPtr<InspectorObject>* result, bool* wasThrown)
6163{
62  InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(getDefaultInspectedState());
 64 ScriptState* scriptState = 0;
 65 if (frameId) {
 66 if (!m_pageAgent) {
 67 *errorString = "No page agent available";
 68 return;
 69 }
 70 Frame* frame = m_pageAgent->frameForId(*frameId);
 71 if (!frame) {
 72 *errorString = "Frame not found";
 73 return;
 74 }
 75 scriptState = mainWorldScriptState(frame);
 76 } else
 77 scriptState = getDefaultInspectedState();
 78 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
6379 if (injectedScript.hasNoValue()) {
6480 *errorString = "Inspected frame has gone";
6581 return;

Source/WebCore/inspector/InspectorRuntimeAgent.h

@@namespace WebCore {
4242class InjectedScriptManager;
4343class InspectorArray;
4444class InspectorObject;
 45class InspectorPageAgent;
4546class InspectorValue;
4647class ScriptDebugServer;
4748

@@public:
5354 virtual ~InspectorRuntimeAgent();
5455
5556 // Part of the protocol.
56  void evaluate(ErrorString*, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, RefPtr<InspectorObject>* result, bool* wasThrown);
 57 void evaluate(ErrorString*, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, RefPtr<InspectorObject>* result, bool* wasThrown);
5758 void callFunctionOn(ErrorString*, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown);
5859 void releaseObject(ErrorString*, const String& objectId);
5960 void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);

@@public:
6465#endif
6566
6667protected:
67  explicit InspectorRuntimeAgent(InjectedScriptManager*);
 68 InspectorRuntimeAgent(InjectedScriptManager*, InspectorPageAgent*);
6869 virtual ScriptState* getDefaultInspectedState() = 0;
6970
7071private:

@@private:
7273#if ENABLE(JAVASCRIPT_DEBUGGER)
7374 ScriptDebugServer* m_scriptDebugServer;
7475#endif
 76 InspectorPageAgent* m_pageAgent;
7577};
7678
7779} // namespace WebCore

Source/WebCore/inspector/WorkerInspectorController.cpp

@@namespace {
5656class WorkerRuntimeAgent : public InspectorRuntimeAgent {
5757public:
5858 WorkerRuntimeAgent(InjectedScriptManager* injectedScriptManager, WorkerContext* workerContext)
59  : InspectorRuntimeAgent(injectedScriptManager)
 59 : InspectorRuntimeAgent(injectedScriptManager, 0)
6060 , m_workerContext(workerContext) { }
6161 virtual ~WorkerRuntimeAgent() { }
6262

Source/WebCore/inspector/front-end/ConsoleView.js

@@WebInspector.ConsoleView = function(drawer)
4040 this.clearButton.title = WebInspector.UIString("Clear console log.");
4141 this.clearButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
4242
 43 this._contextSelectElement = document.getElementById("console-context");
 44 if (WebInspector.WorkerManager.isWorkerFrontend())
 45 this._contextSelectElement.addStyleClass("hidden");
 46
4347 this.messagesElement = document.getElementById("console-messages");
4448 this.messagesElement.addEventListener("selectstart", this._messagesSelectStart.bind(this), false);
4549 this.messagesElement.addEventListener("click", this._messagesClicked.bind(this), true);

@@WebInspector.ConsoleView.prototype = {
164168 }
165169 },
166170
 171 addContext: function(context)
 172 {
 173 var option = document.createElement("option");
 174 option.text = context.displayName;
 175 option.title = context.url;
 176 option._context = context;
 177 context._consoleOption = option;
 178 this._contextSelectElement.appendChild(option);
 179 context.addEventListener(WebInspector.FrameEvaluationContext.EventTypes.Updated, this._contextUpdated, this);
 180 },
 181
 182 removeContext: function(context)
 183 {
 184 this._contextSelectElement.removeChild(context._consoleOption);
 185 },
 186
 187 _contextUpdated: function(event)
 188 {
 189 var context = event.data;
 190 var option= context._consoleOption;
 191 option.text = context.displayName;
 192 option.title = context.url;
 193 },
 194
 195 _currentEvaluationContextId: function()
 196 {
 197 if (this._contextSelectElement.selectedIndex === -1)
 198 return undefined;
 199 return this._contextSelectElement[this._contextSelectElement.selectedIndex]._context.frameId;
 200 },
 201
167202 _updateFilter: function(e)
168203 {
169204 var isMac = WebInspector.isMac();

@@WebInspector.ConsoleView.prototype = {
577612 if (!error)
578613 callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
579614 }
580  RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, evalCallback);
 615 RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, this._currentEvaluationContextId(), evalCallback);
581616 },
582617
583618 _enterKeyPressed: function(event)

Source/WebCore/inspector/front-end/JavaScriptContextManager.js

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31WebInspector.JavaScriptContextManager = function(resourceTreeModel, consoleView)
 32{
 33 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
 34 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
 35 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
 36 this._consoleView = consoleView;
 37 this._frameIdToContext = {};
 38}
 39
 40WebInspector.JavaScriptContextManager.prototype = {
 41 _frameAdded: function(event)
 42 {
 43 var frame = event.data;
 44 var parentFrameId = frame.parentId;
 45 var context = new WebInspector.FrameEvaluationContext(frame);
 46 this._frameIdToContext[frame.id] = context;
 47 this._consoleView.addContext(context);
 48 },
 49
 50 _frameNavigated: function(event)
 51 {
 52 var frame = event.data.frame;
 53 var context = this._frameIdToContext[frame.id];
 54 if (context)
 55 context._frameNavigated(frame);
 56 },
 57
 58 _frameDetached: function(event)
 59 {
 60 var frameId = event.data;
 61 var context = this._frameIdToContext[frameId];
 62 this._consoleView.removeContext(context);
 63 delete this._frameIdToContext[frameId];
 64 },
 65}
 66
 67WebInspector.JavaScriptContextManager.prototype.__proto__ = WebInspector.Object.prototype;
 68
 69WebInspector.FrameEvaluationContext = function(frame)
 70{
 71 this._frame = frame;
 72}
 73
 74WebInspector.FrameEvaluationContext.EventTypes = {
 75 Updated: "updated"
 76}
 77
 78WebInspector.FrameEvaluationContext.prototype =
 79{
 80 _frameNavigated: function(frame)
 81 {
 82 this._frame = frame;
 83 this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.Updated, this);
 84 },
 85
 86 get frameId()
 87 {
 88 return this._frame.id
 89 },
 90
 91 get url()
 92 {
 93 return this._frame.url;
 94 },
 95
 96 get displayName()
 97 {
 98 if (!this._frame.parentId)
 99 return "<top frame>";
 100 var name = this._frame.name || "";
 101 var subtitle = new WebInspector.Resource(null, this._frame.url).displayName;
 102 if (subtitle) {
 103 if (!name)
 104 return subtitle;
 105 return name + "( " + subtitle + " )";
 106 }
 107 return "<iframe>";
 108 }
 109}
 110
 111WebInspector.FrameEvaluationContext.prototype.__proto__ = WebInspector.Object.prototype;

Source/WebCore/inspector/front-end/ResourceTreeModel.js

@@WebInspector.ResourceTreeModel.prototype = {
152152
153153 _cleanupFramesAfterNavigation: function(newMainFrame)
154154 {
155  for (var frameId in this._frameIds) {
156  if (frameId !== newMainFrame.id)
157  this._frameDetached(frameId);
158  }
 155 if (this._currentMainFrameId)
 156 this._frameDetached(this._currentMainFrameId);
 157 this._currentMainFrameId = newMainFrame.id;
159158 },
160159
161160 _frameDetached: function(frameId)

@@WebInspector.ResourceTreeModel.prototype = {
323322 frameResource.type = WebInspector.Resource.Type.Document;
324323 frameResource.finished = true;
325324
326  if (!framePayload.parentId)
 325 if (!framePayload.parentId) {
327326 WebInspector.mainResource = frameResource;
 327 this._currentMainFrameId = framePayload.id;
 328 }
328329 this._addFrame(framePayload);
329330 this._addResourceToFrame(frameResource);
330331

Source/WebCore/inspector/front-end/WebKit.qrc

1616 <file>Color.js</file>
1717 <file>ConsolePanel.js</file>
1818 <file>ConsoleView.js</file>
 19 <file>JavaScriptContextManager.js</file>
1920 <file>ContextMenu.js</file>
2021 <file>CookieItemsView.js</file>
2122 <file>CookieParser.js</file>

Source/WebCore/inspector/front-end/inspector.html

@@THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
170170 <script type="text/javascript" src="SearchController.js"></script>
171171 <script type="text/javascript" src="WorkerManager.js"></script>
172172 <script type="text/javascript" src="UserMetrics.js"></script>
 173 <script type="text/javascript" src="JavaScriptContextManager.js"></script>
173174</head>
174175<body class="detached">
175176 <div id="toolbar">

@@THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
187188 </div>
188189 <div id="drawer">
189190 <div id="console-view"><div id="console-messages" class="monospace"><div id="console-prompt" spellcheck="false"><br></div></div></div>
190  <div id="drawer-status-bar" class="status-bar"><div id="other-drawer-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item clear-status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><div id="console-filter" class="scope-bar status-bar-item"></div></div></div>
 191 <div id="drawer-status-bar" class="status-bar"><div id="other-drawer-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item clear-status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><select id="console-context" class="status-bar-item"></select><div id="console-filter" class="scope-bar status-bar-item"></div></div></div>
191192 </div>
192193</body>
193194</html>

Source/WebCore/inspector/front-end/inspector.js

@@WebInspector.doLoadedDone = function()
502502 this.resourceTreeModel = new WebInspector.ResourceTreeModel();
503503 this.networkLog = new WebInspector.NetworkLog();
504504 this.domAgent = new WebInspector.DOMAgent();
 505 new WebInspector.JavaScriptContextManager(this.resourceTreeModel, this.console);
505506
506507 InspectorBackend.registerDomainDispatcher("Inspector", this);
507508