Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Jun 5, 2022

@fregante
Copy link
Contributor Author

fregante commented Jun 6, 2022

CI is failing for unrelated reasons

Copy link
Member

@Rob--W Rob--W left a 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?

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

philipp-classen added a commit to philipp-classen/ghostery-extension that referenced this pull request Aug 11, 2022
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
philipp-classen added a commit to philipp-classen/ghostery-extension that referenced this pull request Aug 11, 2022
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
chrmod pushed a commit to ghostery/ghostery-extension that referenced this pull request Aug 12, 2022
* 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
@fregante
Copy link
Contributor Author

Sorry I haven't had time to finish this.

@fregante fregante closed this Jan 13, 2023
@fregante fregante deleted the patch-3 branch January 13, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants