Closed
Bug 1086527
Opened 9 years ago
Closed 9 years ago
PluralForm.jsm calls PluralForm.get.caller which is not allowed in "strict mode";
Categories
(Core :: Internationalization: Localization, defect)
Core
Internationalization: Localization
Tracking
()
RESOLVED
FIXED
mozilla36
People
(Reporter: cosmin-malutan, Assigned: cosmin-malutan)
References
Details
(Whiteboard: [mozmill])
Attachments
(2 files, 2 obsolete files)
1.71 MB,
image/png
|
Details | |
2.36 KB,
patch
|
mossop
:
review+
lsblakk
:
approval-mozilla-aurora+
lsblakk
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
If we don't have a rule for this locale it should default to English and not to Chinese, this will throw a TypeError. For exaple in bug 1086238 for CSB locale it won't show the "showAllSearchResults" lable in AddonsManager when searching for addons because the rule for getting the plural form is broken. https://hg.mozilla.org/releases/mozilla-aurora/file/b79894a533bc/intl/locale/PluralForm.jsm#l39 https://hg.mozilla.org/releases/mozilla-aurora/file/b79894a533bc/intl/locale/PluralForm.jsm#l116
Assignee | ||
Comment 1•9 years ago
|
||
Here is the xpcshell-test as requested in bug 1086238 comment 7.
Assignee | ||
Comment 2•9 years ago
|
||
Comment on attachment 8508673 [details] [diff] [review] testcase patch Sorry for that it seems that I misunderstood why it failed the plural rule is set correctly for CSB locale, the only issue her is that we call "caller" in strict mode. https://hg.mozilla.org/releases/mozilla-aurora/file/b79894a533bc/intl/locale/PluralForm.jsm#l138 > 1413892505715 addons.manager WARN Exception calling callback: TypeError: access to strict mode caller function is censored (resource://gre/modules/PluralForm.jsm:138:12) JS Stack trace: > this.PluralForm.makeGetter/ > @PluralForm.jsm:138:13 > gSearchView_showAllResultsLink@extensions.js:2478:15 > gSearchView_updateView@extensions.js:2414:7
Attachment #8508673 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Summary: PluralForm.jsm should default to English pluralRule instead it defaults to the first one which is Chinese → PluralForm.jsm calls PluralForm.get.caller which is not allowed in "strict mode";
Comment 3•9 years ago
|
||
resummarizing, to make this clearer: In a browser context in scratchpad, Components.utils.import("resource://gre/modules/PluralForm.jsm"); [getPlurals, numForms] = PluralForm.makeGetter(9); numForms() getPlurals(5, 'one;many') results in PluralForm.jsm: Index #2 of 'one;many' for value 5 is invalid -- plural rule #9; called by top in the browser console. It also returns "one" as result. Which is the first entry in the list, and thus always there (it's not the chinese plural form, though). The culprit which makes the tests fail in bug 1086238 seems to be that the "called by top" part is TypeError: access to strict mode caller function is censored (resource://gre/modules/PluralForm.jsm:138:12) in mozmill tests, though. We should make the code not fail this hard if possible.
Assignee | ||
Comment 4•9 years ago
|
||
(In reply to Axel Hecht [:Pike] from comment #3) > The culprit which makes the tests fail in bug 1086238 seems to be that the > "called by top" part is > > TypeError: access to strict mode caller function is censored > (resource://gre/modules/PluralForm.jsm:138:12) > > in mozmill tests, though. We should make the code not fail this hard if > possible. This has been caught by mozmill, but has nothing to do with the mozmill code itself, it reproduces manually, and it's a real Firefox bug as you can see in the print-screen attached. In AddonsManager when it creates the allResultsLink, it calls PluralForm.get from strict mode, this will try to access the function callers name, this throws an TypeError exception and brakes the code, resulting in a failure of displaying the allResultsLink and dispatching the ViewChanged event. http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/content/extensions.js?rev=8d3304b7e0e0#2480 What I suggest is to try/catch the calling of PluralForm.get.caller.
Assignee: nobody → cosmin.malutan
Status: NEW → ASSIGNED
Assignee | ||
Comment 5•9 years ago
|
||
Here is a fix-patch, whithout the fix, the test will fail with failure it fails in AddonsManager.
Attachment #8509300 -
Attachment is obsolete: true
Attachment #8509304 -
Flags: review?(l10n)
Attachment #8509304 -
Flags: review?(dtownsend+bugmail)
Updated•9 years ago
|
Attachment #8509300 -
Attachment is obsolete: false
Comment 6•9 years ago
|
||
Comment on attachment 8509304 [details] [diff] [review] patch v1.0 Review of attachment 8509304 [details] [diff] [review]: ----------------------------------------------------------------- I don't feel more confident than giving an f+, but this looks good to me.
Attachment #8509304 -
Flags: review?(l10n) → feedback+
Comment 7•9 years ago
|
||
Comment on attachment 8509304 [details] [diff] [review] patch v1.0 Review of attachment 8509304 [details] [diff] [review]: ----------------------------------------------------------------- ::: intl/locale/PluralForm.jsm @@ +138,5 @@ > + try { > + var caller = PluralForm.get.caller ? PluralForm.get.caller.name : "top"; > + } catch (e if e instanceof TypeError) { > + var caller = "top"; > + } Using Components.stack.caller.name instead should allow this to work even in strict mode.
Attachment #8509304 -
Flags: review?(dtownsend+bugmail) → review-
Comment 8•9 years ago
|
||
Also please in the future attach patches with 8 lines of context, it makes reviewing easier.
Assignee | ||
Comment 9•9 years ago
|
||
Thanks, that worked perfectly. Can't wait to see the bug in Addons-Manager gone.
Attachment #8509304 -
Attachment is obsolete: true
Attachment #8510842 -
Flags: review?(dtownsend+bugmail)
status-firefox35:
--- → affected
Updated•9 years ago
|
status-firefox34:
--- → affected
status-firefox36:
--- → affected
If this is affecting 34 too, it might be good to uplift. It seems low risk but will fix a problem in the Add-ons Manager for several locales on Ubuntu. Cosmin, if you think it's a good idea, can you request uplift to 34? (and 35, since I think this would otherwise ride the trains from 36 onward) Also, was this discovered from mozmill/jenkins tests? For bugs we uncover using it, should we tag them (I think just tagging it [mozmill] in the whiteboard (I could be wrong here, check with whimboo)
Updated•9 years ago
|
Whiteboard: [mozmill]
Comment 11•9 years ago
|
||
Comment on attachment 8510842 [details] [diff] [review] patch v2.0 Review of attachment 8510842 [details] [diff] [review]: ----------------------------------------------------------------- Great!
Attachment #8510842 -
Flags: review?(dtownsend+bugmail) → review+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 12•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/1eb9bb6ee090
Keywords: checkin-needed
Comment 13•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/1eb9bb6ee090
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Assignee | ||
Comment 14•9 years ago
|
||
As Liz mentioned in comment 10 it would be nice to have this uplifted up to 34, it's a small fix that fixes a bug in Beta.
Assignee | ||
Comment 15•9 years ago
|
||
Comment on attachment 8510842 [details] [diff] [review] patch v2.0 Approval Request Comment [Feature/regressing bug #]: [User impact if declined]: User can't see the "Show all add-ons link" in addon-manager in certain locales, see the screen-shot from attachment [Describe test coverage new/current, TBPL]: A new xpcshell test has been made to cover this regression [Risks and why]: Low risk, we just call a different function that works in "strict mode" so it won't throw [String/UUID change made/needed]: none
Attachment #8510842 -
Flags: approval-mozilla-beta?
Attachment #8510842 -
Flags: approval-mozilla-aurora?
Updated•9 years ago
|
Comment 16•9 years ago
|
||
Comment on attachment 8510842 [details] [diff] [review] patch v2.0 This doesn't need to be tracked, but we'll take the low risk uplift.
Attachment #8510842 -
Flags: approval-mozilla-beta?
Attachment #8510842 -
Flags: approval-mozilla-beta+
Attachment #8510842 -
Flags: approval-mozilla-aurora?
Attachment #8510842 -
Flags: approval-mozilla-aurora+
Comment 17•9 years ago
|
||
https://hg.mozilla.org/releases/mozilla-aurora/rev/0901daef7f2c https://hg.mozilla.org/releases/mozilla-beta/rev/363ef26f9bee
You need to log in
before you can comment on or make changes to this bug.
Description
•