Fix spurious error message in dev console

Ports can be disconnected under certain conditions,
and in such case runtime.lastError must be accessed
to avoid the extensions framework from emitting
error messages in the console.
This commit is contained in:
Raymond Hill 2021-07-31 07:20:38 -04:00
parent dc08478130
commit 2eb02c5adc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 5 deletions

View File

@ -97,9 +97,12 @@ vAPI.messaging = {
// as world-ending, i.e. stay around. Except for embedded frames. // as world-ending, i.e. stay around. Except for embedded frames.
disconnectListener: function() { disconnectListener: function() {
void browser.runtime.lastError;
this.port = null; this.port = null;
if ( window !== window.top ) { if ( window !== window.top ) {
vAPI.shutdown.exec(); vAPI.shutdown.exec();
} else {
this.destroyPort();
} }
}, },
disconnectListenerBound: null, disconnectListenerBound: null,
@ -129,11 +132,10 @@ vAPI.messaging = {
messageListenerBound: null, messageListenerBound: null,
canDestroyPort: function() { canDestroyPort: function() {
return this.pending.size === 0 && return this.pending.size === 0 && (
( this.extensions.length === 0 ||
this.extensions.length === 0 || this.extensions.every(e => e.canDestroyPort())
this.extensions.every(e => e.canDestroyPort()) );
);
}, },
mustDestroyPort: function() { mustDestroyPort: function() {