Output log more safely #1067
This commit is contained in:
parent
f5198c31aa
commit
1126c9f211
@ -302,7 +302,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
|||||||
let treeStructure = result.behavior & this.kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE ?
|
let treeStructure = result.behavior & this.kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE ?
|
||||||
null :
|
null :
|
||||||
this.getTreeStructureFromItems(aIDs) ;
|
this.getTreeStructureFromItems(aIDs) ;
|
||||||
log(' treeStructure => '+JSON.stringify(treeStructure));
|
log(' treeStructure => ', treeStructure);
|
||||||
if (treeStructure) {
|
if (treeStructure) {
|
||||||
let parentTabs = treeStructure.filter(function(aParent) {
|
let parentTabs = treeStructure.filter(function(aParent) {
|
||||||
return aParent < 0;
|
return aParent < 0;
|
||||||
@ -340,7 +340,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
|||||||
title: aFolderTitle,
|
title: aFolderTitle,
|
||||||
uri: uri
|
uri: uri
|
||||||
})
|
})
|
||||||
log(' updated treeStructure => '+JSON.stringify(treeStructure));
|
log(' updated treeStructure => ', treeStructure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!haveMultipleTrees) {
|
else if (!haveMultipleTrees) {
|
||||||
@ -428,7 +428,7 @@ PlacesUIUtils._openTabset = function(aItemsToOpen, aEvent, aWindow, ...aArgs) {
|
|||||||
return this.__treestyletab__openTabset.apply(this, allArgs);
|
return this.__treestyletab__openTabset.apply(this, allArgs);
|
||||||
|
|
||||||
var result = BS.handleTabsOpenProcess(where, aEvent, w, ids, uris, aItemsToOpen, this.__treestyletab__folderName);
|
var result = BS.handleTabsOpenProcess(where, aEvent, w, ids, uris, aItemsToOpen, this.__treestyletab__folderName);
|
||||||
log(' result: '+JSON.stringify(result));
|
log(' result: ', result);
|
||||||
|
|
||||||
var tabs = TST.doAndGetNewTabs((function() {
|
var tabs = TST.doAndGetNewTabs((function() {
|
||||||
this.__treestyletab__openTabset.apply(this, allArgs);
|
this.__treestyletab__openTabset.apply(this, allArgs);
|
||||||
|
@ -3436,7 +3436,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
var closeParentBehavior = this.getCloseParentBehaviorForTab(tab);
|
var closeParentBehavior = this.getCloseParentBehaviorForTab(tab);
|
||||||
|
|
||||||
var backupAttributes = this._collectBackupAttributes(tab);
|
var backupAttributes = this._collectBackupAttributes(tab);
|
||||||
log('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes));
|
log('onTabClose: backupAttributes = ', backupAttributes);
|
||||||
|
|
||||||
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
||||||
this.isSubtreeCollapsed(tab))
|
this.isSubtreeCollapsed(tab))
|
||||||
|
@ -97,7 +97,7 @@ FullscreenObserver.prototype = {
|
|||||||
|
|
||||||
onSizeModeChange : function FullscreenObserver_onSizeModeChange()
|
onSizeModeChange : function FullscreenObserver_onSizeModeChange()
|
||||||
{
|
{
|
||||||
log('onSizeModeChange: '+this.window.document.documentElement.getAttribute('sizemode'));
|
log('onSizeModeChange: ', this.window.document.documentElement.getAttribute('sizemode'));
|
||||||
this.updateToolboxPosition();
|
this.updateToolboxPosition();
|
||||||
if (!this.window.gBrowser.treeStyleTab.notifyingRenderedEvent)
|
if (!this.window.gBrowser.treeStyleTab.notifyingRenderedEvent)
|
||||||
this.window.gBrowser.treeStyleTab.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
|
this.window.gBrowser.treeStyleTab.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
|
||||||
|
@ -257,7 +257,7 @@ var TreeStyleTabUtils = {
|
|||||||
if (!this.isDebugging(aModule))
|
if (!this.isDebugging(aModule))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var logString = '[treestyletab:' + aModule+'] '+ aArgs.join(', ');
|
var logString = '[treestyletab:' + aModule+'] '+ aArgs.map(this.objectToLogString, this).join('');
|
||||||
Services.console.logStringMessage(logString);
|
Services.console.logStringMessage(logString);
|
||||||
dump(logString+'\n');
|
dump(logString+'\n');
|
||||||
},
|
},
|
||||||
@ -266,6 +266,66 @@ var TreeStyleTabUtils = {
|
|||||||
var stack = (new Error()).stack.replace(/^/gm, ' ');
|
var stack = (new Error()).stack.replace(/^/gm, ' ');
|
||||||
return this.log.apply(this, [aModule].concat(aArgs).concat([stack]));
|
return this.log.apply(this, [aModule].concat(aArgs).concat([stack]));
|
||||||
},
|
},
|
||||||
|
objectToLogString : function utils_objectToLogString(aObject)
|
||||||
|
{
|
||||||
|
if (!aObject)
|
||||||
|
return JSON.stringify(aObject);
|
||||||
|
|
||||||
|
if (/^(string|number|boolean)$/.test(typeof aObject))
|
||||||
|
return aObject;
|
||||||
|
|
||||||
|
return this.objectToString(aObject);
|
||||||
|
},
|
||||||
|
objectToString : function utils_objectToString(aObject)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!aObject ||
|
||||||
|
/^(string|number|boolean)$/.test(typeof aObject))
|
||||||
|
return JSON.stringify(aObject);
|
||||||
|
|
||||||
|
if (Array.isArray(aObject))
|
||||||
|
return '['+aObject.map(this.objectToString, this).join(', ')+']';
|
||||||
|
|
||||||
|
var constructor = String(aObject.constructor).match(/^function ([^\(]+)/);
|
||||||
|
if (constructor) {
|
||||||
|
constructor = constructor[1];
|
||||||
|
switch (constructor)
|
||||||
|
{
|
||||||
|
case 'String':
|
||||||
|
case 'Number':
|
||||||
|
case 'Boolean':
|
||||||
|
return JSON.stringify(aObject);
|
||||||
|
|
||||||
|
case 'Object':
|
||||||
|
return '{' + Object.keys(aObject).map(function(aKey) {
|
||||||
|
return '"' + aKey + '":' + this.objectToString(aObject[aKey]);
|
||||||
|
}, this).join(', ') + '}';
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/Element$/.test(constructor)) {
|
||||||
|
let id = '';
|
||||||
|
if (aObject.hasAttribute('id'))
|
||||||
|
id = '#' + aObject.getAttribute('id');
|
||||||
|
|
||||||
|
let classes = '';
|
||||||
|
if (aObject.className)
|
||||||
|
classes = '.' + aObject.className.replace(/\s+/g, '.');
|
||||||
|
|
||||||
|
return '<' + aObject.localName + id + classes + '>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<object '+constructor+'>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return String(aObject);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
return String(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/* string bundle */
|
/* string bundle */
|
||||||
get treeBundle () {
|
get treeBundle () {
|
||||||
|
@ -1385,7 +1385,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
if (!aTab)
|
if (!aTab)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log('onBeforeOpenLinkWithTab '+[aTab, JSON.stringify(aParams), this.checkToOpenChildTab(aTab)]);
|
log('onBeforeOpenLinkWithTab: ', [aTab, aParams, this.checkToOpenChildTab(aTab)]);
|
||||||
|
|
||||||
if (!this.checkToOpenChildTab(aTab)) {
|
if (!this.checkToOpenChildTab(aTab)) {
|
||||||
if (!aParams.fromChrome)
|
if (!aParams.fromChrome)
|
||||||
@ -1397,7 +1397,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
|
|
||||||
onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner)
|
onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner)
|
||||||
{
|
{
|
||||||
log('onBeforeOpenNewTabByThirdParty '+[aOwner, this.checkToOpenChildTab(aTab)]);
|
log('onBeforeOpenNewTabByThirdParty: ', [aOwner, this.checkToOpenChildTab(aTab)]);
|
||||||
|
|
||||||
if (!this.checkToOpenChildTab(aOwner)) {
|
if (!this.checkToOpenChildTab(aOwner)) {
|
||||||
this.handleNewTabFromCurrent(aOwner);
|
this.handleNewTabFromCurrent(aOwner);
|
||||||
@ -1413,7 +1413,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
log('onBeforeBrowserAccessOpenURI: opener is DOMWindow');
|
log('onBeforeBrowserAccessOpenURI: opener is DOMWindow');
|
||||||
opener = aOpener;
|
opener = aOpener;
|
||||||
hasOwnerTab = this.getTabFromFrame(opener.top);
|
hasOwnerTab = this.getTabFromFrame(opener.top);
|
||||||
log(' opener =>'+[opener,hasOwnerTab]);
|
log(' opener =>', [opener, hasOwnerTab]);
|
||||||
}
|
}
|
||||||
else if (Ci.nsIOpenURIInFrameParams &&
|
else if (Ci.nsIOpenURIInFrameParams &&
|
||||||
aOpener instanceof Ci.nsIOpenURIInFrameParams) {
|
aOpener instanceof Ci.nsIOpenURIInFrameParams) {
|
||||||
@ -1432,7 +1432,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(' opener =>'+[opener,hasOwnerTab]);
|
log(' opener =>', [opener, hasOwnerTab]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aOpener &&
|
if (aOpener &&
|
||||||
@ -1462,7 +1462,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
{
|
{
|
||||||
var where = String(this.window.whereToOpenLink(aEvent, false, true));
|
var where = String(this.window.whereToOpenLink(aEvent, false, true));
|
||||||
|
|
||||||
log('onBeforeViewMedia '+[aEvent, aOwner, where]);
|
log('onBeforeViewMedia: ', [aEvent, aOwner, where]);
|
||||||
|
|
||||||
if (where.indexOf('tab') == 0)
|
if (where.indexOf('tab') == 0)
|
||||||
this.handleNewTabFromCurrent(aOwner);
|
this.handleNewTabFromCurrent(aOwner);
|
||||||
@ -1472,7 +1472,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
|||||||
|
|
||||||
onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab)
|
onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab)
|
||||||
{
|
{
|
||||||
log('onBeforeBrowserSearch '+[aTerm, aForceNewTab, this.shouldOpenSearchResultAsChild(aTerm)]);
|
log('onBeforeBrowserSearch: ', [aTerm, aForceNewTab, this.shouldOpenSearchResultAsChild(aTerm)]);
|
||||||
|
|
||||||
if ((arguments.length == 1 || aForceNewTab) &&
|
if ((arguments.length == 1 || aForceNewTab) &&
|
||||||
this.shouldOpenSearchResultAsChild(aTerm))
|
this.shouldOpenSearchResultAsChild(aTerm))
|
||||||
|
Loading…
Reference in New Issue
Block a user