Note: There are a few cases of duplicates in user autocompletion which are being worked on.

chrome.i18n is undefined in content scripts

RESOLVED FIXED in Firefox 45

Status

()

Toolkit
WebExtensions: Untriaged
P1
normal
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: callahad, Assigned: kmag)

Tracking

({dev-doc-complete, DevAdvocacy})

unspecified
mozilla45
dev-doc-complete, DevAdvocacy
Points:
---
Dependency tree / graph
Bug Flags:
blocking-webextensions +

Firefox Tracking Flags

(firefox45 fixed)

Details

(Whiteboard: [i18n])

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
On https://wiki.mozilla.org/WebExtensions, we claim to support chrome.i18n.getMessage() with "@@extension_id" and "@@ui_locale" predefined messages. These appear to work in background scripts.

The Chrome docs at https://developer.chrome.com/extensions/content_scripts state that the i18n API should be available to content_scripts. In Firefox, it is not.

Steps to Reproduce:

1. In a content script, call console.log("@@extension_id is", chrome.i18n.getMessage("@@extension_id"));

What should happen:

- A uuid should get logged to the console

What actually happens:

- "chrome.i18n is undefined" shows up in the Browser Console 

This causes the Reddit Enhancement Suite to throw: https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/v4.5.4/Chrome/browsersupport-chrome.js#L116

Test case in the "i18n_content_script" folder of https://github.com/callahad/webextension-tests
(Reporter)

Updated

2 years ago
Blocks: 1208765
(Reporter)

Comment 1

2 years ago
This no longer blocks 1208765, as RES has moved away from this API.
No longer blocks: 1208765
Keywords: dev-doc-needed

Updated

2 years ago
Whiteboard: [i18n]
Blocks: 1214433
Priority: -- → P1

Updated

2 years ago
Flags: blocking-webextensions+
(Assignee)

Updated

2 years ago
Assignee: nobody → kmaglione+bmo
Depends on: 1209184
(Assignee)

Updated

2 years ago
Iteration: --- → 45.2 - Nov 30
(Assignee)

Comment 2

2 years ago
Created attachment 8691163 [details]
MozReview Request: Bug 1208761: [webext] Support l10n.getMessage in content scripts. r?billm

Bug 1208761: [webext] Support l10n.getMessage in content scripts. r?billm
Attachment #8691163 - Flags: review?(wmccloskey)
Comment on attachment 8691163 [details]
MozReview Request: Bug 1208761: [webext] Support l10n.getMessage in content scripts. r?billm

https://reviewboard.mozilla.org/r/26081/#review23459

::: toolkit/components/extensions/test/mochitest/test_ext_i18n.html:83
(Diff revision 1)
> +          if (actual !== expected) {

Can you just send a message to the extension that includes actual and expected? Then the extension could do assertEq. That way we get a message printed when the test succeeds. The downside is that actual and expected must support structured clone. But in this case I can't see how they wouldn't.
Attachment #8691163 - Flags: review?(wmccloskey) → review+
(Assignee)

Comment 4

2 years ago
https://hg.mozilla.org/integration/fx-team/rev/4dca10306d58d2e87cbed46a72472b62c17b0ec9
Bug 1208761: [webext] Support l10n.getMessage in content scripts. r=billm
https://hg.mozilla.org/mozilla-central/rev/4dca10306d58
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox45: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
(Assignee)

Comment 6

2 years ago
Updated https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.