Closed Bug 1237357 Opened 8 years ago Closed 8 years ago

missing Cr used by AddonLocalizationConverter in simpleServices

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(firefox46 fixed)

RESOLVED FIXED
mozilla46
Iteration:
46.2 - Jan 11
Tracking Status
firefox46 --- fixed

People

(Reporter: rpl, Assigned: rpl)

Details

Attachments

(1 file, 2 obsolete files)

Cr is not currently defined in "toolkit/components/utils/simpleServices.js" and this prevents AddonLocalizationConverter to correctly report errors.
Comment on attachment 8704747 [details] [diff] [review]
0001-Bug-1237357-Fix-missing-Cr-used-by-AddonLocalization.patch

Review of attachment 8704747 [details] [diff] [review]:
-----------------------------------------------------------------

I thought I'd already fixed this. Thanks.

Can you also update the test (toolkit/components/extensions/test/xpcshell/test_locale_converter.js) to check that `e.result == Cr.NS_ERROR_INVALID_ARG`? The second to `Assert.throws` can be a function, so something like `e => e.result === Cr.NS_ERROR_INVALID_ARG` should do.
Attachment #8704747 - Flags: review?(kmaglione+bmo)
Assignee: nobody → luca.greco
Patch updated with the suggested change applied to the related test case.

(Thanks Kris! it was exactly what I was searching for: 'where this code is covered by tests and why the issue did not come out before')
Attachment #8704747 - Attachment is obsolete: true
Attachment #8704883 - Flags: review?(kmaglione+bmo)
Iteration: --- → 46.2 - Jan 11
Comment on attachment 8704883 [details] [diff] [review]
0001-Bug-1237357-Fix-missing-Cr-used-by-AddonLocalization.patch

Review of attachment 8704883 [details] [diff] [review]:
-----------------------------------------------------------------

(In reply to Luca Greco [:rpl] from comment #3)
> (Thanks Kris! it was exactly what I was searching for: 'where this code is
> covered by tests and why the issue did not come out before')

Yeah, the test layout is a bit weird. I wrote some quick docs about it
yesterday: https://wiki.mozilla.org/WebExtensions/Hacking#Unit_tests

::: toolkit/components/extensions/test/xpcshell/test_locale_converter.js
@@ +114,1 @@
>    });

Arrow function, please. `e => e.result === Cr.NS_ERROR_INVALID_ARG` or `e => { ...`
Attachment #8704883 - Flags: review?(kmaglione+bmo) → review+
(In reply to Kris Maglione [:kmag] from comment #4)
> Comment on attachment 8704883 [details] [diff] [review]
> 0001-Bug-1237357-Fix-missing-Cr-used-by-AddonLocalization.patch
> 
> Review of attachment 8704883 [details] [diff] [review]:
> -----------------------------------------------------------------
> ::: toolkit/components/extensions/test/xpcshell/test_locale_converter.js
> @@ +114,1 @@
> >    });
> 
> Arrow function, please. `e => e.result === Cr.NS_ERROR_INVALID_ARG` or `e =>
> { ...`

Initially I tried to use an arrow function but Assert.throws complained about the
prototype of the expected (which is the arrow function itself):

ERROR Unexpected exception TypeError: 'prototype' property of expected is not an object at resource://testing-common/Assert.jsm:317
expectedException@resource://testing-common/Assert.jsm:317:1
proto.throws@resource://testing-common/Assert.jsm:358:31
testInvalidUUID@/zfs-tardis/mozlab/desktop/fx-team/obj-x86_64-unknown-linux-gnu/_tests/xpcshell/toolkit/components/extensions/test/xpcshell/test_locale_converter.js:116:3
_run_next_test@/zfs-tardis/mozlab/desktop/fx-team/testing/xpcshell/head.js:1483:9
do_execute_soon/<.run@/zfs-tardis/mozlab/desktop/fx-team/testing/xpcshell/head.js:675:9
_do_main@/zfs-tardis/mozlab/desktop/fx-team/testing/xpcshell/head.js:208:5
_execute_test@/zfs-tardis/mozlab/desktop/fx-team/testing/xpcshell/head.js:535:5
@-e:1:1

it is the first time I'm using the xpcshell tests, so I'm not sure if the issue on retrieving the arrow function prototype is related to its sightly different environment, and unfortunately Assert.jsm check if the actual exception is an instance of expected just before using it as a function:

- https://dxr.mozilla.org/mozilla-central/rev/9d6ffc7a08b6b47056eefe1e652710a3849adbf7/testing/modules/Assert.jsm#317
(In reply to Luca Greco [:rpl] from comment #5)
> (In reply to Kris Maglione [:kmag] from comment #4)
> > Comment on attachment 8704883 [details] [diff] [review]
> > 0001-Bug-1237357-Fix-missing-Cr-used-by-AddonLocalization.patch
> > 
> > Review of attachment 8704883 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > ::: toolkit/components/extensions/test/xpcshell/test_locale_converter.js
> > @@ +114,1 @@
> > >    });
> > 
> > Arrow function, please. `e => e.result === Cr.NS_ERROR_INVALID_ARG` or `e =>
> > { ...`
> 
> Initially I tried to use an arrow function but Assert.throws complained
> about the prototype of the expected (which is the arrow function itself):

OK. Please just add a short comment about why arrow functions don't work,
then.

It might also be worth filing a bug in the testing component to fix
Assert.throws to work with arrow functions.
Patch updated (added a comment about the Assert.throws and arrow function issue, with a reference to the opened Bug 1237961)
Attachment #8704883 - Attachment is obsolete: true
Attachment #8705625 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/af1d9d9f34ec
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: