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

[mv3] Support popup windows - via message channels #1167

Merged
merged 5 commits into from
May 28, 2024

Conversation

emaxx-google
Copy link
Collaborator

This adds support of manifest v3 to the "popup-window" helpers. This is achieved by reimplementing the popup==>background page communication using message ports.

Previously, we used two other mechanisms for this communication:

  • in the Chrome App build mode we injected callbacks into the popup's global state using the chrome.app.window.create() callback.
  • in the Chrome manifest v2 Extension build mode we used "setSelfAsOpener" to let the popup call global functions in the opener page itself.

Neither works in manifest v3 Extensions, hence this commit implements a new approach that should work in all build modes.

This adds support of manifest v3 to the "popup-window" helpers. This is
achieved by reimplementing the popup==>background page communication
using message ports.

Previously, we used two other mechanisms for this communication:

* in the Chrome App build mode we injected callbacks into the popup's
  global state using the chrome.app.window.create() callback.
* in the Chrome manifest v2 Extension build mode we used
  "setSelfAsOpener" to let the popup call global functions in the
  opener page itself.

Neither works in manifest v3 Extensions, hence this commit implements a
new approach that should work in all build modes.
Copy link

Continuous Integration: All tests passed.
C/C++ test coverage: 73.53% lines.

Copy link

Continuous Integration: All tests passed.
C/C++ test coverage: 73.54% lines.

Copy link
Collaborator

@AleksMat AleksMat left a comment

Choose a reason for hiding this comment

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

LGTM % nits

common/js/src/popup-window/popup-opener.js Outdated Show resolved Hide resolved
common/js/src/popup-window/popup-opener.js Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@emaxx-google emaxx-google left a comment

Choose a reason for hiding this comment

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

thanks!

common/js/src/popup-window/popup-opener.js Outdated Show resolved Hide resolved
common/js/src/popup-window/popup-opener.js Outdated Show resolved Hide resolved
Copy link

Continuous Integration: All tests passed.
C/C++ test coverage: 73.53% lines.

Copy link

Continuous Integration: All tests passed.
C/C++ test coverage: 73.55% lines.

@emaxx-google
Copy link
Collaborator Author

I've guarded some code in in-popup-main-script.js with checks because when the window is opened via createWindow() there's no popup_id passed and there's no need in one.

@emaxx-google emaxx-google merged commit b9cc382 into message-waiter May 28, 2024
10 checks passed
Extension migration automation moved this from In progress to Done May 28, 2024
@emaxx-google emaxx-google deleted the mv3-popup branch May 28, 2024 18:29
@emaxx-google emaxx-google restored the mv3-popup branch May 28, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants