summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/js')
-rw-r--r--WebKit/chromium/src/js/DebuggerAgent.js72
-rw-r--r--WebKit/chromium/src/js/DebuggerScript.js46
-rw-r--r--WebKit/chromium/src/js/DevTools.js71
-rw-r--r--WebKit/chromium/src/js/DevToolsHostStub.js4
-rw-r--r--WebKit/chromium/src/js/InspectorControllerImpl.js21
-rw-r--r--WebKit/chromium/src/js/Tests.js4
-rwxr-xr-xWebKit/chromium/src/js/devTools.css4
7 files changed, 132 insertions, 90 deletions
diff --git a/WebKit/chromium/src/js/DebuggerAgent.js b/WebKit/chromium/src/js/DebuggerAgent.js
index 67e54aa..8d2457f 100644
--- a/WebKit/chromium/src/js/DebuggerAgent.js
+++ b/WebKit/chromium/src/js/DebuggerAgent.js
@@ -181,7 +181,7 @@ devtools.DebuggerAgent.prototype.initUI = function()
// pending addition into the UI.
for (var scriptId in this.parsedScripts_) {
var script = this.parsedScripts_[scriptId];
- WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1);
+ WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1, script.worldType());
this.restoreBreakpoints_(scriptId, script.getUrl());
}
return;
@@ -307,7 +307,7 @@ devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line, enable
/**
- * Changes given line of the script.
+ * Changes given line of the script.
*/
devtools.DebuggerAgent.prototype.editScriptSource = function(sourceId, newContent, callback)
{
@@ -319,12 +319,31 @@ devtools.DebuggerAgent.prototype.editScriptSource = function(sourceId, newConten
var cmd = new devtools.DebugCommand("changelive", commandArguments);
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
- if (!msg.isSuccess())
- WebInspector.log("Unable to modify source code within given scope. Only function bodies are editable at the moment.", WebInspector.ConsoleMessage.MessageLevel.Warning);
- this.resolveScriptSource(sourceId, callback);
- if (WebInspector.panels.scripts.paused)
- this.requestBacktrace_();
+ if (!msg.isSuccess()) {
+ callback(false, "Unable to modify source code within given scope. Only function bodies are editable at the moment.", null);
+ return;
+ }
+
+ this.resolveScriptSource(sourceId, requestBacktrace.bind(this));
}.bind(this);
+
+
+ function requestBacktrace(newScriptSource) {
+ if (WebInspector.panels.scripts.paused)
+ this.requestBacktrace_(handleBacktraceResponse.bind(this, newScriptSource));
+ else
+ reportDidCommitEditing(newScriptSource);
+ }
+
+ function handleBacktraceResponse(newScriptSource, msg) {
+ this.updateCallFramesFromBacktraceResponse_(msg);
+ reportDidCommitEditing(newScriptSource, this.callFrames_);
+ }
+
+ function reportDidCommitEditing(newScriptSource, callFrames) {
+ callback(true, newScriptSource, callFrames);
+ }
+
RemoteDebuggerAgent.processDebugCommands();
};
@@ -679,12 +698,14 @@ devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function(breakpointId
/**
* Sends "backtrace" request to v8.
*/
-devtools.DebuggerAgent.prototype.requestBacktrace_ = function()
+devtools.DebuggerAgent.prototype.requestBacktrace_ = function(opt_customHandler)
{
var cmd = new devtools.DebugCommand("backtrace", {
"compactFormat":true
});
devtools.DebuggerAgent.sendCommand_(cmd);
+ var responseHandler = opt_customHandler ? opt_customHandler : this.handleBacktraceResponse_.bind(this);
+ this.requestSeqToCallback_[cmd.getSequenceNumber()] = responseHandler;
};
@@ -800,7 +821,7 @@ devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output)
else if (msg.getCommand() === "clearbreakpoint")
this.handleClearBreakpointResponse_(msg);
else if (msg.getCommand() === "backtrace")
- this.handleBacktraceResponse_(msg);
+ this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "lookup")
this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "evaluate")
@@ -948,17 +969,17 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg)
devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script, msg)
{
var context = msg.lookup(script.context.ref);
- var contextType;
// Find the type from context data. The context data has the format
// "type,id".
var comma = context.data.indexOf(",");
if (comma < 0)
- return
- contextType = context.data.substring(0, comma);
- this.parsedScripts_[script.id] = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType);
+ return;
+ var contextType = context.data.substring(0, comma);
+ var info = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType);
+ this.parsedScripts_[script.id] = info;
if (this.scriptsPanelInitialized_) {
// Only report script as parsed after scripts panel has been shown.
- WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1);
+ WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1, info.worldType());
this.restoreBreakpoints_(script.id, script.name);
}
};
@@ -991,13 +1012,20 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg)
*/
devtools.DebuggerAgent.prototype.doHandleBacktraceResponse_ = function(msg)
{
+ this.updateCallFramesFromBacktraceResponse_(msg);
+ WebInspector.pausedScript(this.callFrames_);
+ this.showPendingExceptionMessage_();
+ InspectorFrontendHost.bringToFront();
+};
+
+
+devtools.DebuggerAgent.prototype.updateCallFramesFromBacktraceResponse_ = function(msg)
+{
var frames = msg.getBody().frames;
this.callFrames_ = [];
for (var i = 0; i < frames.length; ++i)
this.callFrames_.push(this.formatCallFrame_(frames[i]));
- WebInspector.pausedScript(this.callFrames_);
- this.showPendingExceptionMessage_();
- InspectorFrontendHost.bringToFront();
+ return this.callFrames_;
};
@@ -1044,7 +1072,7 @@ devtools.DebuggerAgent.prototype.formatCallFrame_ = function(stackFrame)
var existingScript = this.parsedScripts_[sourceId];
if (!existingScript) {
this.parsedScripts_[sourceId] = new devtools.ScriptInfo(sourceId, null /* name */, 0 /* line */, "unknown" /* type */, true /* unresolved */);
- WebInspector.parsedScriptSource(sourceId, null, null, 0);
+ WebInspector.parsedScriptSource(sourceId, null, null, 0, WebInspector.Script.WorldType.MAIN_WORLD);
}
var funcName = func.name || func.inferredName || "(anonymous function)";
@@ -1257,6 +1285,14 @@ devtools.ScriptInfo.prototype.isUnresolved = function()
};
+devtools.ScriptInfo.prototype.worldType = function()
+{
+ if (this.contextType_ === "injected")
+ return WebInspector.Script.WorldType.EXTENSIONS_WORLD;
+ return WebInspector.Script.WorldType.MAIN_WORLD;
+};
+
+
/**
* @param {number} line 0-based line number in the script.
* @return {?devtools.BreakpointInfo} Information on a breakpoint at the
diff --git a/WebKit/chromium/src/js/DebuggerScript.js b/WebKit/chromium/src/js/DebuggerScript.js
index 7e5b430..3ff3eb7 100644
--- a/WebKit/chromium/src/js/DebuggerScript.js
+++ b/WebKit/chromium/src/js/DebuggerScript.js
@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-function debuggerScriptConstructor() {
+(function () {
var DebuggerScript = {};
DebuggerScript._breakpoints = {};
@@ -39,6 +39,11 @@ DebuggerScript.PauseOnExceptionsState = {
PauseOnUncaughtExceptions: 2
};
+DebuggerScript.ScriptWorldType = {
+ MainWorld : 0,
+ ExtensionsWorld : 1
+};
+
DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
Debug.clearBreakOnException();
Debug.clearBreakOnUncaughtException();
@@ -50,11 +55,21 @@ DebuggerScript.getAfterCompileScript = function(eventData)
DebuggerScript.getScripts = function(contextData)
{
- var scripts = Debug.scripts();
var result = [];
+
+ if (!contextData)
+ return result;
+ var comma = contextData.indexOf(",");
+ if (comma === -1)
+ return result;
+ // Context data is a string in the following format:
+ // ("page"|"injected")","<page id>
+ var idSuffix = contextData.substring(comma); // including the comma
+
+ var scripts = Debug.scripts();
for (var i = 0; i < scripts.length; ++i) {
var script = scripts[i];
- if (contextData === script.context_data)
+ if (script.context_data && script.context_data.lastIndexOf(idSuffix) != -1)
result.push(DebuggerScript._formatScript(script));
}
return result;
@@ -62,13 +77,16 @@ DebuggerScript.getScripts = function(contextData)
DebuggerScript._formatScript = function(script)
{
+ var scriptWorldType = DebuggerScript.ScriptWorldType.MainWorld;
+ if (script.context_data && script.context_data.indexOf("injected") == 0)
+ scriptWorldType = DebuggerScript.ScriptWorldType.ExtensionsWorld;
return {
id: script.id,
name: script.name,
source: script.source,
lineOffset: script.line_offset,
lineCount: script.lineCount(),
- contextData: script.context_data
+ scriptWorldType: scriptWorldType
};
}
@@ -152,6 +170,24 @@ DebuggerScript.stepOutOfFunction = function(execState)
execState.prepareStep(Debug.StepAction.StepOut, 1);
}
+DebuggerScript.editScriptSource = function(scriptId, newSource)
+{
+ var scripts = Debug.scripts();
+ var scriptToEdit = null;
+ for (var i = 0; i < scripts.length; i++) {
+ if (scripts[i].id == scriptId) {
+ scriptToEdit = scripts[i];
+ break;
+ }
+ }
+ if (!scriptToEdit)
+ throw("Script not found");
+
+ var changeLog = [];
+ Debug.LiveEdit.SetScriptSource(scriptToEdit, newSource, changeLog);
+ return scriptToEdit.source;
+}
+
DebuggerScript.clearBreakpoints = function(execState, args)
{
for (var key in DebuggerScript._breakpoints) {
@@ -239,4 +275,4 @@ DebuggerScript._v8ToWebkitLineNumber = function(line)
return DebuggerScript;
-}
+})();
diff --git a/WebKit/chromium/src/js/DevTools.js b/WebKit/chromium/src/js/DevTools.js
index 6e9c090..398d358 100644
--- a/WebKit/chromium/src/js/DevTools.js
+++ b/WebKit/chromium/src/js/DevTools.js
@@ -183,8 +183,8 @@ WebInspector.loaded = function()
Preferences.heapProfilerPresent = true;
Preferences.debuggerAlwaysEnabled = true;
Preferences.profilerAlwaysEnabled = true;
- RemoteDebuggerAgent.setDebuggerScriptSource("(" + debuggerScriptConstructor + ")();");
-
+ Preferences.canEditScriptSource = true;
+
oldLoaded.call(this);
InspectorFrontendHost.loaded();
@@ -210,42 +210,6 @@ document.addEventListener("DOMContentLoaded", devtools.domContentLoaded, false);
if (!window.v8ScriptDebugServerEnabled) {
-/**
- * This override is necessary for adding script source asynchronously.
- * @override
- */
-WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function()
-{
- if (!this._frameNeedsSetup)
- return;
-
- this.attach();
-
- if (this.script.source)
- this.didResolveScriptSource_();
- else {
- var self = this;
- devtools.tools.getDebuggerAgent().resolveScriptSource(
- this.script.sourceID,
- function(source) {
- self.script.source = source || WebInspector.UIString("<source is not available>");
- self.didResolveScriptSource_();
- });
- }
-};
-
-
-/**
- * Performs source frame setup when script source is aready resolved.
- */
-WebInspector.ScriptView.prototype.didResolveScriptSource_ = function()
-{
- this.sourceFrame.setContent("text/javascript", this._prependWhitespace(this.script.source));
- this._sourceFrameSetup = true;
- delete this._frameNeedsSetup;
-};
-
-
(function()
{
var oldShow = WebInspector.ScriptsPanel.prototype.show;
@@ -296,6 +260,21 @@ InjectedScriptAccess.prototype.getCompletions = function(expressionString, inclu
};
})();
+// Highlight extension content scripts in the scripts list.
+(function () {
+ var original = WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu;
+ WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu = function(script)
+ {
+ var result = original.apply(this, arguments);
+ var debuggerAgent = devtools.tools.getDebuggerAgent();
+ var type = debuggerAgent.getScriptContextType(script.sourceID);
+ var option = script.filesSelectOption;
+ if (type === "injected" && option)
+ option.addStyleClass("injected");
+ return result;
+ };
+})();
+
}
@@ -349,22 +328,6 @@ WebInspector.UIString = function(string)
})();
-// Highlight extension content scripts in the scripts list.
-(function () {
- var original = WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu;
- WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu = function(script)
- {
- var result = original.apply(this, arguments);
- var debuggerAgent = devtools.tools.getDebuggerAgent();
- var type = debuggerAgent.getScriptContextType(script.sourceID);
- var option = script.filesSelectOption;
- if (type === "injected" && option)
- option.addStyleClass("injected");
- return result;
- };
-})();
-
-
/** Pending WebKit upstream by apavlov). Fixes iframe vs drag problem. */
(function()
{
diff --git a/WebKit/chromium/src/js/DevToolsHostStub.js b/WebKit/chromium/src/js/DevToolsHostStub.js
index cae4a1e..da5929a 100644
--- a/WebKit/chromium/src/js/DevToolsHostStub.js
+++ b/WebKit/chromium/src/js/DevToolsHostStub.js
@@ -55,10 +55,6 @@ RemoteDebuggerAgentStub.prototype.processDebugCommands = function()
};
-RemoteDebuggerAgentStub.prototype.setDebuggerScriptSource = function(source)
-{
-};
-
/**
* @constructor
diff --git a/WebKit/chromium/src/js/InspectorControllerImpl.js b/WebKit/chromium/src/js/InspectorControllerImpl.js
index 86f885a..327ca8f 100644
--- a/WebKit/chromium/src/js/InspectorControllerImpl.js
+++ b/WebKit/chromium/src/js/InspectorControllerImpl.js
@@ -61,13 +61,16 @@ devtools.InspectorBackendImpl = function()
this.installInspectorControllerDelegate_("getResourceContent");
this.installInspectorControllerDelegate_("highlightDOMNode");
this.installInspectorControllerDelegate_("hideDOMNodeHighlight");
+ this.installInspectorControllerDelegate_("performSearch");
this.installInspectorControllerDelegate_("releaseWrapperObjectGroup");
this.installInspectorControllerDelegate_("removeAllScriptsToEvaluateOnLoad");
this.installInspectorControllerDelegate_("reloadPage");
this.installInspectorControllerDelegate_("removeAttribute");
this.installInspectorControllerDelegate_("removeDOMStorageItem");
this.installInspectorControllerDelegate_("removeNode");
- this.installInspectorControllerDelegate_("saveFrontendSettings");
+ this.installInspectorControllerDelegate_("saveApplicationSettings");
+ this.installInspectorControllerDelegate_("saveSessionSettings");
+ this.installInspectorControllerDelegate_("searchCanceled");
this.installInspectorControllerDelegate_("setAttribute");
this.installInspectorControllerDelegate_("setDOMStorageItem");
this.installInspectorControllerDelegate_("setInjectedScriptSource");
@@ -93,6 +96,8 @@ devtools.InspectorBackendImpl = function()
if (window.v8ScriptDebugServerEnabled) {
this.installInspectorControllerDelegate_("disableDebugger");
+ this.installInspectorControllerDelegate_("editScriptSource");
+ this.installInspectorControllerDelegate_("getScriptSource");
this.installInspectorControllerDelegate_("enableDebugger");
this.installInspectorControllerDelegate_("setBreakpoint");
this.installInspectorControllerDelegate_("removeBreakpoint");
@@ -143,12 +148,22 @@ devtools.InspectorBackendImpl.prototype.removeBreakpoint = function(sourceID, li
devtools.InspectorBackendImpl.prototype.editScriptSource = function(callID, sourceID, newContent)
{
- devtools.tools.getDebuggerAgent().editScriptSource(sourceID, newContent, function(newFullBody) {
- WebInspector.didEditScriptSource(callID, newFullBody);
+ devtools.tools.getDebuggerAgent().editScriptSource(sourceID, newContent, function(success, newBodyOrErrorMessage, callFrames) {
+ WebInspector.didEditScriptSource(callID, success, newBodyOrErrorMessage, callFrames);
});
};
+devtools.InspectorBackendImpl.prototype.getScriptSource = function(callID, sourceID)
+{
+ devtools.tools.getDebuggerAgent().resolveScriptSource(
+ sourceID,
+ function(source) {
+ WebInspector.didGetScriptSource(callID, source);
+ });
+};
+
+
devtools.InspectorBackendImpl.prototype.activateBreakpoints = function()
{
devtools.tools.getDebuggerAgent().setBreakpointsActivated(true);
diff --git a/WebKit/chromium/src/js/Tests.js b/WebKit/chromium/src/js/Tests.js
index 758b8c0..fa910ab 100644
--- a/WebKit/chromium/src/js/Tests.js
+++ b/WebKit/chromium/src/js/Tests.js
@@ -1279,8 +1279,8 @@ TestSuite.prototype.testStepIn = function()
},
{
functionsOnStack: ["fact","d","a","(anonymous function)"],
- lineNumber: 15,
- lineText: " return r;"
+ lineNumber: 10,
+ lineText: " var r = 1;"
},
function() {
test.releaseControl();
diff --git a/WebKit/chromium/src/js/devTools.css b/WebKit/chromium/src/js/devTools.css
index 2cb4ab3..0e6d284 100755
--- a/WebKit/chromium/src/js/devTools.css
+++ b/WebKit/chromium/src/js/devTools.css
@@ -1,7 +1,3 @@
-#scripts-files option.injected {
- color: rgb(70, 134, 240);
-}
-
.data-grid table {
line-height: 120%;
}