mirror of https://github.com/gorhill/uBlock.git
Log procedural cosmetic exception filters
Related issue: - https://github.com/gorhill/uBlock/issues/127 Procedural cosmetic exception filters were the last class of cosmetic exception filters not being reported in the logger; this commit fixes this. Additionally, ensure that a single DOM listener can't prevent other listeners from being processed by throwing an exception. Such approach would have prevented regression leading to emergency release 1.22.4: - https://github.com/gorhill/uBlock/releases/tag/1.22.4
This commit is contained in:
parent
95469032a4
commit
bf697f344a
|
@ -267,7 +267,7 @@ vAPI.SafeAnimationFrame.prototype = {
|
|||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.domWatcher = (function() {
|
||||
vAPI.domWatcher = (( ) => {
|
||||
|
||||
const addedNodeLists = [];
|
||||
const removedNodeLists = [];
|
||||
|
@ -311,7 +311,8 @@ vAPI.domWatcher = (function() {
|
|||
//console.timeEnd('dom watcher/safe observer handler');
|
||||
if ( addedNodes.length === 0 && removedNodes === false ) { return; }
|
||||
for ( const listener of getListenerIterator() ) {
|
||||
listener.onDOMChanged(addedNodes, removedNodes);
|
||||
try { listener.onDOMChanged(addedNodes, removedNodes); }
|
||||
catch (ex) { }
|
||||
}
|
||||
addedNodes.length = 0;
|
||||
removedNodes = false;
|
||||
|
@ -373,7 +374,8 @@ vAPI.domWatcher = (function() {
|
|||
listeners.push(listener);
|
||||
listenerIteratorDirty = true;
|
||||
if ( domIsReady !== true ) { return; }
|
||||
listener.onDOMCreated();
|
||||
try { listener.onDOMCreated(); }
|
||||
catch (ex) { }
|
||||
startMutationObserver();
|
||||
};
|
||||
|
||||
|
@ -401,7 +403,8 @@ vAPI.domWatcher = (function() {
|
|||
const start = function() {
|
||||
domIsReady = true;
|
||||
for ( const listener of getListenerIterator() ) {
|
||||
listener.onDOMCreated();
|
||||
try { listener.onDOMCreated(); }
|
||||
catch (ex) { }
|
||||
}
|
||||
startMutationObserver();
|
||||
};
|
||||
|
|
|
@ -46,6 +46,7 @@ let declarativeStyleStr;
|
|||
const proceduralDict = new Map();
|
||||
const exceptionDict = new Map();
|
||||
let exceptionStr;
|
||||
const proceduralExceptionDict = new Map();
|
||||
const nodesToProcess = new Set();
|
||||
const loggedSelectors = new Set();
|
||||
|
||||
|
@ -172,6 +173,17 @@ const processExceptions = function(out) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
const processProceduralExceptions = function(out) {
|
||||
if ( proceduralExceptionDict.size === 0 ) { return; }
|
||||
for ( const exception of proceduralExceptionDict.values() ) {
|
||||
if ( exception.test() === false ) { continue; }
|
||||
out.push(`#@#${exception.raw}`);
|
||||
proceduralExceptionDict.delete(exception.raw);
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const processTimer = new vAPI.SafeAnimationFrame(( ) => {
|
||||
//console.time('dom logger/scanning for matches');
|
||||
processTimer.clear();
|
||||
|
@ -193,6 +205,7 @@ const processTimer = new vAPI.SafeAnimationFrame(( ) => {
|
|||
processDeclarativeStyle(toLog);
|
||||
processProcedural(toLog);
|
||||
processExceptions(toLog);
|
||||
processProceduralExceptions(toLog);
|
||||
|
||||
nodesToProcess.clear();
|
||||
|
||||
|
@ -268,9 +281,10 @@ const handlers = {
|
|||
exceptionDict.set(details.style[0], details.raw);
|
||||
continue;
|
||||
}
|
||||
// TODO:
|
||||
// Handling of procedural cosmetic exception filters
|
||||
// not implemented.
|
||||
proceduralExceptionDict.set(
|
||||
details.raw,
|
||||
vAPI.domFilterer.createProceduralFilter(details)
|
||||
);
|
||||
}
|
||||
exceptionStr = undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue