Bug 1847815 - Allow embedders of the migration-wizard to override the variant pref via an attribute. r=kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D185707
This commit is contained in:
Mike Conley 2023-08-09 18:57:07 +00:00
Родитель 2e33b5ae6b
Коммит 1b8af1c366
2 изменённых файлов: 63 добавлений и 1 удалений

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

@ -534,7 +534,16 @@ export class MigrationWizard extends HTMLElement {
);
let details = this.#shadowRoot.querySelector("details");
selectionPage.toggleAttribute("show-import-all", state.showImportAll);
if (this.hasAttribute("force-show-import-all")) {
selectionPage.toggleAttribute(
"show-import-all",
this.getAttribute("force-show-import-all") == "true"
);
} else {
selectionPage.toggleAttribute("show-import-all", state.showImportAll);
}
details.open = !state.showImportAll;
this.#expandedDetails = false;

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

@ -1366,6 +1366,59 @@
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']");
ok(
selectionPage.hasAttribute("show-import-all"),
"Should be paying attention to showImportAll=true on state object"
);
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"
);
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"
);
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"
);
gWiz.removeAttribute("force-show-import-all");
});
</script>
</head>
<body>