Skip to content

Background page load fail bug fix release note#30097

Merged
rebloor merged 8 commits into
mdn:mainfrom
rebloor:dackground-page-load-fix
Nov 10, 2023
Merged

Background page load fail bug fix release note#30097
rebloor merged 8 commits into
mdn:mainfrom
rebloor:dackground-page-load-fix

Conversation

@rebloor

@rebloor rebloor commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

Description

Adds a release note describing the fix of a bug that resulted in background pages failing to load. Addresses the dev–doc–needed request for Bug 1860304 Background page fails to load if background.service_worker and background.scripts are both present.

@rebloor rebloor added the Content:WebExt WebExtensions docs label Nov 7, 2023
@rebloor rebloor requested a review from Rob--W November 7, 2023 17:53
@rebloor rebloor self-assigned this Nov 7, 2023
@rebloor rebloor requested a review from a team as a code owner November 7, 2023 17:53
@rebloor rebloor requested review from pepelsbey and removed request for a team November 7, 2023 17:53
@github-actions github-actions Bot added Content:Firefox Content in the Mozilla/Firefox subtree and removed Content:WebExt WebExtensions docs labels Nov 7, 2023
@github-actions

github-actions Bot commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

Preview URLs

External URLs (4)

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background
Title: background


URL: /en-US/docs/Mozilla/Firefox/Releases/121
Title: Firefox 121 for developers

(comment last updated: 2023-11-10 01:14:04)

@Rob--W Rob--W left a comment

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.

Could you also document the service_worker key at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background ? And the behavior when scripts and service_worker are specified together. That's documented at w3c/webextensions#282 (comment)

Comment thread files/en-us/mozilla/firefox/releases/121/index.md Outdated
Comment thread files/en-us/mozilla/firefox/releases/121/index.md Outdated
rebloor and others added 2 commits November 8, 2023 07:15
Co-authored-by: Rob Wu <rob@robwu.nl>
@rebloor rebloor requested a review from Rob--W November 7, 2023 18:16

@Rob--W Rob--W left a comment

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.

@rebloor have you seen my previous comment?

Could you also document the service_worker key at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background ? And the behavior when scripts and service_worker are specified together. That's documented at w3c/webextensions#282 (comment)


- Fixed a bug that caused background pages to fail to start when a manifest.json `background` key contained `service_worker` and `scripts` declarations ([Firefox bug 1860304](https://bugzil.la/1860304)).

> NOTE: Incidentally, Chrome 121 ignores the `scripts` key when specified with the `service_worker` key, instead of refusing to load the extension ([Chromium bug 1418934](https://crbug.com/1418934)).

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.

In my suggested text here, it's not obvious that it's about a change in Chrome 121. Are you able to improve the phrasing?

I used "incidentally" because the independent fixes landed in version 121 of both browsers.

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.

@Rob--W should be addressed now

@rebloor rebloor requested a review from a team as a code owner November 7, 2023 22:46
@github-actions github-actions Bot added the Content:WebExt WebExtensions docs label Nov 7, 2023
@rebloor

rebloor commented Nov 7, 2023

Copy link
Copy Markdown
Contributor Author

@rebloor have you seen my previous comment?

Sorry @Rob--W I tend to work through comments in the source code, and forget there can be ones outside. This should now be addressed.

Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
</p>
</div>
<p>
See the note following the table regarding browser support.

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.

The note applies to page and scripts and service_worker - basically every key. Would it make sense to turn the NOTE in a dedicated section and link it somewhere?

P.S. In another comment I suggested to add a code example to make the behavior easier to understand. That could then be a final part of the Example section.

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 @Rob--W I've moved the content below the property descriptions to a new "browser support" section and included the example

Comment on lines +121 to +123
> - Safari:
> - supports `background.service_worker`.
> - supports `background.scripts`, if `service_worker` is not specified.

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.

Maybe move the Safari section after Firefox, so that the special cases with Chrome and Firefox are next to each other.

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.

Done

> - Firefox:
> - supports `background.service_worker` if the service worker feature is enabled. However, this feature is affected by [a bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1775618#c1).
> - supports `background.scripts`, if `service_worker` is not specified or the service worker feature is disabled.

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.

This whole section is kind of complex. I think that it would be easier to understand if we preface it by an example and then explain the result. Like this:

{
  "name": "Demo of service worker + event page",
  "version": "1",
  "manifest_version": 3,
  "background": {
    "scripts": ["background.js"],
    "service_worker": "background.js"
   }
}

background.js:

if (typeof browser == "undefined") {
  // Chrome does not support the browser namespace yet.
  globalThis.browser = chrome;
}
browser.runtime.onInstalled.addListener(() => {
  browser.tabs.create({ url: "http://example.com/firstrun.html" });
});

rebloor and others added 2 commits November 9, 2023 11:10
Co-authored-by: Rob Wu <rob@robwu.nl>
@rebloor rebloor requested a review from Rob--W November 9, 2023 01:49
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/add-ons/webextensions/manifest.json/background/index.md Outdated
Comment thread files/en-us/mozilla/firefox/releases/121/index.md
Co-authored-by: Rob Wu <rob@robwu.nl>
Comment thread files/en-us/mozilla/firefox/releases/121/index.md Outdated
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@rebloor rebloor merged commit fe56d8f into mdn:main Nov 10, 2023
@rebloor rebloor deleted the dackground-page-load-fix branch November 10, 2023 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:Firefox Content in the Mozilla/Firefox subtree Content:WebExt WebExtensions docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants