this fixes many addon validation warnings

This commit is contained in:
gorhill 2015-05-17 13:02:56 -04:00
parent 7eac4072de
commit facef0dc05
16 changed files with 47 additions and 29 deletions

View file

@ -46,6 +46,10 @@ vAPI.chrome = true;
/******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || self.setTimeout.bind(self);
/******************************************************************************/
vAPI.shutdown = (function() {
var jobs = [];

View file

@ -30,10 +30,12 @@
'use strict';
self.vAPI = self.vAPI || {};
var vAPI = self.vAPI = self.vAPI || {};
var chrome = self.chrome;
var vAPI = self.vAPI;
/******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || self.setTimeout.bind(self);
/******************************************************************************/

View file

@ -747,7 +747,7 @@ vAPI.tabs.injectScript = function(tabId, details, callback) {
);
if ( typeof callback === 'function' ) {
setTimeout(callback, 13);
vAPI.setTimeout(callback, 13);
}
};
@ -1568,7 +1568,7 @@ vAPI.toolbarButton.init = function() {
}
// Anonymous elements need some time to be reachable
setTimeout(this.updateBadgeStyle, 250);
vAPI.setTimeout(this.updateBadgeStyle, 250);
}.bind(this.CUIEvents);
// https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm#Listeners
@ -1602,7 +1602,7 @@ vAPI.toolbarButton.init = function() {
this.onCreated = function(button) {
button.setAttribute('badge', '');
setTimeout(updateBadge, 250);
vAPI.setTimeout(updateBadge, 250);
};
CustomizableUI.addListener(this.CUIEvents);
@ -1668,7 +1668,7 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
return;
}
updateTimer = setTimeout(resizePopup, 10);
updateTimer = vAPI.setTimeout(resizePopup, 10);
};
var resizePopup = function() {
updateTimer = null;

View file

@ -38,6 +38,12 @@ vAPI.sessionId = String.fromCharCode(Date.now() % 25 + 97) +
/******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || function(callback, delay) {
setTimeout(function() { callback(); }, delay);
};
/******************************************************************************/
vAPI.shutdown = (function() {
var jobs = [];

View file

@ -36,7 +36,13 @@ const {Services} = Components.utils.import(
null
);
self.vAPI = self.vAPI || {};
var vAPI = self.vAPI = self.vAPI || {};
/******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || function(callback, delay) {
setTimeout(function() { callback(); }, delay);
};
/******************************************************************************/

View file

@ -1352,7 +1352,7 @@ var scheduleUpdateDaemon = function() {
if ( updateDaemonTimer !== null ) {
clearTimeout(updateDaemonTimer);
}
updateDaemonTimer = setTimeout(
updateDaemonTimer = vAPI.setTimeout(
updateDaemon,
exports.manualUpdate ? manualUpdateDaemonTimerPeriod : autoUpdateDaemonTimerPeriod
);

View file

@ -88,7 +88,7 @@ AsyncJobManager.prototype.restartTimer = function() {
if ( when < this.timerWhen ) {
clearTimeout(this.timerId);
this.timerWhen = when;
this.timerId = setTimeout(processJobs, Math.max(when - Date.now(), 10));
this.timerId = vAPI.setTimeout(processJobs, Math.max(when - Date.now(), 10));
}
};
@ -198,6 +198,6 @@ return asyncJobManager;
if ( vAPI.isBehindTheSceneTabId(tabId) ) {
return;
}
tabIdToTimer[tabId] = setTimeout(updateBadge.bind(this, tabId), 500);
tabIdToTimer[tabId] = vAPI.setTimeout(updateBadge.bind(this, tabId), 500);
};
})();

View file

@ -206,7 +206,7 @@ var uBlockCollapser = (function() {
clearTimeout(timer);
send();
} else if ( timer === null ) {
timer = setTimeout(send, delay || 20);
timer = vAPI.setTimeout(send, delay || 20);
}
};
@ -599,7 +599,7 @@ var uBlockCollapser = (function() {
if ( processHighHighGenericsTimer !== null ) {
clearTimeout(processHighHighGenericsTimer);
}
processHighHighGenericsTimer = setTimeout(processHighHighGenerics, 300);
processHighHighGenericsTimer = vAPI.setTimeout(processHighHighGenerics, 300);
};
// Extract all ids: these will be passed to the cosmetic filtering
@ -739,7 +739,7 @@ var uBlockCollapser = (function() {
// I arbitrarily chose 100 ms for now:
// I have to compromise between the overhead of processing too few
// nodes too often and the delay of many nodes less often.
addedNodeListsTimer = setTimeout(treeMutationObservedHandler, 100);
addedNodeListsTimer = vAPI.setTimeout(treeMutationObservedHandler, 100);
}
};

View file

@ -1012,7 +1012,7 @@ FilterContainer.prototype.triggerSelectorCachePruner = function() {
}
// Of interest: http://fitzgeraldnick.com/weblog/40/
// http://googlecode.blogspot.ca/2009/07/gmail-for-mobile-html5-series-using.html
this.selectorCacheTimer = setTimeout(
this.selectorCacheTimer = vAPI.setTimeout(
this.pruneSelectorCacheAsync.bind(this),
this.selectorCachePruneDelay
);

View file

@ -460,7 +460,7 @@ var onLogBufferRead = function(response) {
tbody.querySelector('tr') === null
);
setTimeout(readLogBuffer, 1200);
vAPI.setTimeout(readLogBuffer, 1200);
};
/******************************************************************************/
@ -640,7 +640,7 @@ var rowFilterer = (function() {
if ( timer !== null ) {
clearTimeout(timer);
}
timer = setTimeout(commit, 750);
timer = vAPI.setTimeout(commit, 750);
};
})();

View file

@ -164,7 +164,7 @@ var janitor = function() {
logBuffer = logBuffer.dispose();
}
if ( logBuffer !== null ) {
setTimeout(janitor, logBufferObsoleteAfter);
vAPI.setTimeout(janitor, logBufferObsoleteAfter);
}
};
@ -181,7 +181,7 @@ var writeOne = function() {
var readAll = function() {
if ( logBuffer === null ) {
logBuffer = new LogBuffer();
setTimeout(janitor, logBufferObsoleteAfter);
vAPI.setTimeout(janitor, logBufferObsoleteAfter);
}
return logBuffer.readAll();
};

View file

@ -332,7 +332,7 @@ var updateMetadataNow = function() {
var updateMetadataAsync = function() {
if ( metadataPersistTimer === null ) {
metadataPersistTimer = setTimeout(updateMetadata, 60 * 1000);
metadataPersistTimer = vAPI.setTimeout(updateMetadata, 60 * 1000);
}
};

View file

@ -200,7 +200,7 @@ NetFilteringResultCache.prototype.prune = function() {
NetFilteringResultCache.prototype.pruneAsync = function() {
if ( this.timer === null ) {
this.timer = setTimeout(this.boundPruneAsyncCallback, this.shelfLife * 2);
this.timer = vAPI.setTimeout(this.boundPruneAsyncCallback, this.shelfLife * 2);
}
};

View file

@ -744,7 +744,7 @@ var pollForContentChange = (function() {
if ( pollTimer !== null ) {
return;
}
pollTimer = setTimeout(pollCallback, 1500);
pollTimer = vAPI.setTimeout(pollCallback, 1500);
};
return poll;

View file

@ -165,7 +165,7 @@ housekeep itself.
TabContext.prototype.onTab = function(tab) {
if ( tab ) {
this.timer = setTimeout(this.onTimerCallback, gcPeriod);
this.timer = vAPI.setTimeout(this.onTimerCallback, gcPeriod);
} else {
this.destroy();
}
@ -188,7 +188,7 @@ housekeep itself.
}
this.onTabCallback = this.onTab.bind(this);
this.onTimerCallback = this.onTimer.bind(this);
this.timer = setTimeout(this.onTimerCallback, gcPeriod);
this.timer = vAPI.setTimeout(this.onTimerCallback, gcPeriod);
};
// Update just force all properties to be updated to match the most current
@ -593,7 +593,7 @@ vAPI.tabs.registerListeners();
return false;
}
tabIdToTryCount[tabId] = count - 1;
tabIdToTimer[tabId] = setTimeout(updateTitle.bind(µb, tabId), delay);
tabIdToTimer[tabId] = vAPI.setTimeout(updateTitle.bind(µb, tabId), delay);
return true;
};
@ -624,7 +624,7 @@ vAPI.tabs.registerListeners();
if ( tabIdToTimer[tabId] ) {
clearTimeout(tabIdToTimer[tabId]);
}
tabIdToTimer[tabId] = setTimeout(updateTitle.bind(this, tabId), delay);
tabIdToTimer[tabId] = vAPI.setTimeout(updateTitle.bind(this, tabId), delay);
tabIdToTryCount[tabId] = 5;
};
})();
@ -664,10 +664,10 @@ var pageStoreJanitor = function() {
}
pageStoreJanitorSampleAt = n;
setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
vAPI.setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
};
setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
vAPI.setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
/******************************************************************************/

View file

@ -372,7 +372,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
if ( tabIdToTimerMap.hasOwnProperty(tabId) ) {
return;
}
tabIdToTimerMap[tabId] = setTimeout(
tabIdToTimerMap[tabId] = vAPI.setTimeout(
injectNow.bind(null, tabId),
100
);