mirror of https://github.com/gorhill/uBlock.git
parent
02b4d149e3
commit
525d7b1b3b
|
@ -900,23 +900,24 @@ vAPI.messaging = {
|
||||||
this.ports.delete(port.name);
|
this.ports.delete(port.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port
|
||||||
|
// port.sender is always present for onConnect() listeners.
|
||||||
onPortConnect: function(port) {
|
onPortConnect: function(port) {
|
||||||
port.onDisconnect.addListener(
|
port.onDisconnect.addListener(port =>
|
||||||
port => this.onPortDisconnect(port)
|
this.onPortDisconnect(port)
|
||||||
);
|
);
|
||||||
port.onMessage.addListener(
|
port.onMessage.addListener((request, port) =>
|
||||||
(request, port) => this.onPortMessage(request, port)
|
this.onPortMessage(request, port)
|
||||||
);
|
);
|
||||||
const portDetails = { port };
|
const portDetails = { port };
|
||||||
const sender = port.sender;
|
const sender = port.sender;
|
||||||
if ( sender ) {
|
|
||||||
portDetails.frameId = sender.frameId;
|
|
||||||
const { tab, url } = sender;
|
const { tab, url } = sender;
|
||||||
|
portDetails.frameId = sender.frameId;
|
||||||
|
portDetails.frameURL = url;
|
||||||
|
portDetails.privileged = url.startsWith(this.PRIVILEGED_URL);
|
||||||
if ( tab ) {
|
if ( tab ) {
|
||||||
portDetails.tabId = tab.id;
|
portDetails.tabId = tab.id;
|
||||||
}
|
portDetails.tabURL = tab.url;
|
||||||
portDetails.url = url;
|
|
||||||
portDetails.privileged = url.startsWith(this.PRIVILEGED_URL);
|
|
||||||
}
|
}
|
||||||
this.ports.set(port.name, portDetails);
|
this.ports.set(port.name, portDetails);
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1652925#c24
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1652925#c24
|
||||||
|
@ -944,13 +945,10 @@ vAPI.messaging = {
|
||||||
vAPI.webextFlavor.major < 61
|
vAPI.webextFlavor.major < 61
|
||||||
) {
|
) {
|
||||||
browser.tabs.onRemoved.addListener(tabId => {
|
browser.tabs.onRemoved.addListener(tabId => {
|
||||||
for ( const { port } of this.ports.values() ) {
|
for ( const { port, tabId: portTabId } of this.ports.values() ) {
|
||||||
const tab = port.sender && port.sender.tab;
|
if ( portTabId !== tabId ) { continue; }
|
||||||
if ( !tab ) { continue; }
|
|
||||||
if ( tab.id === tabId ) {
|
|
||||||
this.onPortDisconnect(port);
|
this.onPortDisconnect(port);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -547,15 +547,9 @@ const µb = µBlock;
|
||||||
|
|
||||||
const retrieveContentScriptParameters = function(sender, request) {
|
const retrieveContentScriptParameters = function(sender, request) {
|
||||||
if ( µb.readyToFilter !== true ) { return; }
|
if ( µb.readyToFilter !== true ) { return; }
|
||||||
const { url: senderURL, tabId, frameId } = sender;
|
const { tabId, frameId } = sender;
|
||||||
if (
|
if ( tabId === undefined || frameId === undefined ) { return; }
|
||||||
tabId === undefined ||
|
|
||||||
frameId === undefined ||
|
|
||||||
senderURL === undefined ||
|
|
||||||
senderURL !== request.url && senderURL.startsWith('about:') === false
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pageStore = µb.pageStoreFromTabId(tabId);
|
const pageStore = µb.pageStoreFromTabId(tabId);
|
||||||
if ( pageStore === null || pageStore.getNetFilteringSwitch() === false ) {
|
if ( pageStore === null || pageStore.getNetFilteringSwitch() === false ) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue