Add basic MessageContext and L10nRegistry xpcshell tests

RESOLVED FIXED

Status

RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: stas, Assigned: gandalf)

Tracking

(Blocks: 1 bug)

Details

(Whiteboard: [gecko-l20n])

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
It would be great to leverage mozilla-central's integration testing to provide good test coverage for MessageContext.

Updated

2 years ago
Whiteboard: [gecko-l20n]

Updated

2 years ago
No longer blocks: 1288639
(Reporter)

Updated

2 years ago
Blocks: 1291693
Comment hidden (mozreview-request)
(Assignee)

Updated

2 years ago
Assignee: nobody → gandalf
Summary: Find a way to run MessageContext's tests in mozilla-central → Add basic MessageContext and L10nRegistry xpcshell tests
(Reporter)

Comment 2

2 years ago
mozreview-review
Comment on attachment 8808523 [details]
Bug 1288684 - Add basic xpcshell tests for MessageContext and L10nRegistry.

https://reviewboard.mozilla.org/r/91354/#review91226

::: toolkit/modules/tests/xpcshell/test_IntlMessageContext.js:60
(Diff revision 1)
> +  mc.addMessages('key = Hello, { $name2 }');
> +
> +  const entity = mc.messages.get('key');
> +
> +  equal(mc.format(entity, {name: "Mary"}, errors), 'Hello, name2');
> +

nit: remove some of the blank lines?

::: toolkit/modules/tests/xpcshell/test_L10nRegistry.js:47
(Diff revision 1)
> +
> +  equal(Array.from(result.supportedLocales).length, 1);
> +  equal(result.bundles[0].locale, 'en-US');
> +  equal(result.bundles[0].resources['browser/brand.ftl'].locale, 'en-US');
> +  equal(result.bundles[0].resources['browser/brand.ftl'].source, 'app');
> +  equal(result.bundles[0].resources['browser/brand.ftl'].data, null);

Why is this `null`?

::: toolkit/modules/tests/xpcshell/test_L10nRegistry.js:54
(Diff revision 1)
> +
> +add_task(function* test_fetchResource() {
> +  const result =
> +    yield L10nRegistry.fetchResource('app', 'browser/brand.ftl', 'en-US');
> +
> +  equal(result, null);

Why is this `null`?
Attachment #8808523 - Flags: review?(stas) → review+
(Assignee)

Comment 3

2 years ago
I believe that the reason we don't return data here is because the test operates in xpcshell which doesn't load toolkit or app.

It makes me think that in the future we may want to move the registering of FileSources to those two so that in xpcshell you have none, in pure Gecko you have 'platform' and only in browser you have two.

I'm going to add a whole-page test - either mochi (which works like karma), or reftest (which is a screenshot to screenshot comparison), which will cover loading the resource as part of it.
(Reporter)

Comment 4

2 years ago
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #3)
> I believe that the reason we don't return data here is because the test
> operates in xpcshell which doesn't load toolkit or app.
> 
> It makes me think that in the future we may want to move the registering of
> FileSources to those two so that in xpcshell you have none, in pure Gecko
> you have 'platform' and only in browser you have two.

File a bug for this please.

> 
> I'm going to add a whole-page test - either mochi (which works like karma),
> or reftest (which is a screenshot to screenshot comparison), which will
> cover loading the resource as part of it.

Also in a new bug, maybe?
(Assignee)

Comment 5

2 years ago
Filed as bug 1316068 and bug 1316069
(Assignee)

Comment 6

2 years ago
https://hg.mozilla.org/projects/larch/rev/4bf4d2d21fb5ea638f76bdcb28b87930bddc35f6
Bug 1288684 - Add basic xpcshell tests for MessageContext and L10nRegistry. r?stas
(Assignee)

Updated

2 years ago
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.