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

Fix unwrapping of eval result array. #33

Merged
merged 1 commit into from
Oct 19, 2022
Merged

Fix unwrapping of eval result array. #33

merged 1 commit into from
Oct 19, 2022

Conversation

sammacbeth
Copy link
Collaborator

Fixes an error in manifest v2 extensions where we were returning a result array for eval rules, which is truthy, causing rules to trigger too often.

resolve([{
result,
result: resultArr[0],
Copy link
Member

Choose a reason for hiding this comment

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

@sammacbeth looks good I think, so since we're converting the "eval" result to a boolean value I guess we can be sure we'll always get back exactly one result in MV3, if I understand the docs correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This code path is only for MV2, which returns an array.

@@ -106,7 +106,7 @@ chrome.runtime.onMessage.addListener(
case "eval":
evalInTab(tabId, frameId, msg.code).then(([result]) => {
if (enableLogs) {
console.groupCollapsed(`eval result for ${sender.origin}`);
console.groupCollapsed(`eval result for ${sender.origin || new URL(sender.url).origin}`);
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that either sender.origin or sender.urlwill always be defined? I checked the (docs)[https://developer.chrome.com/docs/extensions/reference/runtime/#type-MessageSender] and both seem optional, though probably one needs to be set, I guess, @sammacbeth?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you always get one, but I removed the use of URL to be safe and prevent an error being thrown here.

package.json Show resolved Hide resolved
@sammacbeth sammacbeth merged commit 4a932e1 into main Oct 19, 2022
@sammacbeth sammacbeth deleted the sam/ff-eval-bug branch October 19, 2022 12:04
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.

2 participants