Bug 1086527 - Make sure PluralForm.get can be called from strict mode. r=Mossop

This commit is contained in:
Cosmin Malutan 2014-10-23 23:29:00 +02:00
Родитель 392ff86c25
Коммит eea1f5cc9b
3 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -135,7 +135,7 @@ this.PluralForm = {
// Check for array out of bounds or empty strings // Check for array out of bounds or empty strings
if ((ret == undefined) || (ret == "")) { if ((ret == undefined) || (ret == "")) {
// Report the caller to help figure out who is causing badness // 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 // Display a message in the error console
log(["Index #", index, " of '", aWords, "' for value ", aNum, log(["Index #", index, " of '", aWords, "' for value ", aNum,

Просмотреть файл

@ -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'));
}

Просмотреть файл

@ -13,6 +13,7 @@ skip-if = toolkit == "windows" || toolkit == "cocoa"
[test_collation_mac_icu.js] [test_collation_mac_icu.js]
run-if = toolkit == "cocoa" run-if = toolkit == "cocoa"
[test_bug1086527.js]
[test_pluralForm.js] [test_pluralForm.js]
[test_pluralForm_english.js] [test_pluralForm_english.js]
[test_pluralForm_makeGetter.js] [test_pluralForm_makeGetter.js]