diff --git a/front_end/console/ConsoleView.js b/front_end/console/ConsoleView.js index 49694b80b9..bce3137a05 100644 --- a/front_end/console/ConsoleView.js +++ b/front_end/console/ConsoleView.js @@ -150,7 +150,6 @@ WebInspector.ConsoleView = function() this._registerWithMessageSink(); WebInspector.targetManager.observeTargets(this); - WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.MainFrameNavigated, this._onMainFrameNavigated, this); this._initConsoleMessages(); @@ -179,17 +178,6 @@ WebInspector.ConsoleView.prototype = { this._prompt.setAddCompletionsFromHistory(this._consoleHistoryAutocompleteSetting.get()); }, - /** - * @param {!WebInspector.Event} event - */ - _onMainFrameNavigated: function(event) - { - if (!WebInspector.moduleSetting("preserveConsoleLog").get()) - return; - var frame = /** @type {!WebInspector.ResourceTreeFrame} */(event.data); - WebInspector.console.log(WebInspector.UIString("Navigated to %s", frame.url)); - }, - _initConsoleMessages: function() { var mainTarget = WebInspector.targetManager.mainTarget(); diff --git a/front_end/console/module.json b/front_end/console/module.json index 0306e1f441..c511dccd1b 100644 --- a/front_end/console/module.json +++ b/front_end/console/module.json @@ -75,18 +75,6 @@ "settingType": "boolean", "defaultValue": false }, - { - "type": "setting", - "category": "Console", - "title": "Preserve log upon navigation", - "settingName": "preserveConsoleLog", - "settingType": "boolean", - "defaultValue": false, - "options": [ - { "value": true, "title": "Preserve log upon navigation" }, - { "value": false, "title": "Do not preserve log upon navigation" } - ] - }, { "type": "setting", "category": "Console", diff --git a/front_end/sdk/ConsoleModel.js b/front_end/sdk/ConsoleModel.js index 485b88899e..4dd24af5f8 100644 --- a/front_end/sdk/ConsoleModel.js +++ b/front_end/sdk/ConsoleModel.js @@ -82,6 +82,9 @@ WebInspector.ConsoleModel.prototype = { if (msg.source === WebInspector.ConsoleMessage.MessageSource.Worker && msg.target().workerManager && msg.target().workerManager.targetByWorkerId(msg.workerId)) return; + if (msg.source === WebInspector.ConsoleMessage.MessageSource.ConsoleAPI && msg.type === WebInspector.ConsoleMessage.MessageType.Clear) + this.clear(); + if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError && msg._revokedExceptionId) { var exceptionMessage = this._messageByExceptionId.get(msg._revokedExceptionId); if (!exceptionMessage) @@ -145,10 +148,10 @@ WebInspector.ConsoleModel.prototype = { requestClearMessages: function() { this._consoleAgent.clearMessages(); - this._messagesCleared(); + this.clear(); }, - _messagesCleared: function() + clear: function() { this._messages = []; this._messageByExceptionId.clear(); @@ -563,8 +566,6 @@ WebInspector.ConsoleDispatcher.prototype = { */ messagesCleared: function() { - if (!WebInspector.moduleSetting("preserveConsoleLog").get()) - this._console._messagesCleared(); } } diff --git a/front_end/sdk/ResourceTreeModel.js b/front_end/sdk/ResourceTreeModel.js index ee17408974..9d810da913 100644 --- a/front_end/sdk/ResourceTreeModel.js +++ b/front_end/sdk/ResourceTreeModel.js @@ -289,8 +289,13 @@ WebInspector.ResourceTreeModel.prototype = { this._inspectedPageURL = frame.url; this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frame); - if (frame.isMainFrame()) + if (frame.isMainFrame()) { this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame); + if (WebInspector.moduleSetting("preserveConsoleLog").get()) + WebInspector.console.log(WebInspector.UIString("Navigated to %s", frame.url)); + else + this.target().consoleModel.clear(); + } if (addedOrigin) this._addSecurityOrigin(addedOrigin); diff --git a/front_end/sdk/module.json b/front_end/sdk/module.json index cb90918b15..633ec024a4 100644 --- a/front_end/sdk/module.json +++ b/front_end/sdk/module.json @@ -23,6 +23,18 @@ "settingType": "boolean", "defaultValue": false }, + { + "type": "setting", + "category": "Console", + "title": "Preserve log upon navigation", + "settingName": "preserveConsoleLog", + "settingType": "boolean", + "defaultValue": false, + "options": [ + { "value": true, "title": "Preserve log upon navigation" }, + { "value": false, "title": "Do not preserve log upon navigation" } + ] + }, { "type": "setting", "category": "Debugger",