[Pkg-mozext-commits] [tabmixplus] 22/26: Don't rely on Tabmix.callerName to get the right caller name when the original function wrapped by another extension
David Prévot
taffit at moszumanska.debian.org
Fri Mar 25 21:56:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 0.4.2.3pre.160319a1
in repository tabmixplus.
commit eb8731575d19da2fea79988fdc18a4782a22dbae
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Mar 16 20:38:06 2016 +0200
Don't rely on Tabmix.callerName to get the right caller name when the original function wrapped by another extension
---
chrome/content/minit/tablib.js | 14 +++++---------
chrome/content/utils.js | 3 ++-
modules/log.jsm | 10 ++++++++++
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 66ad3a5..7f20c25 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -155,8 +155,8 @@ var tablib = { // eslint-disable-line
Tabmix.changeCode(obj, "gBrowser." + fnName)._replace(
'{', '{\n' +
- ' let dontMove, isPending, callerName = Tabmix.callerName(),\n' +
- ' isRestoringTab = callerName == "ssi_restoreWindow";\n'
+ ' let dontMove, isPending, stack = Tabmix.stackTrace(),\n' +
+ ' isRestoringTab = stack.contain("ssi_restoreWindow");\n'
)._replace(
'let params = arguments[1];',
'$&\n' +
@@ -198,7 +198,7 @@ var tablib = { // eslint-disable-line
't.dispatchEvent(evt);' +
'var openTabnext = Tabmix.prefs.getBoolPref("openTabNext");' +
'if (openTabnext) {' +
- ' if (dontMove || Tabmix.dontMoveNewTab(callerName))' +
+ ' if (dontMove || Tabmix.dontMoveNewTab(stack))' +
' openTabnext = false;' +
' else if (!Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent"))' +
' aRelatedToCurrent = true;' +
@@ -207,12 +207,8 @@ var tablib = { // eslint-disable-line
't.owner = this.selectedTab;', 't.owner = _selectedTab;'
).toCode();
- Tabmix.dontMoveNewTab = function(caller) {
- if (caller == "ssi_restoreWindow" ||
- caller == "ssi_duplicateTab") {
- return true;
- }
- return false;
+ Tabmix.dontMoveNewTab = function(stack) {
+ return stack.contain("ssi_restoreWindow", "ssi_duplicateTab");
};
// ContextMenu Extensions raplce the original removeTab function
diff --git a/chrome/content/utils.js b/chrome/content/utils.js
index c7cc3a9..bc5e963 100644
--- a/chrome/content/utils.js
+++ b/chrome/content/utils.js
@@ -248,7 +248,8 @@ var Tabmix = { // jshint ignore:line
var methods = ["changeCode", "setNewFunction", "nonStrictMode",
"getObject", "log", "getCallerNameByIndex", "callerName",
- "clog", "isCallerInList", "obj", "assert", "trace", "reportError"];
+ "clog", "isCallerInList", "stackTrace",
+ "obj", "assert", "trace", "reportError"];
methods.forEach(function(id) {
this[id] = function TMP_console_wrapper() {
return this._getMethod(id, arguments);
diff --git a/modules/log.jsm b/modules/log.jsm
index b0e329c..ae68f48 100644
--- a/modules/log.jsm
+++ b/modules/log.jsm
@@ -177,6 +177,16 @@ this.console = {
return false;
},
+ stackTrace: function TMP_console_stackTrace() {
+ let stack = this._getStackExcludingInternal().join("\n");
+
+ return {
+ contain: function(...names) {
+ return names.some(name => stack.indexOf(name) > -1);
+ },
+ };
+ },
+
/*
options = {
msg: msg
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list