Backed out 2 changesets (bug 1371149) for failures in browser_autocomplete_insecure_warning.js a=backout

Backed out changeset 0623467f11ba (bug 1371149)
Backed out changeset 5c21cf82263e (bug 1371149)

MozReview-Commit-ID: CllUvst71aj

--HG--
extra : rebase_source : f0550b33761631168dc965455aa177b20a1414bf
This commit is contained in:
Wes Kocher 2017-08-08 11:04:50 -07:00
Родитель 66d2ff2fa6
Коммит a9604094ee
14 изменённых файлов: 60 добавлений и 309 удалений

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

@ -27,8 +27,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillHandler",
"resource://formautofill/FormAutofillHandler.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormLikeFactory",
"resource://gre/modules/FormLikeFactory.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "InsecurePasswordUtils",
"resource://gre/modules/InsecurePasswordUtils.jsm");
const formFillController = Cc["@mozilla.org/satchel/form-fill-controller;1"]
.getService(Ci.nsIFormFillController);
@ -102,7 +100,7 @@ AutofillProfileAutoCompleteSearch.prototype = {
let isAddressField = FormAutofillUtils.isAddressField(info.fieldName);
let handler = FormAutofillContent.getFormHandler(focusedInput);
let allFieldNames = handler.allFieldNames;
let filledRecordGUID = isAddressField ? handler.address.filledRecordGUID : handler.creditCard.filledRecordGUID;
let filledRecordGUID = isAddressField ? handler.address.filledRecordGUID : handler.creditCards.filledRecordGUID;
// Fallback to form-history if ...
// - no profile can fill the currently-focused input.
@ -139,13 +137,11 @@ AutofillProfileAutoCompleteSearch.prototype = {
adaptedRecords,
{});
} else {
let isSecure = InsecurePasswordUtils.isFormSecure(handler.form);
result = new CreditCardResult(searchString,
info.fieldName,
allFieldNames,
adaptedRecords,
{isSecure});
{});
}
listener.onSearchResult(this, result);
ProfileAutocomplete.setProfileAutoCompleteResult(result);

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

