-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle new "tab closed" response from Chrome #385
Conversation
fregante
commented
Jun 5, 2022
- Presumably fixes A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received #384
CI is failing for unrelated reasons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a unit test?
webextension-polyfill/test/test-runtime-onMessage.js
Lines 242 to 265 in 2ece178
it("resolves to undefined when no listeners reply", () => { | |
const fakeChrome = { | |
runtime: { | |
// This error message is defined as CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE | |
// in the polyfill sources and it is used to recognize when Chrome has detected that | |
// none of the listeners replied. | |
lastError: { | |
message: "The message port closed before a response was received.", | |
}, | |
sendMessage: sinon.stub(), | |
}, | |
}; | |
fakeChrome.runtime.sendMessage.onFirstCall().callsArgWith(1, [undefined]); | |
return setupTestDOMWindow(fakeChrome).then(window => { | |
const promise = window.browser.runtime.sendMessage("some_message"); | |
ok(fakeChrome.runtime.sendMessage.calledOnce, "sendMessage has been called once"); | |
return promise.then(reply => { | |
deepEqual(reply, undefined, "sendMessage promise should be resolved to undefined"); | |
}); | |
}); | |
}); |
If you'd like, it would also be nice to add an integration test that triggers the error in a real Chrome browser (in case the error message changes), at https://github.com/mozilla/webextension-polyfill/tree/master/test/fixtures
from the webextension-polyfill (and removes the minified file). The patch silences the following warning that started to appear in recent Chrome versions: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received refs ghostery#808
from the webextension-polyfill (and removes the minified file). The patch silences the following warning that started to appear in recent Chrome versions: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received refs ghostery#806
* Apply patch mozilla/webextension-polyfill#385 from the webextension-polyfill (and removes the minified file). The patch silences the following warning that started to appear in recent Chrome versions: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received refs #806 * Added CHANGELOG
Sorry I haven't had time to finish this. |