1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Basic tests for the Migration Wizard component</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script src="head-common.js"></script>
<script
src="chrome://browser/content/migration/migration-wizard.mjs"
type="module"
></script>
<link
rel="stylesheet"
href="chrome://mochikit/content/tests/SimpleTest/test.css"
/>
<script>
/* import-globals-from ../head-common.js */
"use strict";
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
const MIGRATOR_PROFILE_INSTANCES = [
{
key: "some-browser-0",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 0",
resourceTypes: ["HISTORY", "FORMDATA", "PASSWORDS", "BOOKMARKS", "EXTENSIONS"],
profile: { id: "person-2", name: "Person 2" },
hasPermissions: true,
},
{
key: "some-browser-1",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 1",
resourceTypes: ["HISTORY", "BOOKMARKS"],
profile: null,
hasPermissions: true,
},
];
let gWiz = null;
let gShadowRoot = null;
let gDeck = null;
/**
* Returns the .resource-progress-group div for a particular resource
* type.
*
* @param {string} displayedResourceType
* One of the constants belonging to
* MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.
* @returns {Element}
*/
function getResourceGroup(displayedResourceType) {
return gShadowRoot.querySelector(
`.resource-progress-group[data-resource-type="${displayedResourceType}"]`
);
}
add_setup(async function() {
gWiz = document.getElementById("test-wizard");
gShadowRoot = gWiz.openOrClosedShadowRoot;
gDeck = gShadowRoot.querySelector("#wizard-deck");
});
/**
* Tests that the MigrationWizard:RequestState event is fired when the
* <migration-wizard> is added to the DOM if the auto-request-state attribute
* is set, and then ensures that the starting page is correct.
*
* This also tests that the MigrationWizard:RequestState is not fired automatically
* if the auto-request-state attribute is not set, but is then fired upon calling
* requestState().
*
* This uses a dynamically created <migration-wizard> instead of the one already
* in the content div to make sure that the init event is captured.
*/
add_task(async function test_init_event() {
const REQUEST_STATE_EVENT = "MigrationWizard:RequestState";
let wiz = document.createElement("migration-wizard");
wiz.toggleAttribute("auto-request-state", true);
let content = document.getElementById("content");
let promise = new Promise(resolve => {
content.addEventListener(REQUEST_STATE_EVENT, resolve, {
once: true,
});
});
content.appendChild(wiz);
await promise;
ok(true, `Saw ${REQUEST_STATE_EVENT} event.`);
let shadowRoot = wiz.openOrClosedShadowRoot;
let deck = shadowRoot.querySelector("#wizard-deck");
is(
deck.selectedViewName,
"page-loading",
"Should have the loading page selected"
);
wiz.remove();
wiz.toggleAttribute("auto-request-state", false);
let sawEvent = false;
let handler = () => {
sawEvent = true;
};
content.addEventListener(REQUEST_STATE_EVENT, handler);
content.appendChild(wiz);
ok(!sawEvent, `Should not have seen ${REQUEST_STATE_EVENT} event.`);
content.removeEventListener(REQUEST_STATE_EVENT, handler);
promise = new Promise(resolve => {
content.addEventListener(REQUEST_STATE_EVENT, resolve, {
once: true,
});
});
wiz.requestState();
await promise;
ok(true, `Saw ${REQUEST_STATE_EVENT} event.`);
wiz.remove();
});
/**
* Tests that the wizard can show a list of browser and profiles.
*/
add_task(async function test_selection() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: false,
});
let selector = gShadowRoot.querySelector("#browser-profile-selector");
let preamble = gShadowRoot.querySelector(".resource-selection-preamble");
ok(!isHidden(preamble), "preamble should shown.");
let panelList = gShadowRoot.querySelector("panel-list");
is(panelList.childElementCount, 2, "Should have two child elements");
let resourceTypeList = gShadowRoot.querySelector("#resource-type-list");
let details = gShadowRoot.querySelector("details");
ok(details.open, "Details should be open");
// Test that the resource type checkboxes are shown or hidden depending on
// which resourceTypes are included with the MigratorProfileInstance.
for (let migratorInstance of MIGRATOR_PROFILE_INSTANCES) {
synthesizeMouseAtCenter(selector, {}, gWiz.ownerGlobal);
await new Promise(resolve => {
gShadowRoot
.querySelector("panel-list")
.addEventListener("shown", resolve, { once: true });
});
let panelItem = gShadowRoot.querySelector(
`panel-item[key="${migratorInstance.key}"]`
);
ok(panelItem, "Should find panel-item.");
panelItem.click();
is(
selector.querySelector("#migrator-name").textContent,
migratorInstance.displayName,
"Selector should show display name"
);
let profileName = selector.querySelector("#profile-name");
if (migratorInstance.profile) {
ok(!isHidden(profileName), "Profile name element should be displayed.");
is(
profileName.textContent,
migratorInstance.profile.name,
"Selector should show profile name"
);
} else {
ok(isHidden(profileName), "Profile name element should be hidden.");
is(profileName.textContent, "");
}
for (let resourceType of getChoosableResourceTypes()) {
let node = resourceTypeList.querySelector(
`label[data-resource-type="${resourceType}"]`
);
if (migratorInstance.resourceTypes.includes(resourceType)) {
ok(!isHidden(node), `Selection for ${resourceType} should be shown.`);
ok(
node.control.checked,
`Checkbox for ${resourceType} should be checked.`
);
} else {
ok(isHidden(node), `Selection for ${resourceType} should be hidden.`);
ok(
!node.control.checked,
`Checkbox for ${resourceType} should be unchecked.`
);
}
}
}
let selectAll = gShadowRoot.querySelector("#select-all");
let summary = gShadowRoot.querySelector("summary");
ok(isHidden(selectAll), "Selection for select-all should be hidden.");
ok(isHidden(summary), "Summary should be hidden.");
ok(!isHidden(details), "Details should be shown.");
});
/**
* Tests the migration wizard with no resources
*/
add_task(async function test_no_resources() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key: "some-browser-0",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 0 with no resources",
resourceTypes: [],
profile: { id: "person-1", name: "Person 1" },
hasPermissions: true,
}],
showImportAll: false,
});
let noResourcesFound = gShadowRoot.querySelector(".no-resources-found");
let hideOnErrorEls = gShadowRoot.querySelectorAll(".hide-on-error");
ok(
!isHidden(noResourcesFound),
"Error message of no reasources should be shown."
);
for (let hideOnErrorEl of hideOnErrorEls) {
ok(isHidden(hideOnErrorEl), "Item should be hidden.");
}
});
/**
* Tests variant 2 of the migration wizard
*/
add_task(async function test_selection_variant_2() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: true,
});
let preamble = gShadowRoot.querySelector(".resource-selection-preamble");
ok(isHidden(preamble), "preamble should be hidden.");
let selector = gShadowRoot.querySelector("#browser-profile-selector");
synthesizeMouseAtCenter(selector, {}, gWiz.ownerGlobal);
await new Promise(resolve => {
let panelList = gShadowRoot.querySelector("panel-list");
if (panelList) {
panelList.addEventListener("shown", resolve, { once: true });
}
});
let panelItems = gShadowRoot.querySelectorAll("panel-list > panel-item");
is(panelItems.length, 2, "Should have two panel items");
let details = gShadowRoot.querySelector("details");
ok(!details.open, "Details should be closed");
details.open = true;
for (let i = 0; i < panelItems.length; i++) {
let migratorInstance = MIGRATOR_PROFILE_INSTANCES[i];
let panelItem = panelItems[i];
panelItem.click();
for (let resourceType of getChoosableResourceTypes()) {
let node = gShadowRoot.querySelector(
`#resource-type-list label[data-resource-type="${resourceType}"]`
);
if (migratorInstance.resourceTypes.includes(resourceType)) {
ok(!isHidden(node), `Selection for ${resourceType} should be shown.`);
ok(
node.control.checked,
`Checkbox for ${resourceType} should be checked.`
);
} else {
ok(isHidden(node), `Selection for ${resourceType} should be hidden.`);
ok(
!node.control.checked,
`Checkbox for ${resourceType} should be unchecked.`
);
}
}
}
let selectAll = gShadowRoot.querySelector("#select-all");
let summary = gShadowRoot.querySelector("summary");
ok(!isHidden(selectAll), "Selection for select-all should be shown.");
ok(selectAll.control.checked, "Checkbox for select-all should be checked.");
ok(!isHidden(summary), "Summary should be shown.");
ok(!isHidden(details), "Details should be shown.");
let selectAllCheckbox = gShadowRoot.querySelector(".select-all-checkbox");
selectAllCheckbox.checked = true;
selectAllCheckbox.dispatchEvent(new CustomEvent("change"));
let resourceLabels = gShadowRoot.querySelectorAll("label[data-resource-type]");
for (let resourceLabel of resourceLabels) {
if (resourceLabel.hidden) {
ok(
!resourceLabel.control.checked,
`Hidden checkbox for ${resourceLabel.dataset.resourceType} should be unchecked.`
);
} else {
ok(
resourceLabel.control.checked,
`Visible checkbox for ${resourceLabel.dataset.resourceType} should be checked.`
);
}
}
let selectedDataHeader = gShadowRoot.querySelector(".selected-data-header");
let selectedData = gShadowRoot.querySelector(".selected-data");
let bookmarks = gShadowRoot.querySelector("#bookmarks");
let history = gShadowRoot.querySelector("#history");
let selectedDataUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
bookmarks.control.checked = true;
history.control.checked = true;
bookmarks.dispatchEvent(new CustomEvent("change"));
ok(bookmarks.control.checked, "Bookmarks should be checked");
ok(history.control.checked, "History should be checked");
await selectedDataUpdated;
is(
selectedData.textContent,
"Bookmarks and history",
"Testing if selected-data reflects the selected resources."
);
is(
selectedDataHeader.dataset.l10nId,
"migration-all-available-data-label",
"Testing if selected-data-header reflects the selected resources"
);
let importButton = gShadowRoot.querySelector("#import");
ok(
!importButton.disabled,
"Testing if import button is enabled when at least one resource is selected."
);
let importButtonUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
selectAllCheckbox.checked = false;
selectAllCheckbox.dispatchEvent(new CustomEvent("change", { bubbles: true }));
await importButtonUpdated;
ok(
importButton.disabled,
"Testing if import button is disabled when no resources are selected."
);
});
/**
* Tests variant 2 of the migration wizard when there's a single resource
* item.
*/
add_task(async function test_selection_variant_2_single_item() {
let resourcesUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key: "some-browser-0",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 0 with a single resource",
resourceTypes: ["HISTORY"],
profile: { id: "person-1", name: "Person 1" },
hasPermissions: true,
}, {
key: "some-browser-1",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 1 with a two resources",
resourceTypes: ["HISTORY", "BOOKMARKS"],
profile: { id: "person-2", name: "Person 2" },
hasPermissions: true,
}],
showImportAll: true,
});
await resourcesUpdated;
let selectAll = gShadowRoot.querySelector("#select-all");
let summary = gShadowRoot.querySelector("summary");
let details = gShadowRoot.querySelector("details");
ok(!details.open, "Details should be closed");
details.open = true;
ok(isHidden(selectAll), "Selection for select-all should be hidden.");
ok(!isHidden(summary), "Summary should be shown.");
ok(!isHidden(details), "Details should be shown.");
resourcesUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
let browser1Item = gShadowRoot.querySelector("panel-item[key='some-browser-1']");
browser1Item.click();
await resourcesUpdated;
ok(!isHidden(selectAll), "Selection for select-all should be shown.");
ok(!isHidden(summary), "Summary should be shown.");
ok(!isHidden(details), "Details should be shown.");
});
/**
* Tests that the Select All checkbox is checked if all non-hidden resource
* types are checked, and unchecked otherwise.
*/
add_task(async function test_selection_variant_2_select_all() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: true,
});
let details = gShadowRoot.querySelector("details");
ok(!details.open, "Details should be closed");
details.open = true;
let selectAll = gShadowRoot.querySelector("#select-all");
ok(selectAll.control.checked, "Select all should be checked by default");
let bookmarksResourceLabel = gShadowRoot.querySelector(
"label[data-resource-type='BOOKMARKS']"
);
ok(bookmarksResourceLabel.control.checked, "Bookmarks should be checked");
bookmarksResourceLabel.control.click();
ok(!bookmarksResourceLabel.control.checked, "Bookmarks should no longer be checked");
ok(!selectAll.control.checked, "Select all should not longer be checked");
bookmarksResourceLabel.control.click();
ok(bookmarksResourceLabel.control.checked, "Bookmarks should be checked again");
ok(selectAll.control.checked, "Select all should be checked");
});
/**
* Tests that the wizard can show partial progress during migration.
*/
add_task(async function test_partial_progress() {
const BOOKMARKS_SUCCESS_STRING = "Some bookmarks success string";
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: BOOKMARKS_SUCCESS_STRING,
},
// Don't include PASSWORDS to check that it's hidden.
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.HISTORY]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
},
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
},
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.FORMDATA]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
},
},
});
is(
gDeck.selectedViewName,
"page-progress",
"Should have the progress page selected"
);
// Bookmarks
let bookmarksGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS
);
ok(!isHidden(bookmarksGroup), "Bookmarks group should be visible");
let progressIcon = bookmarksGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
bookmarksGroup.querySelector(".message-text").textContent,
BOOKMARKS_SUCCESS_STRING
);
// Passwords
let passwordsGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.PASSWORDS
);
ok(isHidden(passwordsGroup), "Passwords group should be hidden");
// History
let historyGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.HISTORY
);
ok(!isHidden(historyGroup), "History group should be visible");
progressIcon = historyGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(historyGroup.querySelector(".message-text").textContent.trim(), "");
// Extensions
let extensionsGroup = getResourceGroup(MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS);
ok(!isHidden(extensionsGroup), "Extensions group should be visible");
progressIcon = extensionsGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(extensionsGroup.querySelector("a.message-text").textContent.trim(), "");
is(extensionsGroup.querySelector("span.message-text").textContent.trim(), "");
// Form Data
let formDataGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.FORMDATA
);
ok(!isHidden(formDataGroup), "Form data group should be visible");
progressIcon = formDataGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(formDataGroup.querySelector(".message-text").textContent.trim(), "");
// With progress still being underway, the header should be using the
// in progress string.
let header = gShadowRoot.querySelector("#progress-header");
is(
header.getAttribute("data-l10n-id"),
"migration-wizard-progress-header",
"Should be showing in-progress header string"
);
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(isHidden(doneButton), "Done button should be hidden");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(!isHidden(cancelButton), "Cancel button should be visible");
ok(cancelButton.disabled, "Cancel button should be disabled");
});
/**
* Tests that the wizard can show completed migration progress.
*/
add_task(async function test_completed_progress() {
const BOOKMARKS_SUCCESS_STRING = "Some bookmarks success string";
const PASSWORDS_SUCCESS_STRING = "Some passwords success string";
const FORMDATA_SUCCESS_STRING = "Some formdata string";
const EXTENSIONS_SUCCESS_STRING = "Some extensions string";
const EXTENSIONS_SUCCESS_HREF = "about:addons";
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: BOOKMARKS_SUCCESS_STRING,
},
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.PASSWORDS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: PASSWORDS_SUCCESS_STRING,
},
// Don't include HISTORY to check that it's hidden.
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: EXTENSIONS_SUCCESS_STRING,
},
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.FORMDATA]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: FORMDATA_SUCCESS_STRING,
},
},
});
is(
gDeck.selectedViewName,
"page-progress",
"Should have the progress page selected"
);
// Bookmarks
let bookmarksGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS
);
ok(!isHidden(bookmarksGroup), "Bookmarks group should be visible");
let progressIcon = bookmarksGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
bookmarksGroup.querySelector(".message-text").textContent,
BOOKMARKS_SUCCESS_STRING
);
// Passwords
let passwordsGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.PASSWORDS
);
ok(!isHidden(passwordsGroup), "Passwords group should be visible");
progressIcon = passwordsGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
passwordsGroup.querySelector(".message-text").textContent,
PASSWORDS_SUCCESS_STRING
);
// History
let historyGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.HISTORY
);
ok(isHidden(historyGroup), "History group should be hidden");
// Extensions
let extensionsDataGroup = getResourceGroup(MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS);
ok(!isHidden(extensionsDataGroup), "Extensions data group should be visible");
progressIcon = extensionsDataGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
extensionsDataGroup.querySelector("a.message-text").textContent,
EXTENSIONS_SUCCESS_STRING
);
is(
extensionsDataGroup.querySelector("a.message-text").href,
EXTENSIONS_SUCCESS_HREF
)
// Form Data
let formDataGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.FORMDATA
);
ok(!isHidden(formDataGroup), "Form data group should be visible");
progressIcon = formDataGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
formDataGroup.querySelector(".message-text").textContent,
FORMDATA_SUCCESS_STRING
);
// With progress being complete, the header should be using the completed
// migration string.
let header = gShadowRoot.querySelector("#progress-header");
is(
header.getAttribute("data-l10n-id"),
"migration-wizard-progress-done-header",
"Should be showing completed migration header string"
);
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(!isHidden(doneButton), "Done button should be visible and enabled");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
});
add_task(async function test_extension_partial_success() {
const EXTENSIONS_INFO_STRING = "Extensions info string";
const EXTENSIONS_INFO_HREF = "about:addons";
const EXTENSIONS_SUPPORT_STRING = "extensions support string";
const EXTENSIONS_SUPPORT_HREF = "about:blank";
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.INFO,
message: EXTENSIONS_INFO_STRING,
linkText: EXTENSIONS_SUPPORT_STRING,
linkURL: EXTENSIONS_SUPPORT_HREF,
}
}
});
is(
gDeck.selectedViewName,
"page-progress",
"Should have the progress page selected"
);
let extensionsGroup = getResourceGroup(MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS);
ok(!isHidden(extensionsGroup), "Extensions group should be visible");
let progressIcon = extensionsGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"info",
"Progress should be completed, in info state"
);
is(
extensionsGroup.querySelector("a.message-text").textContent,
EXTENSIONS_INFO_STRING
);
is(
extensionsGroup.querySelector("a.message-text").href,
EXTENSIONS_INFO_HREF
);
is(
extensionsGroup.querySelector("a.message-text").target,
"_blank"
);
is(
extensionsGroup.querySelector(".support-text").textContent,
EXTENSIONS_SUPPORT_STRING
);
is(
extensionsGroup.querySelector(".support-text").href,
EXTENSIONS_SUPPORT_HREF
);
is(
extensionsGroup.querySelector(".support-text").target,
"_blank"
);
// With progress being complete, the header should be using the completed
// migration string.
let header = gShadowRoot.querySelector("#progress-header");
is(
header.getAttribute("data-l10n-id"),
"migration-wizard-progress-done-header",
"Should be showing completed migration header string"
);
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(!isHidden(doneButton), "Done button should be visible and enabled");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
});
add_task(async function test_extension_error() {
const EXTENSIONS_ERROR_STRING = "Extensions error string";
const EXTENSIONS_SUPPORT_STRING = "extensions support string";
const EXTENSIONS_SUPPORT_HREF = "about:blank";
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.WARNING,
message: EXTENSIONS_ERROR_STRING,
linkText: EXTENSIONS_SUPPORT_STRING,
linkURL: EXTENSIONS_SUPPORT_HREF,
}
}
});
is(
gDeck.selectedViewName,
"page-progress",
"Should have the progress page selected"
);
let extensionsGroup = getResourceGroup(MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS);
ok(!isHidden(extensionsGroup), "Extensions group should be visible");
let progressIcon = extensionsGroup.querySelector(".progress-icon");
is(progressIcon.getAttribute("state"), "warning");
is(
extensionsGroup.querySelector("a.message-text").textContent,
""
);
is(
extensionsGroup.querySelector("span.message-text").textContent,
EXTENSIONS_ERROR_STRING
);
is(
extensionsGroup.querySelector(".support-text").textContent,
EXTENSIONS_SUPPORT_STRING
);
is(
extensionsGroup.querySelector(".support-text").href,
EXTENSIONS_SUPPORT_HREF
);
is(
extensionsGroup.querySelector(".support-text").target,
"_blank"
);
// With progress being complete, the header should be using the completed
// migration string.
let header = gShadowRoot.querySelector("#progress-header");
is(
header.getAttribute("data-l10n-id"),
"migration-wizard-progress-done-with-warnings-header",
"Should be showing completed migration header string"
);
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(!isHidden(doneButton), "Done button should be visible and enabled");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
});
/**
* Tests that the wizard can show partial progress during file migration.
*/
add_task(async function test_partial_file_progress() {
const PASSWORDS_SUCCESS_STRING = "Some passwords success string";
const TITLE = "Partial progress";
gWiz.setState({
page: MigrationWizardConstants.PAGES.FILE_IMPORT_PROGRESS,
title: "Partial progress",
progress: {
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_FROM_FILE]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: PASSWORDS_SUCCESS_STRING,
},
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
},
},
});
is(
gDeck.selectedViewName,
"page-file-import-progress",
"Should have the file progress page selected"
);
let header = gShadowRoot.querySelector("#file-import-progress-header");
is(header.textContent, TITLE, "Title is set correctly.");
let passwordsFromFileGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_FROM_FILE
);
ok(!isHidden(passwordsFromFileGroup), "Passwords from file group should be visible");
let progressIcon = passwordsFromFileGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
passwordsFromFileGroup.querySelector(".message-text").textContent,
PASSWORDS_SUCCESS_STRING
);
let passwordsUpdatedGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_UPDATED
);
ok(isHidden(passwordsUpdatedGroup), "Passwords updated group should be hidden");
let passwordsNewGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW
);
ok(!isHidden(passwordsNewGroup), "Passwords new group should be visible");
progressIcon = passwordsNewGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(passwordsNewGroup.querySelector(".message-text").textContent.trim(), "");
let progressPage = gShadowRoot.querySelector("div[name='page-file-import-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(isHidden(doneButton), "Done button should be hidden");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(!isHidden(cancelButton), "Cancel button should be visible");
ok(cancelButton.disabled, "Cancel button should be disabled");
});
/**
* Tests that the wizard can show completed migration progress.
*/
add_task(async function test_completed_file_progress() {
const PASSWORDS_NEW_SUCCESS_STRING = "2 added";
const PASSWORDS_UPDATED_SUCCESS_STRING = "5 updated";
const TITLE = "Done doing file import";
gWiz.setState({
page: MigrationWizardConstants.PAGES.FILE_IMPORT_PROGRESS,
title: TITLE,
progress: {
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: PASSWORDS_NEW_SUCCESS_STRING,
},
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_UPDATED]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: PASSWORDS_UPDATED_SUCCESS_STRING,
},
},
});
is(
gDeck.selectedViewName,
"page-file-import-progress",
"Should have the file progress page selected"
);
let header = gShadowRoot.querySelector("#file-import-progress-header");
is(header.textContent, TITLE, "Title is set correctly.");
let passwordsNewGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW
);
ok(!isHidden(passwordsNewGroup), "Passwords new group should be visible");
let progressIcon = passwordsNewGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
passwordsNewGroup.querySelector(".message-text").textContent,
PASSWORDS_NEW_SUCCESS_STRING
);
let passwordsUpdatedGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_UPDATED
);
ok(!isHidden(passwordsUpdatedGroup), "Passwords updated group should be visible");
progressIcon = passwordsUpdatedGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
passwordsUpdatedGroup.querySelector(".message-text").textContent,
PASSWORDS_UPDATED_SUCCESS_STRING
);
let passwordsFromFileGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_FROM_FILE
);
ok(isHidden(passwordsFromFileGroup), "Passwords from file group should be hidden");
let progressPage = gShadowRoot.querySelector("div[name='page-file-import-progress']");
let doneButton = progressPage.querySelector(".done-button");
ok(!isHidden(doneButton), "Done button should be visible and enabled");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
});
/**
* Tests that the buttons that dismiss the wizard when embedded in
* a dialog are only visible when in dialog mode, and dispatch a
* MigrationWizard:Close event when clicked.
*/
add_task(async function test_dialog_mode_close() {
gWiz.toggleAttribute("dialog-mode", true);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
// For now, there's only a single .cancel-close button, so let's just test
// that one. Let's make this test fail if there are multiple so that we can
// then update this test to switch to the right pages to test those buttons
// too.
let buttons = gShadowRoot.querySelectorAll(".cancel-close:not([disabled])");
ok(
buttons.length,
"This test expects at least one enabled .cancel-close button"
);
let button = buttons[0];
ok(
!isHidden(button),
".cancel-close button should be visible in dialog mode."
);
let closeEvent = BrowserTestUtils.waitForEvent(gWiz, "MigrationWizard:Close");
button.click();
await closeEvent;
gWiz.toggleAttribute("dialog-mode", false);
ok(
isHidden(button),
".cancel-close button should be hidden when not in dialog mode."
);
});
/**
* Internet Explorer and Edge refer to bookmarks as "favorites",
* and we change our labels to suit when either of those browsers are
* selected as the migration source. This test tests that behavior in the
* selection page.
*/
add_task(async function test_ie_edge_favorites_selection() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: false,
});
let bookmarksCheckboxLabel = gShadowRoot.querySelector("#bookmarks");
let span = bookmarksCheckboxLabel.querySelector("span[default-data-l10n-id]");
ok(span, "The bookmarks selection span has a default-data-l10n-id attribute");
is(
span.getAttribute("data-l10n-id"),
span.getAttribute("default-data-l10n-id"),
"Should be showing the default string for bookmarks"
);
// Now test when in Variant 2, for the string in the <summary>.
let selectedDataUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: true,
});
await selectedDataUpdated;
let summary = gShadowRoot.querySelector("summary");
ok(
summary.textContent.toLowerCase().includes("bookmarks"),
"Summary should include the string 'bookmarks'"
);
for (let key of MigrationWizardConstants.USES_FAVORITES) {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key,
displayName: "Legacy Microsoft Browser",
resourceTypes: ["BOOKMARKS"],
profile: null,
hasPermissions: true,
}],
showImportAll: false,
});
is(
span.getAttribute("data-l10n-id"),
span.getAttribute("ie-edge-data-l10n-id"),
"Should be showing the IE/Edge string for bookmarks"
);
// Now test when in Variant 2, for the string in the <summary>.
selectedDataUpdated = BrowserTestUtils.waitForEvent(
gWiz,
"MigrationWizard:ResourcesUpdated"
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key,
displayName: "Legacy Microsoft Browser",
resourceTypes: ["BOOKMARKS"],
profile: null,
hasPermissions: true,
}],
showImportAll: true,
});
await selectedDataUpdated;
ok(
summary.textContent.toLowerCase().includes("favorites"),
"Summary should include the string 'favorites'"
);
}
});
/**
* Internet Explorer and Edge refer to bookmarks as "favorites",
* and we change our labels to suit when either of those browsers are
* selected as the migration source. This test tests that behavior in the
* progress page
*/
add_task(async function test_ie_edge_favorites_progress() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
inProgress: false,
message: "A string from the parent",
},
},
});
let bookmarksGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS
);
let span = bookmarksGroup.querySelector("span[default-data-l10n-id]");
ok(span, "Should have found a span with default-data-l10n-id");
is(
span.getAttribute("data-l10n-id"),
span.getAttribute("default-data-l10n-id"),
"Should be using the default string."
);
for (let key of MigrationWizardConstants.USES_FAVORITES) {
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key,
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
inProgress: false,
message: "A string from the parent",
},
},
});
is(
span.getAttribute("data-l10n-id"),
span.getAttribute("ie-edge-data-l10n-id"),
"Should be showing the IE/Edge string for bookmarks"
);
}
});
/**
* Tests that the button shown in either the browser migration success or
* file migration success pages is a "continue" button rather than a
* "done" button.
*/
add_task(async function test_embedded_continue_button() {
gWiz.toggleAttribute("dialog-mode", false);
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: "A string from the parent",
},
},
});
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
let doneButton = progressPage.querySelector(".done-button");
ok(isHidden(doneButton), "Done button should be hidden when embedding");
let continueButton = progressPage.querySelector(".continue-button");
ok(!isHidden(continueButton), "Continue button should be displayed");
let content = document.getElementById("content");
let promise = new Promise(resolve => {
content.addEventListener("MigrationWizard:Close", resolve, {
once: true,
});
});
continueButton.click();
await promise;
ok(
true,
"Clicking on the Continue button sent the MigrationWizard:Close event."
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.FILE_IMPORT_PROGRESS,
title: "Done importing file data",
progress: {
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW]: {
inProgress: false,
message: "Some message",
},
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_UPDATED]: {
inProgress: false,
message: "Some other",
},
},
});
progressPage = gShadowRoot.querySelector("div[name='page-file-import-progress']");
cancelButton = progressPage.querySelector(".cancel-close");
ok(isHidden(cancelButton), "Cancel button should be hidden");
doneButton = progressPage.querySelector(".done-button");
ok(isHidden(doneButton), "Done button should be hidden when embedding");
continueButton = progressPage.querySelector(".continue-button");
ok(!isHidden(continueButton), "Continue button should be displayed");
promise = new Promise(resolve => {
content.addEventListener("MigrationWizard:Close", resolve, {
once: true,
});
});
continueButton.click();
await promise;
ok(
true,
"Clicking on the Continue button sent the MigrationWizard:Close event."
);
gWiz.toggleAttribute("dialog-mode", true);
});
/**
* Tests that if a progress update comes down which puts a resource from
* being done to loading, that the status message is cleared.
*/
add_task(async function test_clear_status_message_when_in_progress() {
const STRING_TO_CLEAR = "This string should get cleared";
gWiz.toggleAttribute("dialog-mode", false);
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: STRING_TO_CLEAR,
},
},
});
let bookmarksGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS
);
ok(!isHidden(bookmarksGroup), "Bookmarks group should be visible");
let progressIcon = bookmarksGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
bookmarksGroup.querySelector(".message-text").textContent,
STRING_TO_CLEAR
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
message: "",
},
},
});
ok(!isHidden(bookmarksGroup), "Bookmarks group should be visible");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(
bookmarksGroup.querySelector(".message-text").textContent.trim(),
""
);
});
/**
* Tests that if a file progress update comes down which puts a resource
* from being done to loading, that the status message is cleared.
*
* This is extremely similar to the above test, except that it's for progress
* updates for file resources.
*/
add_task(async function test_clear_status_message_when_in_file_progress() {
const STRING_TO_CLEAR = "This string should get cleared";
gWiz.toggleAttribute("dialog-mode", false);
gWiz.setState({
page: MigrationWizardConstants.PAGES.FILE_IMPORT_PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
message: STRING_TO_CLEAR,
},
},
});
let passwordsGroup = getResourceGroup(
MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW
);
ok(!isHidden(passwordsGroup), "Passwords group should be visible");
let progressIcon = passwordsGroup.querySelector(".progress-icon");
is(
progressIcon.getAttribute("state"),
"success",
"Progress should be completed"
);
is(
passwordsGroup.querySelector(".message-text").textContent,
STRING_TO_CLEAR
);
gWiz.setState({
page: MigrationWizardConstants.PAGES.FILE_IMPORT_PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_FILE_RESOURCE_TYPES.PASSWORDS_NEW]: {
value: MigrationWizardConstants.PROGRESS_VALUE.LOADING,
message: "",
},
},
});
ok(!isHidden(passwordsGroup), "Passwords group should be visible");
is(
progressIcon.getAttribute("state"),
"loading",
"Progress should be still be underway"
);
is(
passwordsGroup.querySelector(".message-text").textContent.trim(),
""
);
});
/**
* Tests that the migration wizard can be put into the selection page after
* a file migrator error and show an error message.
*/
add_task(async function test_file_migrator_error() {
const FILE_MIGRATOR_KEY = "some-file-migrator";
const FILE_IMPORT_ERROR_MESSAGE = "This is an error message";
const MIGRATORS = [
{
key: "some-browser-0",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 0",
resourceTypes: ["HISTORY", "FORMDATA", "PASSWORDS", "BOOKMARKS"],
profile: { id: "person-2", name: "Person 2" },
hasPermissions: true,
},
{
key: "some-browser-1",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 1",
resourceTypes: ["HISTORY", "BOOKMARKS"],
profile: null,
hasPermissions: true,
},
{
key: FILE_MIGRATOR_KEY,
type: MigrationWizardConstants.MIGRATOR_TYPES.FILE,
displayName: "Some File Migrator",
resourceTypes: [],
},
];
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATORS,
showImportAll: true,
migratorKey: "some-file-migrator",
fileImportErrorMessage: FILE_IMPORT_ERROR_MESSAGE,
});
let errorMessageContainer = gShadowRoot.querySelector(".file-import-error");
ok(!isHidden(errorMessageContainer), "Error message should be shown.");
let errorText = gShadowRoot.querySelector("#file-import-error-message").textContent;
is(errorText, FILE_IMPORT_ERROR_MESSAGE);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATORS,
showImportAll: true,
});
ok(isHidden(errorMessageContainer), "Error message should be hidden.");
errorText = gShadowRoot.querySelector("#file-import-error-message").textContent;
is(errorText, "");
});
/**
* Tests that the variant of the wizard can be forced via
* attributes on the migration-wizard element.
*/
add_task(async function force_show_import_all() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: true,
});
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let details = gShadowRoot.querySelector("details");
ok(
selectionPage.hasAttribute("show-import-all"),
"Should be paying attention to showImportAll=true on state object"
);
ok(!details.open, "Details collapsed by default");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: false,
});
ok(
!selectionPage.hasAttribute("show-import-all"),
"Should be paying attention to showImportAll=false on state object"
);
ok(details.open, "Details expanded by default");
gWiz.setAttribute("force-show-import-all", "false");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: true,
});
ok(
!selectionPage.hasAttribute("show-import-all"),
"Should be paying attention to force-show-import-all=false on DOM node"
);
ok(details.open, "Details expanded by default");
gWiz.setAttribute("force-show-import-all", "true");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: false,
});
ok(
selectionPage.hasAttribute("show-import-all"),
"Should be paying attention to force-show-import-all=true on DOM node"
);
ok(!details.open, "Details collapsed by default");
gWiz.removeAttribute("force-show-import-all");
});
/**
* Tests that for non-Safari migrators without permissions, we show
* the appropriate message and the button for getting permissions.
*/
add_task(async function no_permissions() {
const SOME_FAKE_PERMISSION_PATH = "/some/fake/path";
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key: "some-browser-0",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Some Browser 0 with no permissions",
resourceTypes: [],
profile: null,
hasPermissions: false,
permissionsPath: SOME_FAKE_PERMISSION_PATH,
}],
showImportAll: false,
});
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
ok(selectionPage.hasAttribute("no-permissions"), "no-permissions attribute set.");
let resourceList = gShadowRoot.querySelector(".resource-selection-details");
ok(isHidden(resourceList), "Resources list is hidden.");
let importButton = gShadowRoot.querySelector("#import");
ok(isHidden(importButton), "Import button hidden.");
let noPermissionsMessage = gShadowRoot.querySelector(".no-permissions-message");
ok(!isHidden(noPermissionsMessage), "No permissions message shown.");
let getPermissionButton = gShadowRoot.querySelector("#get-permissions");
ok(!isHidden(getPermissionButton), "Get permissions button shown.");
let step2 = gShadowRoot.querySelector(".migration-no-permissions-instructions-step2");
ok(step2.hasAttribute("data-l10n-args"));
is(JSON.parse(step2.getAttribute("data-l10n-args")).permissionsPath, SOME_FAKE_PERMISSION_PATH);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
showImportAll: false,
});
ok(!selectionPage.hasAttribute("no-permissions"), "no-permissions attribute set to false.");
ok(!isHidden(resourceList), "Resources list is shown.");
ok(!isHidden(importButton), "Import button is shown.");
ok(isHidden(noPermissionsMessage), "No permissions message hidden.");
ok(isHidden(getPermissionButton), "Get permissions button hidden.");
});
/**
* Tests that for the Safari migrator without permissions, we show the
* normal resources list and impor tbutton instead of the no permissions
* message. Safari has a special flow where permissions are requested
* only after resource selection has occurred.
*/
add_task(async function no_permissions_safari() {
const SOME_FAKE_PERMISSION_PATH = "/some/fake/safari/path";
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key: "safari",
type: MigrationWizardConstants.MIGRATOR_TYPES.BROWSER,
displayName: "Safari with no permissions",
resourceTypes: ["HISTORY", "BOOKMARKS"],
profile: null,
hasPermissions: false,
permissionsPath: SOME_FAKE_PERMISSION_PATH,
}],
showImportAll: false,
});
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
ok(!selectionPage.hasAttribute("no-permissions"), "no-permissions attribute not set.");
let resourceList = gShadowRoot.querySelector(".resource-selection-details");
ok(!isHidden(resourceList), "Resources list is shown.");
let importButton = gShadowRoot.querySelector("#import");
ok(!isHidden(importButton), "Import button shown.");
let noPermissionsMessage = gShadowRoot.querySelector(".no-permissions-message");
ok(isHidden(noPermissionsMessage), "No permissions message hidden.");
let getPermissionButton = gShadowRoot.querySelector("#get-permissions");
ok(isHidden(getPermissionButton), "Get permissions button hiddne.");
});
add_task(async function hide_option_expander_subtitle() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
gWiz.setAttribute("hide-option-expander-subtitle", "true");
let subtitle = selectionPage.querySelector("#resource-selection-summary > .selected-data");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
ok(gWiz.hasAttribute("hide-option-expander-subtitle"), "hide option expander subtitle attribute is present on migration wizard");
ok(isHidden(subtitle), "subtitle is hidden");
gWiz.removeAttribute("hide-option-expander-subtitle");
});
add_task(async function update_option_expander_title_string() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let title = selectionPage.querySelector(".selected-data-header");
gWiz.setAttribute("option-expander-title-string", "test");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
await BrowserTestUtils.waitForMutationCondition(
title,
{childList: true},
() => title.textContent == "test"
)
is(title.textContent, "test", "resource selection expander subtitle has been changed");
gWiz.removeAttribute("option-expander-title-string");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
await BrowserTestUtils.waitForMutationCondition(
title,
{childList: true},
() => title.textContent != "test"
)
isnot(title.textContent, "test", "resource selection expander subtitle was reverted");
});
add_task(async function hide_select_all_checkbox() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let selectAll = selectionPage.querySelector("#select-all");
gWiz.setAttribute("hide-select-all", true);
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
ok(isHidden(selectAll), "select all is not displayed");
gWiz.removeAttribute("hide-select-all");
});
add_task(async function update_import_button_string() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
gWiz.setAttribute("import-button-string", "test");
let button = selectionPage.querySelector(".migration-import-button");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
is(button.textContent, "test", "button text is expected");
gWiz.removeAttribute("import-button-string");
});
add_task(async function update_checkbox_margins() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
gWiz.setAttribute("checkbox-margin-inline", "27px 42px");
gWiz.setAttribute("checkbox-margin-block", "42px 27px");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
let checkboxLabels = selectionPage.querySelectorAll(".resource-type-label");
for(let label of checkboxLabels) {
let computedStyle = getComputedStyle(label);
let marginInline = computedStyle.getPropertyValue("margin-inline");
let marginBlock = computedStyle.getPropertyValue("margin-block");
is(marginInline, "27px 42px", "margin inline is set to expected value");
is(marginBlock, "42px 27px", "margin block is set to expected value");
}
gWiz.removeAttribute("checkbox-margin-inline");
gWiz.removeAttribute("checkbox-margin-block");
});
add_task(async function update_import_button_class() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let importButton = selectionPage.querySelector("#import");
gWiz.setAttribute("import-button-class", "primary");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
ok(importButton.classList.contains("primary"), "import button has the primary class");
gWiz.removeAttribute("import-button-class");
});
add_task(async function update_header_font_size() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let header = selectionPage.querySelector("h1");
gWiz.setAttribute("header-font-size", "24px");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
let computedStyle = getComputedStyle(header);
is(computedStyle.getPropertyValue("font-size"), "24px", "header font size is changed to correct value");
gWiz.removeAttribute("header-font-size");
});
add_task(async function update_header_margin_block() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let header = selectionPage.querySelector("h1");
gWiz.setAttribute("header-margin-block", "20px 30px");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
let computedStyle = getComputedStyle(header);
is(computedStyle.getPropertyValue("margin-block"), "20px 30px", "header margin block is changed to correct value");
gWiz.removeAttribute("header-margin-block");
});
add_task(async function update_header_string() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let header = selectionPage.querySelector("h1");
gWiz.setAttribute("selection-header-string", "test string");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
is(header.textContent, "test string", "header text content is changed to correct value");
gWiz.removeAttribute("selection-header-string");
});
add_task(async function update_subheader_font_size() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let subheader = selectionPage.querySelector("h1");
gWiz.setAttribute("subheader-font-size", "24px");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
let computedStyle = getComputedStyle(subheader);
is(computedStyle.getPropertyValue("font-size"), "24px", "subheader font size is changed to correct value");
gWiz.removeAttribute("subheader-font-size");
});
add_task(async function update_subheader_margin_block() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let subheader = selectionPage.querySelector("h1");
gWiz.setAttribute("subheader-margin-block", "20px 30px");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
let computedStyle = getComputedStyle(subheader);
is(computedStyle.getPropertyValue("margin-block"), "20px 30px", "subheader margin block is changed to correct value");
gWiz.removeAttribute("subheader-margin-block");
});
add_task(async function update_subheader_string() {
let selectionPage = gShadowRoot.querySelector("div[name='page-selection']");
let subheader = selectionPage.querySelector(".migration-wizard-subheader");
gWiz.setAttribute("selection-subheader-string", "test string");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
is(subheader.textContent, "test string", "subheader text content is changed to correct value");
gWiz.removeAttribute("selection-subheader-string");
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: MIGRATOR_PROFILE_INSTANCES,
});
ok(isHidden(subheader), "subheader is hidden")
});
add_task(async function update_data_import_success_string() {
let progressPage = gShadowRoot.querySelector("div[name='page-progress']");
let header = progressPage.querySelector("h1");
gWiz.setAttribute("data-import-complete-success-string", "test string");
gWiz.setState({
page: MigrationWizardConstants.PAGES.PROGRESS,
key: "chrome",
progress: {
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.EXTENSIONS]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
},
[MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.FORMDATA]: {
value: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
},
},
});
is(header.textContent, "test string", "import success header text content is changed to correct value");
gWiz.removeAttribute("data-import-complete-success-string");
});
</script>
</head>
<body>
<p id="display"></p>
<div id="content">
<migration-wizard id="test-wizard" dialog-mode=""></migration-wizard>
</div>
<pre id="test"></pre>
</body>
</html>
|