Bug 1918300 - Apply bug 1293212 and bug 1628961 to the uikit uriloader. r=nika
[gecko.git] / intl / l10n / test / test_missing_variables.js
blob8c05f7f94f9c8be29acbee2b59c2b38a274c665b
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Disable `xpc::IsInAutomation()` so that missing variables don't throw
5 // errors.
6 Services.prefs.setBoolPref(
7   "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
8   false
9 );
11 /**
12  * The following test demonstrates crashing behavior.
13  */
14 add_task(function test_missing_variables() {
15   const l10nReg = new L10nRegistry();
17   const fs = [
18     { path: "/localization/en-US/browser/test.ftl", source: "welcome-message = Welcome { $user }\n" }
19   ]
20   const locales = ["en-US"];
21   const source = L10nFileSource.createMock("test", "app", locales, "/localization/{locale}", fs);
22   l10nReg.registerSources([source]);
23   const l10n = new Localization(["/browser/test.ftl"], true, l10nReg, locales);
25   {
26     const [message] = l10n.formatValuesSync([{ id: "welcome-message", args: { user: "Greg" } }]);
27     equal(message, "Welcome Greg");
28   }
30   {
31     // This will crash in debug builds.
32     const [message] = l10n.formatValuesSync([{ id: "welcome-message" }]);
33     equal(message, "Welcome {$user}");
34   }
35 });