mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
Fix potential failure to unregister scriptlet
In Firefox-specific contentScripts API used to register scriptlets. This could potentially occurs when there are registrations pending during a reload of filter lists.
This commit is contained in:
parent
41d49921c8
commit
f936dfa648
1 changed files with 4 additions and 1 deletions
|
@ -61,6 +61,7 @@ const contentScriptRegisterer = new (class {
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
}).then(handle => {
|
}).then(handle => {
|
||||||
this.hostnameToDetails.set(hostname, { handle, code });
|
this.hostnameToDetails.set(hostname, { handle, code });
|
||||||
|
return handle;
|
||||||
}).catch(( ) => {
|
}).catch(( ) => {
|
||||||
this.hostnameToDetails.delete(hostname);
|
this.hostnameToDetails.delete(hostname);
|
||||||
});
|
});
|
||||||
|
@ -94,7 +95,9 @@ const contentScriptRegisterer = new (class {
|
||||||
}
|
}
|
||||||
unregisterHandle(handle) {
|
unregisterHandle(handle) {
|
||||||
if ( handle instanceof Promise ) {
|
if ( handle instanceof Promise ) {
|
||||||
handle.then(handle => { handle.unregister(); });
|
handle.then(handle => {
|
||||||
|
if ( handle ) { handle.unregister(); }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
handle.unregister();
|
handle.unregister();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue