Closed Bug 1208761 Opened 9 years ago Closed 9 years ago

chrome.i18n is undefined in content scripts

Categories

(WebExtensions :: Untriaged, defect, P1)

defect

Tracking

(firefox45 fixed)

RESOLVED FIXED
mozilla45
Iteration:
45.2 - Nov 30
Tracking Status
firefox45 --- fixed

People

(Reporter: callahad, Assigned: kmag)

References

Details

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

Attachments

(1 file)

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
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

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+
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
Closed: 9 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.

Attachment

General

Created:
Updated:
Size: