Bug 1497039 - Put a placeholder in privacy.xul that will be used to inject the form-autofill section. r=MattN
authorJared Wein <jwein@mozilla.com>
Thu, 18 Oct 2018 03:42:59 +0000
changeset 497601 afdfeb4c004cbba91d4d9e30a0e80e6dfb0dce60
parent 497600 856c528a098312ad0ee77b5c6960993974ed19f4
child 497602 02a07fe8780872236c65ddc30470209bef95b71b
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1497039
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497039 - Put a placeholder in privacy.xul that will be used to inject the form-autofill section. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D8892
browser/components/preferences/in-content/preferences.js
browser/components/preferences/in-content/privacy.xul
browser/extensions/formautofill/FormAutofillParent.jsm
browser/extensions/formautofill/FormAutofillPreferences.jsm
browser/extensions/formautofill/test/browser/browser_privacyPreferences.js
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -231,27 +231,27 @@ async function spotlight(subcategory) {
     for (let element of highlightedElements) {
       element.classList.remove("spotlight");
     }
   }
   if (subcategory) {
     if (!gSearchResultsPane.categoriesInitialized) {
       await waitForSystemAddonInjectionsFinished([{
         isGoingToInject: formAutofillParent.initialized,
-        elementId: "formAutofillGroupBox",
+        elementId: "formAutofillGroup",
       }]);
     }
     scrollAndHighlight(subcategory);
   }
 
   /**
    * Wait for system addons finished their dom injections.
    * @param {Array} addons - The system addon information array.
    * For example, the element is looked like
-   * { isGoingToInject: true, elementId: "formAutofillGroupBox" }.
+   * { isGoingToInject: true, elementId: "formAutofillGroup" }.
    * The `isGoingToInject` means the system addon will be visible or not,
    * and the `elementId` means the id of the element will be injected into the dom
    * if the `isGoingToInject` is true.
    * @returns {Promise} Will resolve once all injections are finished.
    */
   function waitForSystemAddonInjectionsFinished(addons) {
     return new Promise(resolve => {
       let elementIdSet = new Set();
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -364,16 +364,22 @@
     <hbox>
       <button id="changeMasterPassword"
               class="accessory-button"
               data-l10n-id="forms-master-pw-change"/>
     </hbox>
   </hbox>
 </groupbox>
 
+<!-- The form autofill section is inserted in to this box
+     after the form autofill extension has initialized. -->
+<groupbox id="formAutofillGroupBox"
+          data-category="panePrivacy"
+          data-subcategory="form-autofill"></groupbox>
+
 <!-- History -->
 <groupbox id="historyGroup" data-category="panePrivacy" hidden="true">
   <caption><label data-l10n-id="history-header"/></caption>
   <hbox align="center">
     <label id="historyModeLabel"
            control="historyMode"
            data-l10n-id="history-remember-label"/>
     <!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
--- a/browser/extensions/formautofill/FormAutofillParent.jsm
+++ b/browser/extensions/formautofill/FormAutofillParent.jsm
@@ -128,20 +128,19 @@ FormAutofillParent.prototype = {
   },
 
   observe(subject, topic, data) {
     log.debug("observe:", topic, "with data:", data);
     switch (topic) {
       case "sync-pane-loaded": {
         let formAutofillPreferences = new FormAutofillPreferences();
         let document = subject.document;
-        let prefGroupBox = formAutofillPreferences.init(document);
-        let parentNode = document.getElementById("mainPrefPane");
-        let insertBeforeNode = document.getElementById("historyGroup");
-        parentNode.insertBefore(prefGroupBox, insertBeforeNode);
+        let prefFragment = formAutofillPreferences.init(document);
+        let formAutofillGroupBox = document.getElementById("formAutofillGroupBox");
+        formAutofillGroupBox.appendChild(prefFragment);
         break;
       }
 
       case "nsPref:changed": {
         // Observe pref changes and update _active cache if status is changed.
         this._updateStatus();
         break;
       }
--- a/browser/extensions/formautofill/FormAutofillPreferences.jsm
+++ b/browser/extensions/formautofill/FormAutofillPreferences.jsm
@@ -46,17 +46,17 @@ FormAutofillPreferences.prototype = {
    *
    * @param   {XULDocument} document
    * @returns {XULElement}
    */
   init(document) {
     this.createPreferenceGroup(document);
     this.attachEventListeners();
 
-    return this.refs.formAutofillGroupBox;
+    return this.refs.formAutofillFragment;
   },
 
   /**
    * Remove event listeners and the preference group.
    */
   uninit() {
     this.detachEventListeners();
     this.refs.formAutofillGroup.remove();
@@ -64,17 +64,17 @@ FormAutofillPreferences.prototype = {
 
   /**
    * Create Form Autofill preference group
    *
    * @param  {XULDocument} document
    */
   createPreferenceGroup(document) {
     let learnMoreURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "autofill-card-address";
-    let formAutofillGroupBox = document.createXULElement("groupbox");
+    let formAutofillFragment = document.createDocumentFragment();
     let formAutofillGroupBoxCaption = document.createXULElement("caption");
     let formAutofillGroupBoxCaptionLabel = document.createXULElement("label");
     let formAutofillGroupBoxDescription = document.createXULElement("description");
     let formAutofillGroup = document.createXULElement("vbox");
     let addressAutofill = document.createXULElement("hbox");
     let addressAutofillCheckboxGroup = document.createXULElement("hbox");
     let addressAutofillCheckbox = document.createXULElement("checkbox");
     let addressAutofillCheckboxLabel = document.createXULElement("label");
@@ -88,19 +88,16 @@ FormAutofillPreferences.prototype = {
     savedAddressesBtn.className = "accessory-button";
     addressAutofillCheckboxLabelSpacer.className = "tail-with-learn-more";
     addressAutofillLearnMore.className = "learnMore text-link";
 
     formAutofillGroup.id = "formAutofillGroup";
     addressAutofill.id = "addressAutofill";
     addressAutofillLearnMore.id = "addressAutofillLearnMore";
 
-    formAutofillGroupBox.setAttribute("id", "formAutofillGroupBox");
-    formAutofillGroupBox.setAttribute("data-category", "panePrivacy");
-    formAutofillGroupBox.setAttribute("data-subcategory", "form-autofill");
     formAutofillGroupBoxCaptionLabel.textContent = this.bundle.GetStringFromName("autofillHeader");
     formAutofillGroupBoxDescription.textContent =
       this.bundle.formatStringFromName("autofillDescription",
                                        [FormAutofillUtils.brandBundle.GetStringFromName("brandShortName")],
                                        1);
 
     addressAutofill.setAttribute("data-subcategory", "address-autofill");
     addressAutofillCheckboxLabel.textContent = this.bundle.GetStringFromName("autofillAddressesCheckbox");
@@ -122,30 +119,30 @@ FormAutofillPreferences.prototype = {
       addressAutofillCheckbox.setAttribute("checked", true);
     }
 
     addressAutofillCheckboxGroup.align = "center";
     addressAutofillCheckboxGroup.flex = 1;
     addressAutofillCheckboxLabel.flex = 1;
 
     formAutofillGroupBoxCaption.appendChild(formAutofillGroupBoxCaptionLabel);
-    formAutofillGroupBox.appendChild(formAutofillGroupBoxCaption);
-    formAutofillGroupBox.appendChild(formAutofillGroupBoxDescription);
-    formAutofillGroupBox.appendChild(formAutofillGroup);
+    formAutofillFragment.appendChild(formAutofillGroupBoxCaption);
+    formAutofillFragment.appendChild(formAutofillGroupBoxDescription);
+    formAutofillFragment.appendChild(formAutofillGroup);
     formAutofillGroup.appendChild(addressAutofill);
     addressAutofill.appendChild(addressAutofillCheckboxGroup);
     addressAutofillCheckboxGroup.appendChild(addressAutofillCheckbox);
     addressAutofillCheckboxGroup.appendChild(addressAutofillCheckboxLabel);
     addressAutofillCheckboxLabel.appendChild(addressAutofillCheckboxLabelSpacer);
     addressAutofillCheckboxLabel.appendChild(addressAutofillLearnMore);
     addressAutofill.appendChild(savedAddressesBtnWrapper);
     savedAddressesBtnWrapper.appendChild(savedAddressesBtn);
 
     this.refs = {
-      formAutofillGroupBox,
+      formAutofillFragment,
       formAutofillGroup,
       addressAutofillCheckbox,
       addressAutofillCheckboxLabel,
       savedAddressesBtn,
     };
 
     if (FormAutofill.isAutofillCreditCardsAvailable) {
       let creditCardAutofill = document.createXULElement("hbox");
--- a/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js
+++ b/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js
@@ -1,14 +1,14 @@
 "use strict";
 
 const PAGE_PREFS = "about:preferences";
 const PAGE_PRIVACY = PAGE_PREFS + "#privacy";
 const SELECTORS = {
-  group: "#passwordsGroup",
+  group: "#formAutofillGroupBox",
   addressAutofillCheckbox: "#addressAutofill checkbox",
   creditCardAutofillCheckbox: "#creditCardAutofill checkbox",
   savedAddressesBtn: "#addressAutofill button",
   savedCreditCardsBtn: "#creditCardAutofill button",
   addressAutofillLearnMore: "#addressAutofillLearnMore",
   creditCardAutofillLearnMore: "#creditCardAutofillLearnMore",
 };