diff --git a/.eslintignore b/.eslintignore
index b4cb86c26bb4..1c607b14d2bc 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -341,6 +341,7 @@ services/common/kinto-http-client.js
services/common/kinto-offline-client.js
# toolkit/ exclusions
+toolkit/content/widgets/wizard.xml
# Intentionally invalid JS
toolkit/components/workerloader/tests/moduleF-syntax-error.js
@@ -355,7 +356,6 @@ toolkit/components/reader/JSDOMParser.js
# Uses preprocessing
toolkit/components/reader/Readerable.jsm
-toolkit/content/widgets/wizard.xml
toolkit/modules/AppConstants.jsm
toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
tools/tryselect/selectors/chooser/templates/chooser.html
diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
index a04a88a672da..cc1215078a0b 100644
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
@@ -54,27 +54,27 @@ class Wizard(UIBaseLib):
@property
def cancel_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'cancel'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="cancel"]')
@property
def extra1_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'extra1'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="extra1"]')
@property
def extra2_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'extra2'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="extra2"]')
@property
def previous_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'back'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="back"]')
@property
def finish_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'finish'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="finish"]')
@property
def next_button(self):
- return self._buttons.find_element(By.ANON_ATTRIBUTE, {'dlgtype': 'next'})
+ return self._buttons.find_element(By.CSS_SELECTOR, '[dlgtype="next"]')
# Properties for visual panels of the wizard #
diff --git a/toolkit/content/jar.mn b/toolkit/content/jar.mn
index 139c093c1fc8..fa4bbeb61017 100644
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -82,7 +82,7 @@ toolkit.jar:
content/global/bindings/timekeeper.js (widgets/timekeeper.js)
content/global/bindings/timepicker.js (widgets/timepicker.js)
content/global/bindings/toolbarbutton.xml (widgets/toolbarbutton.xml)
-* content/global/bindings/wizard.xml (widgets/wizard.xml)
+ content/global/bindings/wizard.xml (widgets/wizard.xml)
content/global/elements/autocomplete-popup.js (widgets/autocomplete-popup.js)
content/global/elements/autocomplete-richlistitem.js (widgets/autocomplete-richlistitem.js)
content/global/elements/browser-custom-element.js (widgets/browser-custom-element.js)
diff --git a/toolkit/content/widgets/wizard.js b/toolkit/content/widgets/wizard.js
index 5f22d1c9f1c2..ce0302fb40b8 100644
--- a/toolkit/content/widgets/wizard.js
+++ b/toolkit/content/widgets/wizard.js
@@ -7,6 +7,10 @@
// This is loaded into chrome windows with the subscript loader. Wrap in
// a block to prevent accidentally leaking globals onto `window`.
{
+const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
+const kDTDs = [ "chrome://global/locale/wizard.dtd" ];
+
class MozWizardPage extends MozXULElement {
constructor() {
super();
@@ -29,4 +33,144 @@ class MozWizardPage extends MozXULElement {
}
customElements.define("wizardpage", MozWizardPage);
+
+class MozWizardButtons extends MozXULElement {
+ connectedCallback() {
+ this.textContent = "";
+ this.appendChild(MozXULElement.parseXULToFragment(this._markup, kDTDs));
+
+ this._wizardButtonDeck = this.querySelector(".wizard-next-deck");
+
+ this.initializeAttributeInheritance();
+
+ const listeners = [
+ ["back", () => document.documentElement.rewind()],
+ ["next", () => document.documentElement.advance()],
+ ["finish", () => document.documentElement.advance()],
+ ["cancel", () => document.documentElement.cancel()],
+ ["extra1", () => document.documentElement.extra1()],
+ ["extra2", () => document.documentElement.extra2()],
+ ];
+ for (let [name, listener] of listeners) {
+ let btn = this.getButton(name);
+ if (btn) {
+ btn.addEventListener("command", listener);
+ }
+ }
+ }
+
+ static get inheritedAttributes() {
+ return AppConstants.platform == "macosx" ? {
+ "[dlgtype='finish']": "hidefinishbutton",
+ "[dlgtype='next']": "lastpage",
+ } : null;
+ }
+
+ get _markup() {
+ if (AppConstants.platform == "macosx") {
+ return `
+
+
+
+
+
+
+
+
+
+
+ `;
+ }
+
+ let buttons = AppConstants.platform == "linux" ? `
+
+
+
+
+
+
+
+
+
+
+ ` : `
+
+
+
+
+
+
+
+
+
+ `;
+
+ return `
+
+
+
+
+
+
+ ${buttons}
+
+ `;
+ }
+
+ onPageChange() {
+ if (AppConstants.platform == "macosx") {
+ this.setAttribute("hidefinishbutton",
+ !(this.getAttribute("lastpage") == "true"));
+ } else if (this.getAttribute("lastpage") == "true") {
+ this._wizardButtonDeck.setAttribute("selectedIndex", 0);
+ } else {
+ this._wizardButtonDeck.setAttribute("selectedIndex", 1);
+ }
+ }
+
+ getButton(type) {
+ return this.querySelector(`[dlgtype="${type}"]`);
+ }
+
+ get defaultButton() {
+ const kXULNS =
+ "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+ let buttons = this._wizardButtonDeck.selectedPanel.
+ getElementsByTagNameNS(kXULNS, "button");
+ for (let i = 0; i < buttons.length; i++) {
+ if (buttons[i].getAttribute("default") == "true" &&
+ !buttons[i].hidden && !buttons[i].disabled) {
+ return buttons[i];
+ }
+ }
+ return null;
+ }
+}
+
+customElements.define("wizard-buttons", MozWizardButtons);
}
diff --git a/toolkit/content/widgets/wizard.xml b/toolkit/content/widgets/wizard.xml
index 7da2295c325e..4ea5644fdf68 100644
--- a/toolkit/content/widgets/wizard.xml
+++ b/toolkit/content/widgets/wizard.xml
@@ -4,11 +4,6 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
- %wizardDTD;
-]>
-
-
+
@@ -31,9 +26,9 @@
onset="return document.title = val;"/>
+ onset="this.getButton('next').disabled = !val; return this._canAdvance = val;"/>
+ onset="this.getButton('back').disabled = !val; return this._canRewind = val;"/>
@@ -67,13 +62,13 @@
this.canRewind = false;
this.setAttribute("firstpage", "true");
if (/Linux/.test(navigator.platform)) {
- this._backButton.setAttribute('hidden', 'true');
+ this.getButton("back").setAttribute("hidden", "true");
}
} else {
this.canRewind = true;
this.setAttribute("firstpage", "false");
if (/Linux/.test(navigator.platform)) {
- this._backButton.setAttribute('hidden', 'false');
+ this.getButton("back").setAttribute("hidden", "false");
}
}
@@ -128,8 +123,7 @@
@@ -139,22 +133,6 @@
-
-
-
-
-
- (function() { document.documentElement.rewind(); })
- (function() { document.documentElement.advance(); })
- (function() { document.documentElement.advance(); })
- (function() { document.documentElement.cancel(); })
- (function() { document.documentElement.extra1(); })
- (function() { document.documentElement.extra2(); })
-
- (function(event) {
- if (document.documentElement.cancel())
- event.preventDefault();
- })
{
+ if (document.documentElement.cancel()) {
+ event.preventDefault();
+ }
+ });
// start off on the first page
this.pageCount = this.wizardPages.length;
@@ -386,18 +363,6 @@
]]>