From de0f45581c142701f7b4d249921cbffdf8d53997 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 28 Sep 2022 09:58:44 -0400 Subject: [PATCH] Fix logging of sub_frame types Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/discussions/2302 --- src/js/static-net-filtering.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 6115c81d8..8485cd001 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -142,8 +142,8 @@ const typeValueToTypeName = [ 'image', 'object', 'script', - 'xmlhttprequest', - 'sub_frame', + 'xhr', + 'frame', 'font', 'media', 'websocket', @@ -163,6 +163,22 @@ const typeValueToTypeName = [ 'unsupported', ]; +const typeValueToDNRTypeName = [ + '', + 'stylesheet', + 'image', + 'object', + 'script', + 'xmlhttprequest', + 'sub_frame', + 'font', + 'media', + 'websocket', + 'ping', + 'other', +]; + + //const typeValueFromCatBits = catBits => (catBits >>> TypeBitsOffset) & 0b11111; const MAX_TOKEN_LENGTH = 7; @@ -1284,11 +1300,12 @@ const FilterNotType = class { rc.excludedResourceTypes = [ 'main_frame' ]; } let bits = args[1]; - for ( let i = 1; bits !== 0 && i < typeValueToTypeName.length; i++ ) { + for ( let i = 1; bits !== 0 && i < typeValueToDNRTypeName.length; i++ ) { const bit = 1 << (i - 1); if ( (bits & bit) === 0 ) { continue; } bits &= ~bit; - const type = typeValueToTypeName[i]; + const type = typeValueToDNRTypeName[i]; + if ( type === undefined ) { continue; } if ( rc.excludedResourceTypes.includes(type) ) { continue; } rc.excludedResourceTypes.push(type); }