disconnect port explicitly in FF
This commit is contained in:
parent
4d1110986c
commit
740a16a563
|
@ -15,6 +15,8 @@ if (typeof self.oldCode !== 'string') {
|
||||||
if (msg.code != null) self.oldCode = msg.code;
|
if (msg.code != null) self.oldCode = msg.code;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// FF keeps content scripts connected on navigation https://github.com/openstyles/stylus/issues/864
|
||||||
|
addEventListener('pagehide', () => port.disconnect(), {once: true});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,9 +398,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
port.onDisconnect.addListener(() => {
|
port.onDisconnect.addListener(() => {
|
||||||
browser.tabs.get(tabId)
|
chrome.tabs.get(tabId, tab =>
|
||||||
.then(tab => tab.url === initialUrl && location.reload())
|
!chrome.runtime.lastError && tab.url === initialUrl
|
||||||
.catch(closeCurrentTab);
|
? location.reload()
|
||||||
|
: closeCurrentTab());
|
||||||
});
|
});
|
||||||
return (opts = {}) => new Promise((resolve, reject) => {
|
return (opts = {}) => new Promise((resolve, reject) => {
|
||||||
const id = performance.now();
|
const id = performance.now();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user