* @implements {WebInspector.Searchable}
* @implements {WebInspector.TargetManager.Observer}
* @implements {WebInspector.ViewportControl.Provider}
- * @param {boolean} hideContextSelector
*/
-WebInspector.ConsoleView = function(hideContextSelector)
+WebInspector.ConsoleView = function()
{
WebInspector.VBox.call(this);
this.registerRequiredCSS("filter.css");
this._filter = new WebInspector.ConsoleViewFilter(this);
this._filter.addEventListener(WebInspector.ConsoleViewFilter.Events.FilterChanged, this._updateMessageList.bind(this));
- if (hideContextSelector)
- this._executionContextSelector.element.classList.add("hidden");
-
this._filterBar = new WebInspector.FilterBar();
this._preserveLogCheckbox = new WebInspector.StatusBarCheckbox(WebInspector.UIString("Preserve log"));
this._registerWithMessageSink();
WebInspector.targetManager.observeTargets(this);
- WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
- WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this);
- WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this);
WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
+ this._initConsoleMessages();
+
+ WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChangedExternally, this);
+}
+
+WebInspector.ConsoleView.prototype = {
+ _initConsoleMessages: function()
+ {
+ var mainTarget = WebInspector.targetManager.mainTarget();
+ if (!WebInspector.isWorkerFrontend() && (!mainTarget || !mainTarget.resourceTreeModel.cachedResourcesLoaded())) {
+ WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._onResourceTreeModelLoaded, this);
+ return;
+ }
+ this._fetchMultitargetMessages();
+ },
/**
- * @param {!WebInspector.ConsoleMessage} message
- * @this {WebInspector.ConsoleView}
+ * @param {!WebInspector.Event} event
*/
- function appendMessage(message)
+ _onResourceTreeModelLoaded: function(event)
{
- var viewMessage = this._createViewMessage(message);
- this._consoleMessageAdded(viewMessage);
- }
-
- WebInspector.multitargetConsoleModel.messages().forEach(appendMessage, this);
+ var resourceTreeModel = event.target;
+ if (resourceTreeModel.target() !== WebInspector.targetManager.mainTarget())
+ return;
+ WebInspector.targetManager.removeModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._onResourceTreeModelLoaded, this);
+ this._fetchMultitargetMessages();
+ },
- WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChangedExternally, this);
-}
+ _fetchMultitargetMessages: function()
+ {
+ WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
+ WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this);
+ WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this);
+ WebInspector.multitargetConsoleModel.messages().forEach(this._addConsoleMessage, this);
+ },
-WebInspector.ConsoleView.prototype = {
/**
* @return {number}
*/
if (executionContext.isMainWorldContext) {
if (executionContext.frameId) {
var frame = executionContext.target().resourceTreeModel.frameForId(executionContext.frameId);
- result = frame ? frame.displayName() : executionContext.name;
+ result = frame ? frame.displayName() : (executionContext.origin || executionContext.name);
} else {
- result = WebInspector.displayNameForURL(executionContext.name)
+ result = WebInspector.displayNameForURL(executionContext.origin) || executionContext.name;
}
} else
- result = "\u00a0\u00a0\u00a0\u00a0" + executionContext.name;
+ result = "\u00a0\u00a0\u00a0\u00a0" + (executionContext.name || executionContext.origin);
var maxLength = 50;
return result.trimMiddle(maxLength);
var newOption = document.createElement("option");
newOption.__executionContext = executionContext;
newOption.text = this._titleFor(executionContext);
- this._optionByExecutionContext.put(executionContext, newOption);
+ this._optionByExecutionContext.set(executionContext, newOption);
var sameGroupExists = false;
var options = this._executionContextSelector.selectElement().options;
var insertBeforeOption = null;
addMessage();
return;
}
-
var url;
+ var lineNumber;
+ var columnNumber;
var script = target.debuggerModel.scriptForId(response.location.scriptId);
- if (script && script.sourceURL)
+ if (script && script.sourceURL) {
url = script.sourceURL;
+ // FIXME(WK62725): Debugger line/column are 0-based, while console ones are 1-based.
+ lineNumber = response.location.lineNumber + 1;
+ columnNumber = response.location.columnNumber + 1;
+ }
// FIXME: this should be using live location.
- addMessage(url, response.location.lineNumber, response.location.columnNumber);
+ addMessage(url, lineNumber, columnNumber);
}
},