Closed Bug 1208761 Opened 9 years ago Closed 8 years ago

chrome.i18n is undefined in content scripts


(WebExtensions :: Untriaged, defect, P1)



(firefox45 fixed)

45.2 - Nov 30
Tracking Status
firefox45 --- fixed


(Reporter: callahad, Assigned: kmag)



(Keywords: dev-doc-complete, DevAdvocacy, Whiteboard: [i18n])


(1 file)

On, 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 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:

Test case in the "i18n_content_script" folder of
This no longer blocks 1208765, as RES has moved away from this API.
Whiteboard: [i18n]
Flags: blocking-webextensions+
Assignee: nobody → kmaglione+bmo
Depends on: 1209184
Iteration: --- → 45.2 - Nov 30
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

::: 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+
Bug 1208761: [webext] Support l10n.getMessage in content scripts. r=billm
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.