Skip to content

fix: sendMessage promise should resolve to undefined when no listeners reply#140

Merged
rpl merged 1 commit intomozilla:masterfrom
rpl:fix/130-sendMessage-with-no-replies
Jul 4, 2018
Merged

fix: sendMessage promise should resolve to undefined when no listeners reply#140
rpl merged 1 commit intomozilla:masterfrom
rpl:fix/130-sendMessage-with-no-replies

Conversation

@rpl
Copy link
Member

@rpl rpl commented Jul 2, 2018

This PR contains the changes from #131 with the addition of some small tweaks (from the last review on #131) and an additional integration test (to check that the behavior of the polyfill in Chrome is the same of the one on Firefox with the native promised APIs).

Fixes #130


test("sendMessage and no listener answers", async (t) => {
const reply = await browser.runtime.sendMessage("test - sendMessage and no listener answers");
t.equal(reply, undefined, "Got undefined as a reply a expected");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: as expected

},
};

fakeChrome.runtime.sendMessage.onFirstCall().callsArgWith(1, ["res1", "res2"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Use .callsArg(1) or callsArgWith(1, [undefined]); .
In reality the sendMessage callback won't ever be invoked with two arguments.

@ExE-Boss ExE-Boss mentioned this pull request Jul 3, 2018
@rpl rpl force-pushed the fix/130-sendMessage-with-no-replies branch from 5229506 to 8d5ab25 Compare July 3, 2018 20:03
@rpl rpl merged commit 4e1e98a into mozilla:master Jul 4, 2018
@rpl rpl deleted the fix/130-sendMessage-with-no-replies branch March 15, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants