Skip to content

Commit

Permalink
fix #3201
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 7, 2017
1 parent 8b2c6a6 commit 9d86ab0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 25 additions & 10 deletions src/js/pagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ var pageStoreJunkyardMax = 10;

/******************************************************************************/

var PageStore = function(tabId) {
this.init(tabId);
var PageStore = function(tabId, context) {
this.init(tabId, context);
this.journal = [];
this.journalTimer = null;
this.journalLastCommitted = this.journalLastUncommitted = undefined;
Expand All @@ -250,19 +250,23 @@ var PageStore = function(tabId) {

/******************************************************************************/

PageStore.factory = function(tabId) {
PageStore.factory = function(tabId, context) {
var entry = pageStoreJunkyard.pop();
if ( entry === undefined ) {
entry = new PageStore(tabId);
entry = new PageStore(tabId, context);
} else {
entry.init(tabId);
entry.init(tabId, context);
}
return entry;
};

/******************************************************************************/

PageStore.prototype.init = function(tabId) {
// https://github.com/gorhill/uBlock/issues/3201
// The context is used to determine whether we report behavior change to the
// logger.

PageStore.prototype.init = function(tabId, context) {
var tabContext = µb.tabContextManager.mustLookup(tabId);
this.tabId = tabId;

Expand Down Expand Up @@ -292,8 +296,15 @@ PageStore.prototype.init = function(tabId) {
this.netFilteringCache = NetFilteringResultCache.factory();
this.internalRedirectionCount = 0;

this.noCosmeticFiltering = µb.hnSwitches.evaluateZ('no-cosmetic-filtering', tabContext.rootHostname) === true;
if ( this.noCosmeticFiltering && µb.logger.isEnabled() ) {
this.noCosmeticFiltering = µb.hnSwitches.evaluateZ(
'no-cosmetic-filtering',
tabContext.rootHostname
) === true;
if (
this.noCosmeticFiltering &&
µb.logger.isEnabled() &&
context === 'tabCommitted'
) {
µb.logger.writeOne(
tabId,
'cosmetic',
Expand All @@ -314,7 +325,11 @@ PageStore.prototype.init = function(tabId) {
'generichide'
);
this.noGenericCosmeticFiltering = result === 2;
if ( result !== 0 && µb.logger.isEnabled() ) {
if (
result !== 0 &&
µb.logger.isEnabled() &&
context === 'tabCommitted'
) {
µb.logger.writeOne(
tabId,
'net',
Expand Down Expand Up @@ -360,7 +375,7 @@ PageStore.prototype.reuse = function(context) {
}
this.disposeFrameStores();
this.netFilteringCache = this.netFilteringCache.dispose();
this.init(this.tabId);
this.init(this.tabId, context);
return this;
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ vAPI.tabs.registerListeners();
if ( !pageStore ) {
this.updateTitle(tabId);
this.pageStoresToken = Date.now();
return (this.pageStores[tabId] = this.PageStore.factory(tabId));
return (this.pageStores[tabId] = this.PageStore.factory(tabId, context));
}

// https://github.com/chrisaljoudi/uBlock/issues/516
Expand Down

0 comments on commit 9d86ab0

Please sign in to comment.