From ecd81183b1e3e14ff6378014b4acf018c130456f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 19 Jul 2019 06:54:55 -0400 Subject: [PATCH] Fix thrown exception in onHeadersReceived listener Regression from: - https://github.com/gorhill/uBlock/commit/ae56c4dfe855 --- src/js/tab.js | 2 +- src/js/traffic.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/tab.js b/src/js/tab.js index 50504f47a..cb0f6febd 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -912,7 +912,7 @@ vAPI.tabs.registerListeners(); { const NoPageStore = class extends µBlock.PageStore { getNetFilteringSwitch(fctxt) { - if ( fctxt.docId === 0 ) { + if ( fctxt && fctxt.docId === 0 ) { const docOrigin = fctxt.getDocOrigin(); if ( docOrigin ) { return µBlock.getNetFilteringSwitch(docOrigin); diff --git a/src/js/traffic.js b/src/js/traffic.js index 96b5ad6f4..9b587e3ca 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -440,7 +440,7 @@ const onHeadersReceived = function(details) { if ( isRootDoc === false ) { return; } pageStore = µb.bindTabToPageStats(fctxt.tabId, 'beforeRequest'); } - if ( pageStore.getNetFilteringSwitch() === false ) { return; } + if ( pageStore.getNetFilteringSwitch(fctxt) === false ) { return; } // Keep in mind response headers will be modified in-place if needed, so // `details.responseHeaders` will always point to the modified response