From 3b83aa86923ea3767c53d1d6fdcdddc82edaa0f9 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Fri, 9 Jun 2017 11:46:23 +0200 Subject: [PATCH] Backed out changeset df527bcc28dc (bug 1303510) for test failures in browser_first_time_use_doorhanger.js --- browser/app/profile/firefox.js | 1 - .../formautofill/FormAutofillContent.jsm | 16 +- .../formautofill/FormAutofillDoorhanger.jsm | 173 ------------------ .../formautofill/FormAutofillParent.jsm | 17 +- .../content/icon-address-save.svg | 6 - .../locale/en-US/formautofill.properties | 3 - .../test/unit/test_onFormSubmitted.js | 2 +- 7 files changed, 8 insertions(+), 210 deletions(-) delete mode 100644 browser/extensions/formautofill/FormAutofillDoorhanger.jsm delete mode 100644 browser/extensions/formautofill/content/icon-address-save.svg diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 037168a2e681..0107c50c60d6 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1663,7 +1663,6 @@ pref("extensions.formautofill.experimental", true); pref("extensions.formautofill.experimental", false); #endif pref("extensions.formautofill.addresses.enabled", true); -pref("extensions.formautofill.firstTimeUse", true); pref("extensions.formautofill.heuristics.enabled", true); pref("extensions.formautofill.loglevel", "Warn"); diff --git a/browser/extensions/formautofill/FormAutofillContent.jsm b/browser/extensions/formautofill/FormAutofillContent.jsm index 65727532e1e4..882f628b6e70 100644 --- a/browser/extensions/formautofill/FormAutofillContent.jsm +++ b/browser/extensions/formautofill/FormAutofillContent.jsm @@ -324,11 +324,9 @@ var FormAutofillContent = { * Send the profile to parent for doorhanger and storage saving/updating. * * @param {Object} profile Submitted form's address/creditcard guid and record. - * @param {Object} domWin Current content window. */ - _onFormSubmit(profile, domWin) { - let mm = this._messageManagerFromWindow(domWin); - mm.sendAsyncMessage("FormAutofill:OnFormSubmit", profile); + _onFormSubmit(profile) { + Services.cpmm.sendAsyncMessage("FormAutofill:OnFormSubmit", profile); }, /** @@ -367,7 +365,7 @@ var FormAutofillContent = { record: pendingAddress, }, // creditCard: {} - }, domWin); + }); return true; }, @@ -509,14 +507,6 @@ var FormAutofillContent = { ProfileAutocomplete._previewSelectedProfile(selectedIndex); } }, - - _messageManagerFromWindow(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIContentFrameMessageManager); - }, }; diff --git a/browser/extensions/formautofill/FormAutofillDoorhanger.jsm b/browser/extensions/formautofill/FormAutofillDoorhanger.jsm deleted file mode 100644 index a8e1b0ac3f81..000000000000 --- a/browser/extensions/formautofill/FormAutofillDoorhanger.jsm +++ /dev/null @@ -1,173 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements doorhanger singleton that wraps up the PopupNotifications and handles - * the doorhager UI for formautofill related features. - */ - -/* exported FormAutofillDoorhanger */ - -"use strict"; - -this.EXPORTED_SYMBOLS = ["FormAutofillDoorhanger"]; - -const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://formautofill/FormAutofillUtils.jsm"); - -this.log = null; -FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]); - -const BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties"; -const GetStringFromName = Services.strings.createBundle(BUNDLE_URI).GetStringFromName; - -const CONTENT = { - firstTimeUse: { - notificationId: "autofill-address", - message: GetStringFromName("saveAddressMessage"), - anchor: { - id: "autofill-address-notification-icon", - URL: "chrome://formautofill/content/icon-address-save.svg", - tooltiptext: GetStringFromName("openAutofillMessagePanel"), - }, - options: { - persistWhileVisible: true, - popupIconURL: "chrome://formautofill/content/icon-address-save.svg", - }, - }, -}; - -let FormAutofillDoorhanger = { - /** - * Generate the main action and secondary actions from content parameters and - * promise resolve. - * - * @private - * @param {Object} mainActionParams - * Parameters for main action. - * @param {Array} secondaryActionParams - * Array of the parameters for secondary actions. - * @param {Function} resolve Should be called in action callback. - * @returns {Array} - Return the mainAction and secondary actions in an array for showing doorhanger - */ - _createActions(mainActionParams, secondaryActionParams, resolve) { - if (!mainActionParams) { - return [null, null]; - } - - let {label, accessKey, callbackState} = mainActionParams; - let callback = resolve.bind(null, callbackState); - let mainAction = {label, accessKey, callback}; - - if (!secondaryActionParams) { - return [mainAction, null]; - } - - let secondaryActions = []; - for (let params of secondaryActionParams) { - let cb = resolve.bind(null, params.callbackState); - secondaryActions.push({ - label: params.label, - accessKey: params.accessKey, - callback: cb, - }); - } - - return [mainAction, secondaryActions]; - }, - /** - * Append the link label element to the popupnotificationcontent. - * @param {XULElement} browser - * Target browser element for showing doorhanger. - * @param {string} id - * The ID of the doorhanger. - */ - _appendPrivacyPanelLink(browser, id) { - let notificationId = id + "-notification"; - let chromeDoc = browser.ownerDocument; - let notification = chromeDoc.getElementById(notificationId); - - if (!notification.querySelector("popupnotificationcontent")) { - let notificationcontent = chromeDoc.createElement("popupnotificationcontent"); - let privacyLinkElement = chromeDoc.createElement("label"); - privacyLinkElement.className = "text-link"; - privacyLinkElement.setAttribute("useoriginprincipal", true); - privacyLinkElement.setAttribute("href", "about:preferences#privacy"); - privacyLinkElement.setAttribute("value", GetStringFromName("viewAutofillOptions")); - notificationcontent.appendChild(privacyLinkElement); - notification.append(notificationcontent); - } - }, - /** - * Create an image element for notification anchor if it doesn't already exist. - * @param {XULElement} browser - * Target browser element for showing doorhanger. - * @param {Object} anchor - * Anchor options for setting the anchor element. - * @param {string} anchor.id - * ID of the anchor element. - * @param {string} anchor.URL - * Path of the icon asset. - * @param {string} anchor.tooltiptext - * Tooltip string for the anchor. - */ - _setAnchor(browser, anchor) { - let chromeDoc = browser.ownerDocument; - let {id, URL, tooltiptext} = anchor; - let anchorEt = chromeDoc.getElementById(id); - if (!anchorEt) { - let notificationPopupBox = - chromeDoc.getElementById("notification-popup-box"); - // Icon shown on URL bar - let anchorElement = chromeDoc.createElement("image"); - anchorElement.id = id; - anchorElement.setAttribute("src", URL); - anchorElement.classList.add("notification-anchor-icon"); - anchorElement.setAttribute("role", "button"); - anchorElement.setAttribute("tooltiptext", tooltiptext); - anchorElement.style.setProperty("-moz-context-properties", "fill"); - anchorElement.style.fill = "currentcolor"; - notificationPopupBox.appendChild(anchorElement); - } - }, - /** - * Show different types of doorhanger by leveraging PopupNotifications. - * @param {XULElement} browser - * Target browser element for showing doorhanger. - * @param {string} type - * The type of the doorhanger. There will have first time use/update/credit card. - * @returns {Promise} - Resolved with action type when action callback is triggered. - */ - async show(browser, type) { - log.debug("show doorhanger with type:", type); - return new Promise((resolve) => { - let content = CONTENT[type]; - let chromeWin = browser.ownerGlobal; - content.options.eventCallback = (topic) => { - log.debug("eventCallback:", topic); - - switch (topic) { - // We can only append label element when notification box is shown - case "shown": - this._appendPrivacyPanelLink(browser, content.notificationId); - break; - } - }; - this._setAnchor(browser, content.anchor); - chromeWin.PopupNotifications.show( - browser, - content.notificationId, - content.message, - content.anchor.id, - ...this._createActions(content.mainAction, content.secondaryActions, resolve), - content.options, - ); - }); - }, -}; diff --git a/browser/extensions/formautofill/FormAutofillParent.jsm b/browser/extensions/formautofill/FormAutofillParent.jsm index 5cec8dab1056..7884ef926c88 100644 --- a/browser/extensions/formautofill/FormAutofillParent.jsm +++ b/browser/extensions/formautofill/FormAutofillParent.jsm @@ -35,13 +35,12 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://formautofill/FormAutofillUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillPreferences", "resource://formautofill/FormAutofillPreferences.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillDoorhanger", - "resource://formautofill/FormAutofillDoorhanger.jsm"); this.log = null; FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]); @@ -81,7 +80,7 @@ FormAutofillParent.prototype = { Services.ppmm.addMessageListener("FormAutofill:GetAddresses", this); Services.ppmm.addMessageListener("FormAutofill:SaveAddress", this); Services.ppmm.addMessageListener("FormAutofill:RemoveAddresses", this); - Services.mm.addMessageListener("FormAutofill:OnFormSubmit", this); + Services.ppmm.addMessageListener("FormAutofill:OnFormSubmit", this); // Observing the pref and storage changes Services.prefs.addObserver(ENABLED_PREF, this); @@ -277,16 +276,8 @@ FormAutofillParent.prototype = { } this.profileStorage.addresses.notifyUsed(address.guid); } else { - if (!Services.prefs.getBoolPref("extensions.formautofill.firstTimeUse")) { - if (!this.profileStorage.addresses.mergeToStorage(address.record)) { - this.profileStorage.addresses.add(address.record); - } - return; - } - - this.profileStorage.addresses.add(address.record); - Services.prefs.setBoolPref("extensions.formautofill.firstTimeUse", false); - FormAutofillDoorhanger.show(target, "firstTimeUse"); + // TODO: Add first time use probe(bug 990199) and doorhanger(bug 1303510) + // profileStorage.addresses.add(address.record); } }, }; diff --git a/browser/extensions/formautofill/content/icon-address-save.svg b/browser/extensions/formautofill/content/icon-address-save.svg deleted file mode 100644 index d1e32b4cc2af..000000000000 --- a/browser/extensions/formautofill/content/icon-address-save.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/browser/extensions/formautofill/locale/en-US/formautofill.properties b/browser/extensions/formautofill/locale/en-US/formautofill.properties index f5c1ca8e622e..76baf35cd0ad 100644 --- a/browser/extensions/formautofill/locale/en-US/formautofill.properties +++ b/browser/extensions/formautofill/locale/en-US/formautofill.properties @@ -5,6 +5,3 @@ preferenceGroupTitle = Form Autofill enableProfileAutofill = Enable Profile Autofill savedProfiles = Saved Profiles… -saveAddressMessage = Firefox now saves your form data to help you fill out forms faster! -viewAutofillOptions = View Form Autofill options… -openAutofillMessagePanel = Open Form Autofill message panel diff --git a/browser/extensions/formautofill/test/unit/test_onFormSubmitted.js b/browser/extensions/formautofill/test/unit/test_onFormSubmitted.js index 54096e2e5bcb..1d362b17afd3 100644 --- a/browser/extensions/formautofill/test/unit/test_onFormSubmitted.js +++ b/browser/extensions/formautofill/test/unit/test_onFormSubmitted.js @@ -108,7 +108,7 @@ TESTCASES.forEach(testcase => { let input = MOCK_DOC.getElementById(key); input.value = testcase.formValue[key]; } - sinon.stub(FormAutofillContent, "_onFormSubmit"); + sinon.spy(FormAutofillContent, "_onFormSubmit"); FormAutofillContent.identifyAutofillFields(MOCK_DOC); FormAutofillContent.notify(form);