... |
... |
@@ -142,18 +142,23 @@ async function createDictionaryBrowseResults() { |
142
|
142
|
return dir;
|
143
|
143
|
}
|
144
|
144
|
|
145
|
|
-function assertLocaleOrder(list, locales) {
|
|
145
|
+function assertLocaleOrder(list, locales, selectedLocale) {
|
146
|
146
|
is(
|
147
|
147
|
list.itemCount,
|
148
|
148
|
locales.split(",").length,
|
149
|
|
- "The right number of locales are selected"
|
|
149
|
+ "The right number of locales are in the list"
|
150
|
150
|
);
|
151
|
151
|
is(
|
152
|
152
|
Array.from(list.children)
|
153
|
153
|
.map(child => child.value)
|
154
|
154
|
.join(","),
|
155
|
155
|
locales,
|
156
|
|
- "The selected locales are in order"
|
|
156
|
+ "The listed locales are in order"
|
|
157
|
+ );
|
|
158
|
+ is(
|
|
159
|
+ list.selectedItem.value,
|
|
160
|
+ selectedLocale,
|
|
161
|
+ "The selected item locale matches"
|
157
|
162
|
);
|
158
|
163
|
}
|
159
|
164
|
|
... |
... |
@@ -219,6 +224,11 @@ async function selectLocale(localeCode, available, selected, dialogDoc) { |
219
|
224
|
await added;
|
220
|
225
|
}
|
221
|
226
|
|
|
227
|
+// Select a locale from the list of already added locales.
|
|
228
|
+function selectAddedLocale(localeCode, selected) {
|
|
229
|
+ selected.selectedItem = selected.querySelector(`[value="${localeCode}"]`);
|
|
230
|
+}
|
|
231
|
+
|
222
|
232
|
async function openDialog(doc, search = false) {
|
223
|
233
|
let dialogLoaded = promiseLoadSubDialog(BROWSER_LANGUAGES_URL);
|
224
|
234
|
if (search) {
|
... |
... |
@@ -283,7 +293,7 @@ add_task(async function testDisabledBrowserLanguages() { |
283
|
293
|
// pl is not selected since it's disabled.
|
284
|
294
|
is(pl.userDisabled, true, "pl is disabled");
|
285
|
295
|
is(pl.version, "1.0", "pl is the old 1.0 version");
|
286
|
|
- assertLocaleOrder(selected, "en-US,he");
|
|
296
|
+ assertLocaleOrder(selected, "en-US,he", "en-US");
|
287
|
297
|
|
288
|
298
|
// Wait for the children menu to be populated.
|
289
|
299
|
await BrowserTestUtils.waitForCondition(
|
... |
... |
@@ -313,7 +323,7 @@ add_task(async function testDisabledBrowserLanguages() { |
313
|
323
|
|
314
|
324
|
// Add pl.
|
315
|
325
|
await selectLocale("pl", available, selected, dialogDoc);
|
316
|
|
- assertLocaleOrder(selected, "pl,en-US,he");
|
|
326
|
+ assertLocaleOrder(selected, "pl,en-US,he", "pl");
|
317
|
327
|
|
318
|
328
|
// Find pl again since it's been upgraded.
|
319
|
329
|
pl = await AddonManager.getAddonByID(langpackId("pl"));
|
... |
... |
@@ -371,12 +381,12 @@ add_task(async function testReorderingBrowserLanguages() { |
371
|
381
|
let firstDialogId = getDialogId(dialogDoc);
|
372
|
382
|
|
373
|
383
|
// The initial order is set by the pref, filtered by available.
|
374
|
|
- assertLocaleOrder(selected, "en-US,pl,he");
|
|
384
|
+ assertLocaleOrder(selected, "en-US,pl,he", "en-US");
|
375
|
385
|
|
376
|
386
|
// Moving pl down changes the order.
|
377
|
|
- selected.selectedItem = selected.querySelector("[value='pl']");
|
|
387
|
+ selectAddedLocale("pl", selected);
|
378
|
388
|
dialogDoc.getElementById("down").doCommand();
|
379
|
|
- assertLocaleOrder(selected, "en-US,he,pl");
|
|
389
|
+ assertLocaleOrder(selected, "en-US,he,pl", "pl");
|
380
|
390
|
|
381
|
391
|
// Accepting the change shows the confirm message bar.
|
382
|
392
|
let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "dialogclosing");
|
... |
... |
@@ -404,13 +414,13 @@ add_task(async function testReorderingBrowserLanguages() { |
404
|
414
|
selected = newDialog.selected;
|
405
|
415
|
|
406
|
416
|
// The initial order comes from the previous settings.
|
407
|
|
- assertLocaleOrder(selected, "en-US,he,pl");
|
|
417
|
+ assertLocaleOrder(selected, "en-US,he,pl", "en-US");
|
408
|
418
|
|
409
|
419
|
// Select pl in the list.
|
410
|
|
- selected.selectedItem = selected.querySelector("[value='pl']");
|
|
420
|
+ selectAddedLocale("pl", selected);
|
411
|
421
|
// Move pl back up.
|
412
|
422
|
dialogDoc.getElementById("up").doCommand();
|
413
|
|
- assertLocaleOrder(selected, "en-US,pl,he");
|
|
423
|
+ assertLocaleOrder(selected, "en-US,pl,he", "pl");
|
414
|
424
|
|
415
|
425
|
// Accepting the change hides the confirm message bar.
|
416
|
426
|
dialogClosed = BrowserTestUtils.waitForEvent(dialog, "dialogclosing");
|
... |
... |
@@ -485,25 +495,42 @@ add_task(async function testAddAndRemoveSelectedLanguages() { |
485
|
495
|
}
|
486
|
496
|
);
|
487
|
497
|
// The initial order is set by the pref.
|
488
|
|
- assertLocaleOrder(selected, "en-US");
|
|
498
|
+ assertLocaleOrder(selected, "en-US", "en-US");
|
489
|
499
|
assertAvailableLocales(available, ["fr", "pl", "he"]);
|
490
|
500
|
|
|
501
|
+ let removeButton = dialogDoc.getElementById("remove");
|
|
502
|
+ // Cannot remove the default locale.
|
|
503
|
+ is(removeButton.disabled, true, "Remove en-US should be disabled");
|
|
504
|
+
|
491
|
505
|
// Add pl and fr to selected.
|
492
|
506
|
await selectLocale("pl", available, selected, dialogDoc);
|
493
|
507
|
await selectLocale("fr", available, selected, dialogDoc);
|
494
|
508
|
|
495
|
|
- assertLocaleOrder(selected, "fr,pl,en-US");
|
|
509
|
+ assertLocaleOrder(selected, "fr,pl,en-US", "fr");
|
496
|
510
|
assertAvailableLocales(available, ["he"]);
|
497
|
511
|
|
|
512
|
+ // Can remove the added locale again.
|
|
513
|
+ is(removeButton.disabled, false, "Remove fr should be not be disabled");
|
|
514
|
+
|
|
515
|
+ selectAddedLocale("en-US", selected);
|
|
516
|
+ // Cannot remove the default locale, even after adding more.
|
|
517
|
+ is(removeButton.disabled, true, "Remove en-us should still be disabled");
|
|
518
|
+
|
498
|
519
|
// Remove pl and fr from selected.
|
499
|
|
- dialogDoc.getElementById("remove").doCommand();
|
500
|
|
- dialogDoc.getElementById("remove").doCommand();
|
501
|
|
- assertLocaleOrder(selected, "en-US");
|
|
520
|
+ selectAddedLocale("fr", selected);
|
|
521
|
+ is(removeButton.disabled, false, "Remove fr should be not be disabled");
|
|
522
|
+ removeButton.doCommand();
|
|
523
|
+ // Selection moves to pl.
|
|
524
|
+ assertLocaleOrder(selected, "pl,en-US", "pl");
|
|
525
|
+ is(removeButton.disabled, false, "Remove pl should be not be disabled");
|
|
526
|
+ removeButton.doCommand();
|
|
527
|
+ assertLocaleOrder(selected, "en-US", "en-US");
|
502
|
528
|
assertAvailableLocales(available, ["fr", "pl", "he"]);
|
|
529
|
+ is(removeButton.disabled, true, "Remove en-us should be disabled at end");
|
503
|
530
|
|
504
|
531
|
// Add he to selected.
|
505
|
532
|
await selectLocale("he", available, selected, dialogDoc);
|
506
|
|
- assertLocaleOrder(selected, "he,en-US");
|
|
533
|
+ assertLocaleOrder(selected, "he,en-US", "he");
|
507
|
534
|
assertAvailableLocales(available, ["pl", "fr"]);
|
508
|
535
|
|
509
|
536
|
// Accepting the change shows the confirm message bar.
|
... |
... |
@@ -603,7 +630,7 @@ add_task(async function testInstallFromAMO() { |
603
|
630
|
}
|
604
|
631
|
|
605
|
632
|
// The initial order is set by the pref.
|
606
|
|
- assertLocaleOrder(selected, "en-US");
|
|
633
|
+ assertLocaleOrder(selected, "en-US", "en-US");
|
607
|
634
|
assertAvailableLocales(available, ["fr", "he", "pl"]);
|
608
|
635
|
is(
|
609
|
636
|
Services.locale.availableLocales.join(","),
|
... |
... |
@@ -633,7 +660,7 @@ add_task(async function testInstallFromAMO() { |
633
|
660
|
);
|
634
|
661
|
|
635
|
662
|
// Verify the list is correct.
|
636
|
|
- assertLocaleOrder(selected, "pl,en-US");
|
|
663
|
+ assertLocaleOrder(selected, "pl,en-US", "pl");
|
637
|
664
|
assertAvailableLocales(available, ["fr", "he"]);
|
638
|
665
|
is(
|
639
|
666
|
Services.locale.availableLocales.sort().join(","),
|
... |
... |
@@ -658,7 +685,7 @@ add_task(async function testInstallFromAMO() { |
658
|
685
|
|
659
|
686
|
// Move pl down the list, which prevents an error since it isn't valid.
|
660
|
687
|
dialogDoc.getElementById("down").doCommand();
|
661
|
|
- assertLocaleOrder(selected, "en-US,pl");
|
|
688
|
+ assertLocaleOrder(selected, "en-US,pl", "pl");
|
662
|
689
|
|
663
|
690
|
// Test that disabling the langpack removes it from the list.
|
664
|
691
|
let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "dialogclosing");
|
... |
... |
@@ -683,7 +710,7 @@ add_task(async function testInstallFromAMO() { |
683
|
710
|
target => available.itemCount > 1
|
684
|
711
|
);
|
685
|
712
|
}
|
686
|
|
- assertLocaleOrder(selected, "en-US");
|
|
713
|
+ assertLocaleOrder(selected, "en-US", "en-US");
|
687
|
714
|
assertAvailableLocales(available, ["fr", "he", "pl"]);
|
688
|
715
|
|
689
|
716
|
// Uninstall the langpack and dictionary.
|