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: Chrome Extensions service worker host registration #39290

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

codebytere
Copy link
Member

Description of Change

Closes #34178.

Fixes basic Chrome Extension Manifest V3 service worker functionality. Previously, the service worker would register but could not run any chrome APIs:

[61131:0731/100424.234951:ERROR:render_process_host_impl.cc(3967)] Request for unknown Channel-associated interface: extensions.mojom.ServiceWorkerHost

This fixes that and adds a simple regression test.

Checklist

Release Notes

Notes: Fixed an issue where service workers could not run Chrome APIs in Chrome Extensions Manifest V3.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/24-x-y PR should also be added to the "24-x-y" branch. target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. labels Jul 31, 2023
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 31, 2023
@codebytere codebytere requested review from jkleinsc and removed request for MarshallOfSound July 31, 2023 12:57
@zcbenz zcbenz merged commit c8f7a0e into main Aug 1, 2023
18 checks passed
@zcbenz zcbenz deleted the fix-service-worker-registration branch August 1, 2023 06:04
@release-clerk
Copy link

release-clerk bot commented Aug 1, 2023

Release Notes Persisted

Fixed an issue where service workers could not run Chrome APIs in Chrome Extensions Manifest V3.

@trop
Copy link
Contributor

trop bot commented Aug 1, 2023

I have automatically backported this PR to "26-x-y", please check out #39310

@trop trop bot added in-flight/26-x-y and removed target/26-x-y PR should also be added to the "26-x-y" branch. labels Aug 1, 2023
@trop
Copy link
Contributor

trop bot commented Aug 1, 2023

I have automatically backported this PR to "24-x-y", please check out #39311

@trop
Copy link
Contributor

trop bot commented Aug 1, 2023

I have automatically backported this PR to "25-x-y", please check out #39312

@trop trop bot added in-flight/24-x-y in-flight/25-x-y and removed target/24-x-y PR should also be added to the "24-x-y" branch. target/25-x-y PR should also be added to the "25-x-y" branch. labels Aug 1, 2023
@trop trop bot added merged/25-x-y PR was merged to the "25-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. and removed in-flight/25-x-y in-flight/26-x-y in-flight/24-x-y labels Aug 1, 2023
win32ss pushed a commit to win32ss/supermium-electron that referenced this pull request Sep 24, 2023
MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
@dragonsinth
Copy link

This may be a dumb question, but I can't get background scripts to work at all. I found this PR looking for answers-- the fact that this sample exists suggests background scripts should work? But I can't even get this sample to work in 26.6.9. Is this like.. a brand new feature?

I copied this exact sample, loading it into electron-react-boilerplate:

app.whenReady().then(async () => {
  const ext: Electron.Extension = await session.defaultSession.loadExtension(
      '/Users/scottb/github/electron-react-boilerplate/electron-react-boilerplate/mv3-service-worker',
      {
        allowFileAccess: true,
      },
  );
  console.log(ext)
})

And get this output:

{
  id: 'ciapjocennpjgkpponngfceicijjbnlc',
  name: 'MV3 Service Worker',
  path: '/Users/scottb/github/electron-react-boilerplate/electron-react-boilerplate/mv3-service-worker',
  url: 'chrome-extension://ciapjocennpjgkpponngfceicijjbnlc/',
  version: '1.0',
  manifest: {
    background: { service_worker: 'background.js' },
    content_scripts: [ [Object] ],
    description: 'Test for extension service worker support.',
    manifest_version: 3,
    name: 'MV3 Service Worker',
    version: '1.0'
  }
}
[60264:0208/091005.172943:ERROR:extensions_browser_client.cc(69)] Extension Error:
  OTR:     false
  Level:   1
  Source:  manifest.json
  Message: Service worker registration failed. Status code: 2
  ID:      ciapjocennpjgkpponngfceicijjbnlc
  Type:    ManifestError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/25-x-y PR was merged to the "25-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. new-pr 🌱 PR opened in the last 24 hours semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Chrome Extension V3 service_worker - Supported APIs do not function
4 participants