@ -82,7 +82,6 @@ FormAutofillParent.prototype = {
Services.ppmm.addMessageListener("FormAutofill:InitStorage", this);
Services.ppmm.addMessageListener("FormAutofill:GetRecords", this);
Services.ppmm.addMessageListener("FormAutofill:SaveAddress", this);
Services.ppmm.addMessageListener("FormAutofill:SaveCreditCard", this);
Services.ppmm.addMessageListener("FormAutofill:RemoveAddresses", this);
Services.ppmm.addMessageListener("FormAutofill:OpenPreferences", this);
Services.mm.addMessageListener("FormAutofill:OnFormSubmit", this);
@ -194,10 +193,6 @@ FormAutofillParent.prototype = {
}
break;
}
case "FormAutofill:SaveCreditCard": {
this.profileStorage.creditCards.add(data.creditcard);
break;
}
case "FormAutofill:RemoveAddresses": {
data.guids.forEach(guid => this.profileStorage.addresses.remove(guid));
break;
@ -224,7 +219,6 @@ FormAutofillParent.prototype = {
Services.ppmm.removeMessageListener("FormAutofill:InitStorage", this);
Services.ppmm.removeMessageListener("FormAutofill:GetRecords", this);
Services.ppmm.removeMessageListener("FormAutofill:SaveAddress", this);
Services.ppmm.removeMessageListener("FormAutofill:SaveCreditCard", this);
Services.ppmm.removeMessageListener("FormAutofill:RemoveAddresses", this);
Services.obs.removeObserver(this, "advanced-pane-loaded");
Services.prefs.removeObserver(ENABLED_PREF, this);

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

@ -346,7 +346,3 @@ this.FormAutofillUtils = {
this.log = null;
this.FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]);
XPCOMUtils.defineLazyGetter(FormAutofillUtils, "stringBundle", function() {
return Services.strings.createBundle("chrome://formautofill/locale/formautofill.properties");
});

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

@ -8,23 +8,14 @@ this.EXPORTED_SYMBOLS = ["AddressResult", "CreditCardResult"]; /* exported Addre
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");
XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() {
return Services.strings.createBundle("chrome://branding/locale/brand.properties");
});
XPCOMUtils.defineLazyPreferenceGetter(this, "insecureWarningEnabled", "security.insecure_field_warning.contextual.enabled");
this.log = null;
FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]);
class ProfileAutoCompleteResult {
constructor(searchString, focusedFieldName, allFieldNames, matchingProfiles, {
resultCode = null,
isSecure = true,
}) {
constructor(searchString, focusedFieldName, allFieldNames, matchingProfiles, {resultCode = null}) {
log.debug("Constructing new ProfileAutoCompleteResult:", [...arguments]);
// nsISupports
@ -42,8 +33,6 @@ class ProfileAutoCompleteResult {
this.defaultIndex = 0;
// The reason the search failed
this.errorDescription = "";
// The value used to determine whether the form is secure or not.
this._isSecure = isSecure;
// The result code of this result object.
if (resultCode) {
@ -158,6 +147,17 @@ class ProfileAutoCompleteResult {
class AddressResult extends ProfileAutoCompleteResult {
constructor(...args) {
super(...args);
// Add an empty result entry for footer. Its content will come from
// the footer binding, so don't assign any value to it.
// The additional properties: categories and focusedCategory are required of
// the popup to generate autofill hint on the footer.
this._popupLabels.push({
primary: "",
secondary: "",
categories: FormAutofillUtils.getCategoriesFromFieldNames(this._allFieldNames),
focusedCategory: FormAutofillUtils.getCategoryFromFieldName(this._focusedFieldName),
});
}
_getSecondaryLabel(focusedFieldName, allFieldNames, profile) {
@ -233,7 +233,7 @@ class AddressResult extends ProfileAutoCompleteResult {
_generateLabels(focusedFieldName, allFieldNames, profiles) {
// Skip results without a primary label.
let labels = profiles.filter(profile => {
return profiles.filter(profile => {
return !!profile[focusedFieldName];
}).map(profile => {
let primaryLabel = profile[focusedFieldName];
@ -248,24 +248,17 @@ class AddressResult extends ProfileAutoCompleteResult {
profile),
};
});
// Add an empty result entry for footer. Its content will come from
// the footer binding, so don't assign any value to it.
// The additional properties: categories and focusedCategory are required of
// the popup to generate autofill hint on the footer.
labels.push({
primary: "",
secondary: "",
categories: FormAutofillUtils.getCategoriesFromFieldNames(this._allFieldNames),
focusedCategory: FormAutofillUtils.getCategoryFromFieldName(this._focusedFieldName),
});
return labels;
}
}
class CreditCardResult extends ProfileAutoCompleteResult {
constructor(...args) {
super(...args);
// Add an empty result entry for footer.
this._popupLabels.push({primary: "", secondary: ""});
}
_getSecondaryLabel(focusedFieldName, allFieldNames, profile) {
@ -314,17 +307,8 @@ class CreditCardResult extends ProfileAutoCompleteResult {
}
_generateLabels(focusedFieldName, allFieldNames, profiles) {
if (!this._isSecure) {
if (!insecureWarningEnabled) {
return [];
}
let brandName = gBrandBundle.GetStringFromName("brandShortName");
return [FormAutofillUtils.stringBundle.formatStringFromName("insecureFieldWarningDescription", [brandName], 1)];
}
// Skip results without a primary label.
let labels = profiles.filter(profile => {
return profiles.filter(profile => {
return !!profile[focusedFieldName];
}).map(profile => {
return {
@ -334,40 +318,13 @@ class CreditCardResult extends ProfileAutoCompleteResult {
profile),
};
});
// Add an empty result entry for footer.
labels.push({primary: "", secondary: ""});
return labels;
}
// Always return empty string for credit card result. Since the decryption might
// be required of users' input, we have to suppress AutoCompleteController
// be required of users' input, we have to to suppress AutoCompleteController
// from filling encrypted data directly.
getValueAt(index) {
this._checkIndexBounds(index);
return "";
}
getLabelAt(index) {
this._checkIndexBounds(index);
let label = this._popupLabels[index];
if (typeof label == "string") {
return label;
}
return JSON.stringify(label);
}
getStyleAt(index) {
this._checkIndexBounds(index);
if (!this._isSecure && insecureWarningEnabled) {
return "insecureWarning";
}
if (index == this.matchCount - 1) {
return "autofill-footer";
}
return "autofill-profile";
}
}

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

@ -19,10 +19,6 @@
-moz-binding: url("chrome://formautofill/content/formautofill.xml#autocomplete-profile-listitem-footer");
}
#PopupAutoComplete > richlistbox > richlistitem[originaltype="insecureWarning"] {
-moz-binding: url("chrome://formautofill/content/formautofill.xml#autocomplete-creditcard-insecure-field");
}
/* Treat @collpased="true" as display: none similar to how it is for XUL elements.
* https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#Values */
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-profile"][collapsed="true"],

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

@ -58,10 +58,6 @@
<body></body>
</method>
<method name="handleOverUnderflow">
<body></body>
</method>
<method name="_adjustAutofillItemLayout">
<body>
<![CDATA[
@ -280,31 +276,4 @@
</implementation>
</binding>
<binding id="autocomplete-creditcard-insecure-field" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-richlistitem-insecure-field">
<implementation implements="nsIDOMXULSelectControlItemElement">
<constructor>
<![CDATA[
this.setAttribute("formautofillattached", "true");
]]>
</constructor>
<method name="_cleanup">
<body>
<![CDATA[
this.removeAttribute("formautofillattached");
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="click" button="0" phase="capturing"><![CDATA[
// Suppress any other handlers from its inheritance chain.
event.stopPropagation();
// Leave empty here until we're sure where to redirect for "Learn more" link
]]></handler>
</handlers>
</binding>
</bindings>

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

@ -56,5 +56,3 @@ email = Email
cancel = Cancel
save = Save
countryWarningMessage = Autofill is currently available only for US addresses
insecureFieldWarningDescription = %S has detected an insecure site. Credit card autofill is temporarily disabled

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

@ -3,7 +3,6 @@ head = head.js
support-files =
../fixtures/autocomplete_basic.html
../fixtures/autocomplete_creditcard_basic.html
[browser_autocomplete_footer.js]
[browser_autocomplete_marked_back_forward.js]
@ -11,8 +10,7 @@ support-files =
[browser_check_installed.js]
[browser_editAddressDialog.js]
[browser_first_time_use_doorhanger.js]
[browser_insecure_form.js]
[browser_manageAddressesDialog.js]
[browser_privacyPreferences.js]
[browser_manageAddressesDialog.js]
[browser_submission_in_private_mode.js]
[browser_update_doorhanger.js]

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

@ -21,7 +21,7 @@ add_task(async function setup_storage() {
add_task(async function test_click_on_footer() {
await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
const {autoCompletePopup: {richlistbox: itemsBox}} = browser;
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
await openPopupOn(browser, "#organization");
// Click on the footer
@ -31,13 +31,17 @@ add_task(async function test_click_on_footer() {
await BrowserTestUtils.removeTab(await prefTabPromise);
ok(true, "Tab: preferences#privacy was successfully opened by clicking on the footer");
await closePopup(browser);
// Ensure the popup is closed before entering the next test.
await ContentTask.spawn(browser, {}, async function() {
content.document.getElementById("organization").blur();
});
await BrowserTestUtils.waitForCondition(() => !autoCompletePopup.popupOpen);
});
});
add_task(async function test_press_enter_on_footer() {
await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
const {autoCompletePopup: {richlistbox: itemsBox}} = browser;
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
await openPopupOn(browser, "#organization");
// Navigate to the footer and press enter.
@ -50,13 +54,17 @@ add_task(async function test_press_enter_on_footer() {
await BrowserTestUtils.removeTab(await prefTabPromise);
ok(true, "Tab: preferences#privacy was successfully opened by pressing enter on the footer");
await closePopup(browser);
// Ensure the popup is closed before entering the next test.
await ContentTask.spawn(browser, {}, async function() {
content.document.getElementById("organization").blur();
});
await BrowserTestUtils.waitForCondition(() => !autoCompletePopup.popupOpen);
});
});
add_task(async function test_phishing_warning() {
await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
const {autoCompletePopup: {richlistbox: itemsBox}} = browser;
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
await openPopupOn(browser, "#street-address");
const warningBox = itemsBox.querySelector(".autocomplete-richlistitem:last-child")._warningTextBox;
@ -70,6 +78,10 @@ add_task(async function test_phishing_warning() {
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
await expectWarningText(browser, "Also autofills company, phone, email");
await closePopup(browser);
// Ensure the popup is closed before entering the next test.
await ContentTask.spawn(browser, {}, async function() {
content.document.getElementById("street-address").blur();
});
await BrowserTestUtils.waitForCondition(() => !autoCompletePopup.popupOpen);
});
});

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

@ -51,6 +51,11 @@ add_task(async function test_back_forward() {
await openPopupOn(browser, "#street-address");
checkPopup(autoCompletePopup);
await closePopup(browser);
// Ensure the popup is closed before entering the next test.
await ContentTask.spawn(browser, {}, async function() {
content.document.getElementById("street-address").blur();
});
await BrowserTestUtils.waitForCondition(() => !autoCompletePopup.popupOpen,
"popup should have closed");
});
});

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

@ -43,7 +43,12 @@ add_task(async function test_detach_tab_marked() {
await openPopupOn(newBrowser, "#street-address");
checkPopup(newAutoCompletePopup);
await closePopup(newBrowser);
// Ensure the popup is closed before entering the next test.
await ContentTask.spawn(newBrowser, {}, async function() {
content.document.getElementById("street-address").blur();
});
await BrowserTestUtils.waitForCondition(() => !newAutoCompletePopup.popupOpen,
"popup should have closed");
await BrowserTestUtils.closeWindow(newWin);
});
});

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

@ -1,94 +0,0 @@
"use strict";
const TEST_URL_PATH_CC = "://example.org/browser/browser/extensions/formautofill/test/browser/autocomplete_creditcard_basic.html";
const TEST_URL_PATH = "://example.org/browser/browser/extensions/formautofill/test/browser/autocomplete_basic.html";
add_task(async function setup_storage() {
await saveAddress(TEST_ADDRESS_1);
await saveAddress(TEST_ADDRESS_2);
await saveAddress(TEST_ADDRESS_3);
await saveCreditCard(TEST_CREDIT_CARD_1);
await saveCreditCard(TEST_CREDIT_CARD_2);
await saveCreditCard(TEST_CREDIT_CARD_3);
});
add_task(async function test_insecure_form() {
async function runTest({urlPath, protocol, focusInput, expectedType, expectedResultLength}) {
await BrowserTestUtils.withNewTab({gBrowser, url: protocol + urlPath}, async function(browser) {
await openPopupOn(browser, focusInput);
const items = getDisplayedPopupItems(browser);
is(items.length, expectedResultLength, `Should show correct amount of results in "${protocol}"`);
const firstItem = items[0];
is(firstItem.getAttribute("originaltype"), expectedType, `Item should attach with correct binding in "${protocol}"`);
await closePopup(browser);
});
}
const testSets = [{
urlPath: TEST_URL_PATH,
protocol: "https",
focusInput: "#organization",
expectedType: "autofill-profile",
expectedResultLength: 2,
}, {
urlPath: TEST_URL_PATH,
protocol: "http",
focusInput: "#organization",
expectedType: "autofill-profile",
expectedResultLength: 2,
}, {
urlPath: TEST_URL_PATH_CC,
protocol: "https",
focusInput: "#cc-name",
expectedType: "autofill-profile",
expectedResultLength: 3,
}, {
urlPath: TEST_URL_PATH_CC,
protocol: "http",
focusInput: "#cc-name",
expectedType: "insecureWarning", // insecure warning field
expectedResultLength: 1,
}];
await runTest(testSets[0]);
await runTest(testSets[1]);
await runTest(testSets[2]);
await runTest(testSets[3]);
});
add_task(async function test_click_on_insecure_warning() {
await BrowserTestUtils.withNewTab({gBrowser, url: "http" + TEST_URL_PATH_CC}, async function(browser) {
await openPopupOn(browser, "#cc-name");
const insecureItem = getDisplayedPopupItems(browser)[0];
await EventUtils.synthesizeMouseAtCenter(insecureItem, {});
// Check input's value after popup closed to ensure the completion of autofilling.
await expectPopupClose(browser);
const inputValue = await ContentTask.spawn(browser, {}, async function() {
return content.document.querySelector("#cc-name").value;
});
is(inputValue, "");
await closePopup(browser);
});
});
add_task(async function test_press_enter_on_insecure_warning() {
await BrowserTestUtils.withNewTab({gBrowser, url: "http" + TEST_URL_PATH_CC}, async function(browser) {
await openPopupOn(browser, "#cc-name");
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser);
// Check input's value after popup closed to ensure the completion of autofilling.
await expectPopupClose(browser);
const inputValue = await ContentTask.spawn(browser, {}, async function() {
return content.document.querySelector("#cc-name").value;
});
is(inputValue, "");
await closePopup(browser);
});
});

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

@ -1,9 +1,7 @@
/* exported MANAGE_ADDRESSES_DIALOG_URL, EDIT_ADDRESS_DIALOG_URL, BASE_URL,
TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3,
TEST_CREDIT_CARD_1, TEST_CREDIT_CARD_2, TEST_CREDIT_CARD_3,
sleep, expectPopupOpen, openPopupOn, expectPopupClose, closePopup, clickDoorhangerButton,
getAddresses, saveAddress, removeAddresses, saveCreditCard,
getDisplayedPopupItems */
sleep, expectPopupOpen, openPopupOn, clickDoorhangerButton,
getAddresses, saveAddress, removeAddresses */
"use strict";
@ -35,51 +33,22 @@ const TEST_ADDRESS_3 = {
"postal-code": "12345",
};
const TEST_CREDIT_CARD_1 = {
"cc-name": "John Doe",
"cc-number": "1234567812345678",
// "cc-number-encrypted": "",
"cc-exp-month": 4,
"cc-exp-year": 2017,
};
const TEST_CREDIT_CARD_2 = {
"cc-name": "Timothy Berners-Lee",
"cc-number": "1111222233334444",
"cc-exp-month": 12,
"cc-exp-year": 2022,
};
const TEST_CREDIT_CARD_3 = {
"cc-number": "9999888877776666",
"cc-exp-month": 1,
"cc-exp-year": 2000,
};
const MAIN_BUTTON_INDEX = 0;
const SECONDARY_BUTTON_INDEX = 1;
function getDisplayedPopupItems(browser, selector = ".autocomplete-richlistitem") {
const {autoCompletePopup: {richlistbox: itemsBox}} = browser;
const listItemElems = itemsBox.querySelectorAll(selector);
return [...listItemElems].filter(item => item.getAttribute("collapsed") != "true");
}
async function sleep(ms = 500) {
await new Promise(resolve => setTimeout(resolve, ms));
}
async function expectPopupOpen(browser) {
const {autoCompletePopup} = browser;
const listItemElems = getDisplayedPopupItems(browser);
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem");
await BrowserTestUtils.waitForCondition(() => autoCompletePopup.popupOpen,
"popup should be open");
await BrowserTestUtils.waitForCondition(() => {
return [...listItemElems].every(item => {
return (item.getAttribute("originaltype") == "autofill-profile" ||
item.getAttribute("originaltype") == "insecureWarning" ||
item.getAttribute("originaltype") == "autofill-footer") &&
item.hasAttribute("formautofillattached");
});
@ -89,39 +58,14 @@ async function expectPopupOpen(browser) {
async function openPopupOn(browser, selector) {
await SimpleTest.promiseFocus(browser);
/* eslint no-shadow: ["error", { "allow": ["selector"] }] */
const identified = await ContentTask.spawn(browser, {selector}, async function({selector}) {
const input = content.document.querySelector(selector);
const forms = content.document.getElementsByTagName("form");
const rootElement = [...forms].find(form => form.contains(input)) || content.document.body;
input.focus();
if (rootElement.hasAttribute("test-formautofill-identified")) {
return true;
}
rootElement.setAttribute("test-formautofill-identified", "true");
return false;
await ContentTask.spawn(browser, {selector}, async function({selector}) {
content.document.querySelector(selector).focus();
});
// Wait 2 seconds for identifyAutofillFields if the form hasn't been identified yet.
if (!identified) {
await sleep(2000);
}
await sleep(2000);
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
await expectPopupOpen(browser);
}
async function expectPopupClose(browser) {
await BrowserTestUtils.waitForCondition(() => !browser.autoCompletePopup.popupOpen,
"popup should have closed");
}
async function closePopup(browser) {
await ContentTask.spawn(browser, {}, async function() {
content.document.activeElement.blur();
});
await expectPopupClose(browser);
}
function getRecords(data) {
return new Promise(resolve => {
Services.cpmm.addMessageListener("FormAutofill:Records", function getResult(result) {
@ -141,10 +85,6 @@ function saveAddress(address) {
return TestUtils.topicObserved("formautofill-storage-changed");
}
function saveCreditCard(creditcard) {
Services.cpmm.sendAsyncMessage("FormAutofill:SaveCreditCard", {creditcard});
return TestUtils.topicObserved("formautofill-storage-changed");
}
function removeAddresses(guids) {
Services.cpmm.sendAsyncMessage("FormAutofill:RemoveAddresses", {guids});
return TestUtils.topicObserved("formautofill-storage-changed");

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

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Form Autofill Credit Card Demo Page</title>
</head>
<body>
<h1>Form Autofill Credit Card Demo Page</h1>
<form id="form">
<p><label>Name: <input id="cc-name" autocomplete="cc-name"></label></p>
<p><label>Card Number: <input id="cc-number" autocomplete="cc-number"></label></p>
<p><label>Expiration month: <input id="cc-exp-month" autocomplete="cc-exp-month"></label></p>
<p><label>Expiration year: <input id="cc-exp-year" autocomplete="cc-exp-year"></label></p>
<p><label>CSC: <input id="cc-csc" autocomplete="cc-csc"></label></p>
<p>
<input type="submit" value="Submit">
<button type="reset">Reset</button>
</p>
</form>
</body>
</html>