Commit bdd3ed44 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Do not perform logging for ChromeVox log page itself

This makes it so we don't output ChromeVox logs for the log page itself. This is a requirement for any user of ChromeVox to use this log page.

Test: manual
Change-Id: Ie453b5cfeab113b1a0cd9cc16af2e991758f9751
Reviewed-on: https://chromium-review.googlesource.com/c/1295489
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarYuki Awano <yawano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602530}
parent 2fdfbe94
......@@ -51,42 +51,16 @@ EventStreamLogger.prototype = {
this.node_.removeEventListener(eventType, this.watcher_, false);
},
/**
* @param {!AutomationNode} target
*/
isDescendantOfConsole: function(target) {
/** Event log should not be written when event is dispatched from console or
* chromevox log page.
*/
if (target.docUrl &&
(target.docUrl.indexOf('chrome-devtools://') == 0 ||
target.docUrl == chrome.runtime.getURL('cvox2/background/log.html')))
return true;
if (!target.parent)
return false;
return this.isDescendantOfConsole(target.parent);
},
/**
* @param {!AutomationEvent} evt
*/
eventStreamLogging: function(evt) {
/**
* If evt is dispatched to console, don't show.
* Console event log are unnecessary for developers.
*/
if (this.isDescendantOfConsole(evt.target))
return;
var logStr = 'EventType = ' + evt.type;
logStr += ', TargetName = ' + evt.target.name;
logStr += ', RootName = ' + evt.target.root.name;
logStr += ', DocumentURL = ' + evt.target.docUrl;
LogStore.getInstance().writeTextLog(logStr, TextLog.LogType.EVENT);
console.log(logStr);
},
/**
......
......@@ -160,6 +160,9 @@ LogStore.prototype.getLogs = function() {
* @param {!TextLog.LogType} logType
*/
LogStore.prototype.writeTextLog = function(logContent, logType) {
if (this.shouldSkipOutput_())
return;
var log = new TextLog(logContent, logType);
this.logs_[this.startIndex_] = log;
this.startIndex_ += 1;
......@@ -173,6 +176,9 @@ LogStore.prototype.writeTextLog = function(logContent, logType) {
* @param {!TreeDumper} logContent
*/
LogStore.prototype.writeTreeLog = function(logContent) {
if (this.shouldSkipOutput_())
return;
var log = new TreeLog(logContent);
this.logs_[this.startIndex_] = log;
this.startIndex_ += 1;
......@@ -189,6 +195,19 @@ LogStore.prototype.clearLog = function() {
this.startIndex_ = 0;
};
/** @private @return {boolean} */
LogStore.prototype.shouldSkipOutput_ = function() {
var ChromeVoxState = chrome.extension.getBackgroundPage()['ChromeVoxState'];
if (ChromeVoxState.instance.currentRange &&
ChromeVoxState.instance.currentRange.start &&
ChromeVoxState.instance.currentRange.start.node &&
ChromeVoxState.instance.currentRange.start.node.root) {
return ChromeVoxState.instance.currentRange.start.node.root.docUrl.indexOf(
chrome.extension.getURL('cvox2/background/log.html')) == 0;
}
return false;
};
/**
* Global instance.
* @type {LogStore}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment