Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

fix desktop using mv3 and remove ENABLE_MV3#263

Merged
vinistevam merged 9 commits intomain-desktopfrom
fix/desktop-using-mv3
Dec 7, 2022
Merged

fix desktop using mv3 and remove ENABLE_MV3#263
vinistevam merged 9 commits intomain-desktopfrom
fix/desktop-using-mv3

Conversation

@vinistevam
Copy link
Copy Markdown
Contributor

@vinistevam vinistevam commented Nov 21, 2022

Overview

ENABLE_MV3 was removed from mv3.utils.js on the desktop app side. Now It only has two places where ENABLE_MV3 will need to be until MV3 is fully merged.

Changes

Desktop

  • included logic on node-browser.ts and in background.js to properly proxy browserAction because it has been replaced by action in MV3

Extension

  • removed ENABLE_MV3 from mv3.utils.js

Common

  • browser-proxy to replace browserAction with action when the extension is in MV3

Issues

Resolves #159

@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch from fea4f57 to 73fc6d1 Compare November 21, 2022 18:39
@vinistevam vinistevam marked this pull request as ready for review November 21, 2022 19:31
@vinistevam vinistevam requested a review from a team November 21, 2022 19:31
@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch from 73fc6d1 to 2398174 Compare November 22, 2022 06:25
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this all necessary? Can we not just add both the action and browserAction versions to the array?

Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 Nov 22, 2022

Choose a reason for hiding this comment

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

Should we be using cfg().desktop.mv3 and code fencing to avoid dealing with the envs directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, but just to confirm do you mean code fencing just the import cfg from './desktop/utils/config'; or the whole if as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good point, probably not worth it here as you'd have to break up the condition and it'd get ugly.

@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch 7 times, most recently from b1fae9a to d818604 Compare November 23, 2022 21:32
@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch 3 times, most recently from 9fbcc40 to 20aabb3 Compare November 30, 2022 13:12
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can remove configOverride if it's no longer being used.

Copy link
Copy Markdown
Contributor

@gauthierpetetin gauthierpetetin Dec 1, 2022

Choose a reason for hiding this comment

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

Is there a way to fully get rid ENABLE_MV3 env variable?

For example by calling both the MV3 and the non-MV3 method in the extension?

browser.action.setBadgeText({ text: label });
browser.browserAction.setBadgeText({ text: label });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's possible if I use fencing.

      ///: BEGIN:EXCLUDE_IN(desktopapp)
      browser.action.setBadgeText({ text: label });
      browser.action.setBadgeBackgroundColor({ color: '#037DD6' });
      ///: END:EXCLUDE_IN

It will result in errors like Cannot find browser method - browserAction.setBadgeBackgroundColor.

@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch 2 times, most recently from d346c77 to 293fdb9 Compare December 2, 2022 09:45
@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch 4 times, most recently from 336413d to d0e4408 Compare December 6, 2022 08:27
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 Dec 6, 2022

Choose a reason for hiding this comment

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

This isn't actually doing anything as in the desktop app (which is always MV2), we would never hit the desktopextension code fence as it has its own desktopapp build type. And in the extension itself, we can detect isManifestV3 correctly and use the alternate condition.

On reflection, the cleanest fix for this issue is to update browser-proxy in the common package which receives browser commands from the app and runs them against the real browser. Here we can use isManifestV3 as we're in the extension, and update getBrowserMethod to just update all browserAction functions to use action if we're in MV3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @matthewwalsh0, applied the fix on browser-proxy to replace browserAction with action when the extension is in MV3.

@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch 3 times, most recently from cedf96e to 376b8c8 Compare December 7, 2022 09:10
@vinistevam vinistevam force-pushed the fix/desktop-using-mv3 branch from 376b8c8 to 62c3a43 Compare December 7, 2022 17:04
@vinistevam vinistevam merged commit 9f2548d into main-desktop Dec 7, 2022
@vinistevam vinistevam deleted the fix/desktop-using-mv3 branch December 7, 2022 19:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate if "ENABLE_MV3" env variable is required

5 participants