Bug 1086527 - Make sure PluralForm.get can be called from strict mode. r=Mossop
authorCosmin Malutan <cosmin.malutan@softvision.ro>
Thu, 23 Oct 2014 23:29:00 +0200
changeset 212437 1eb9bb6ee090cc7b23e41058baf2572235e9f9a7
parent 212436 af0e6f52dedf6e5f31b9e2126113d746535b8c0e
child 212438 d65d20dc0ac238dac2379286d8d1ddcd8170ac6b
child 212482 92fa14326d08fdcdac5572bb36fe8e65f5df1698
push id27710
push usercbook@mozilla.com
push dateMon, 27 Oct 2014 14:52:01 +0000
treeherdermozilla-central@d65d20dc0ac2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs1086527
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1086527 - Make sure PluralForm.get can be called from strict mode. r=Mossop
intl/locale/PluralForm.jsm
intl/locale/tests/unit/test_bug1086527.js
intl/locale/tests/unit/xpcshell.ini
--- a/intl/locale/PluralForm.jsm
+++ b/intl/locale/PluralForm.jsm
@@ -130,17 +130,17 @@ this.PluralForm = {
       let words = aWords ? aWords.split(/;/) : [""];
 
       // Explicitly check bounds to avoid strict warnings
       let ret = index < words.length ? words[index] : undefined;
 
       // Check for array out of bounds or empty strings
       if ((ret == undefined) || (ret == "")) {
         // Report the caller to help figure out who is causing badness
-        let caller = PluralForm.get.caller ? PluralForm.get.caller.name : "top";
+        let caller = Components.stack.caller ? Components.stack.caller.name : "top";
 
         // Display a message in the error console
         log(["Index #", index, " of '", aWords, "' for value ", aNum,
             " is invalid -- plural rule #", aRuleNum, "; called by ", caller]);
 
         // Default to the first entry (which might be empty, but not undefined)
         ret = words[0];
       }
new file mode 100644
--- /dev/null
+++ b/intl/locale/tests/unit/test_bug1086527.js
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * This unit test makes sure that PluralForm.get can be called from strict mode
+ */
+
+Components.utils.import("resource://gre/modules/PluralForm.jsm");
+
+delete PluralForm.numForms;
+delete PluralForm.get;
+[PluralForm.get, PluralForm.numForms] = PluralForm.makeGetter(9);
+
+function run_test() {
+  "use strict";
+
+  do_check_eq(3, PluralForm.numForms());
+  do_check_eq("one", PluralForm.get(5, 'one;many'));
+}
--- a/intl/locale/tests/unit/xpcshell.ini
+++ b/intl/locale/tests/unit/xpcshell.ini
@@ -8,11 +8,12 @@ run-if = toolkit == "windows" || toolkit
 
 [test_bug371611.js]
 [test_bug374040.js]
 skip-if = toolkit == "windows" || toolkit == "cocoa"
 
 [test_collation_mac_icu.js]
 run-if = toolkit == "cocoa"
 
+[test_bug1086527.js]
 [test_pluralForm.js]
 [test_pluralForm_english.js]
 [test_pluralForm_makeGetter.js]