1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

this fixes #854.

Unlike PageStore, TabContext is best placed to keep track of whitelist status
This commit is contained in:
gorhill 2015-10-22 09:45:21 -04:00
parent 97c87ce646
commit afd77a3cef
2 changed files with 18 additions and 16 deletions

View File

@ -300,8 +300,6 @@ PageStore.prototype.init = function(tabId) {
this.hostnameToCountMap = {};
this.contentLastModified = 0;
this.frames = {};
this.netFiltering = true;
this.netFilteringReadTime = 0;
this.perLoadBlockedRequestCount = 0;
this.perLoadAllowedRequestCount = 0;
this.hiddenElementCount = ''; // Empty string means "unknown"
@ -351,7 +349,6 @@ PageStore.prototype.reuse = function(context) {
// As part of https://github.com/chrisaljoudi/uBlock/issues/405
// URL changed, force a re-evaluation of filtering switch
this.rawURL = tabContext.rawURL;
this.netFilteringReadTime = 0;
return this;
}
@ -444,19 +441,7 @@ PageStore.prototype.createContextFromFrameHostname = function(frameHostname) {
/******************************************************************************/
PageStore.prototype.getNetFilteringSwitch = function() {
var tabContext = µb.tabContextManager.lookup(this.tabId);
if ( this.netFilteringReadTime > µb.netWhitelistModifyTime ) {
return this.netFiltering;
}
// https://github.com/chrisaljoudi/uBlock/issues/1078
// Use both the raw and normalized URLs.
this.netFiltering = µb.getNetFilteringSwitch(tabContext.normalURL);
if ( this.netFiltering && tabContext.rawURL !== tabContext.normalURL ) {
this.netFiltering = µb.getNetFilteringSwitch(tabContext.rawURL);
}
this.netFilteringReadTime = Date.now();
return this.netFiltering;
return µb.tabContextManager.lookup(this.tabId).getNetFilteringSwitch();
};
/******************************************************************************/

View File

@ -155,6 +155,8 @@ housekeep itself.
this.rootDomain = '';
this.commitTimer = null;
this.gcTimer = null;
this.netFiltering = true;
this.netFilteringReadTime = 0;
tabContexts[tabId] = this;
};
@ -228,6 +230,7 @@ housekeep itself.
// Update just force all properties to be updated to match the most recent
// root URL.
TabContext.prototype.update = function() {
this.netFilteringReadTime = 0;
if ( this.stack.length === 0 ) {
this.rawURL = this.normalURL = this.rootHostname = this.rootDomain = '';
return;
@ -291,6 +294,20 @@ housekeep itself.
this.update();
};
TabContext.prototype.getNetFilteringSwitch = function() {
if ( this.netFilteringReadTime > µb.netWhitelistModifyTime ) {
return this.netFiltering;
}
// https://github.com/chrisaljoudi/uBlock/issues/1078
// Use both the raw and normalized URLs.
this.netFiltering = µb.getNetFilteringSwitch(this.normalURL);
if ( this.netFiltering && this.rawURL !== this.normalURL ) {
this.netFiltering = µb.getNetFilteringSwitch(this.rawURL);
}
this.netFilteringReadTime = Date.now();
return this.netFiltering;
};
// These are to be used for the API of the tab context manager.
var push = function(tabId, url) {