Bug 1322622 - Make form autofill handler a frame script and load from bootstrap.js. r=steveck

MozReview-Commit-ID: DeIjzMytVxJ

--HG--
rename : browser/extensions/formautofill/FormAutofillContent.jsm => browser/extensions/formautofill/content/FormAutofillContent.js
extra : rebase_source : 5e62eb24e76bf58436e73267ebb8e872e42a71d2
This commit is contained in:
Matthew Noorenberghe 2016-12-16 01:26:46 -05:00
Родитель ec36746143
Коммит 877c8752a1
9 изменённых файлов: 46 добавлений и 14 удалений

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

@ -1555,3 +1555,6 @@ pref("browser.crashReports.unsubmittedCheck.autoSubmit", false);
// controlling validation are located in /services/sync/services-sync.js
pref("services.sync.validation.enabled", true);
#endif
// Preferences for the form autofill system extension
pref("browser.formautofill.enabled", false);

20
browser/extensions/formautofill/bootstrap.js поставляемый
Просмотреть файл

@ -6,7 +6,25 @@
/* exported startup, shutdown, install, uninstall */
function startup() {}
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillParent",
"resource://formautofill/FormAutofillParent.jsm");
function startup() {
// Besides this pref, we'll need dom.forms.autocomplete.experimental enabled
// as well to make sure form autocomplete works correctly.
if (!Services.prefs.getBoolPref("browser.formautofill.enabled")) {
return;
}
FormAutofillParent.init();
Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillContent.js", true);
}
function shutdown() {}
function install() {}
function uninstall() {}

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

@ -3,13 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Implements a service used by DOM content to request Form Autofill.
* Form Autofill frame script.
*/
"use strict";
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
/**
* Handles profile autofill for a DOM Form element.
* @param {HTMLFormElement} form Form that need to be auto filled
@ -130,5 +131,3 @@ FormAutofillHandler.prototype = {
}
},
};
this.EXPORTED_SYMBOLS = ["FormAutofillHandler"];

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

@ -5,3 +5,6 @@
[features/formautofill@mozilla.org] chrome.jar:
% resource formautofill %res/
res/ (*.jsm)
% content formautofill %content/
content/ (content/*)

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

@ -2,7 +2,7 @@
* Provides infrastructure for automated formautofill components tests.
*/
/* exported importAutofillModule, getTempFile */
/* exported getTempFile */
"use strict";
@ -37,6 +37,17 @@ Components.manager.addBootstrappedManifestLocation(extensionDir);
// with a file that is still pending deletion highly unlikely.
let gFileCounter = Math.floor(Math.random() * 1000000);
function loadFormAutofillContent() {
let facGlobal = {};
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScriptWithOptions("chrome://formautofill/content/FormAutofillContent.js", {
target: facGlobal,
});
return facGlobal;
}
/**
* Returns a reference to a temporary file, that is guaranteed not to exist, and
* to have never been created before.
@ -71,10 +82,13 @@ function getTempFile(leafName) {
}
add_task(function* test_common_initialize() {
Services.prefs.setBoolPref("browser.formautofill.enabled", true);
Services.prefs.setBoolPref("dom.forms.autocomplete.experimental", true);
loadFormAutofillContent();
// Clean up after every test.
do_register_cleanup(() => {
Services.prefs.setBoolPref("dom.forms.autocomplete.experimental", false);
Services.prefs.clearUserPref("browser.formautofill.enabled");
Services.prefs.clearUserPref("dom.forms.autocomplete.experimental");
});
});

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

@ -1,5 +0,0 @@
/**
* Cleans up the testing environment.
*/
"use strict";

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

@ -4,7 +4,7 @@
"use strict";
let {FormAutofillHandler} = Cu.import("resource://formautofill/FormAutofillContent.jsm");
let {FormAutofillHandler} = loadFormAutofillContent();
const TESTCASES = [
{

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

@ -4,7 +4,7 @@
"use strict";
let {FormAutofillHandler} = Cu.import("resource://formautofill/FormAutofillContent.jsm");
let {FormAutofillHandler} = loadFormAutofillContent();
const TESTCASES = [
{

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

@ -1,7 +1,7 @@
[DEFAULT]
firefox-appdir = browser
head = head.js
tail = tail.js
tail =
support-files =
[test_autofillFormFields.js]