author | Luke Chang <lchang@mozilla.com> |
Thu, 24 Nov 2016 13:21:05 +0800 | |
changeset 324358 | 82018512953d40dcff9dd4d13959b1cedea4fe52 |
parent 324357 | 5aa4b8d980786d55d1fda696329312f40cc33868 |
child 324359 | cbd4fb9f368e4ea3dd2efff323fc860aa407bdbe |
push id | 31003 |
push user | cbook@mozilla.com |
push date | Mon, 28 Nov 2016 15:36:30 +0000 |
treeherder | mozilla-central@2594b001d757 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | MattN |
bugs | 1319995 |
milestone | 53.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
|
--- a/browser/extensions/formautofill/test/unit/head.js +++ b/browser/extensions/formautofill/test/unit/head.js @@ -1,42 +1,34 @@ /** - * Provides infrastructure for automated login components tests. + * Provides infrastructure for automated formautofill components tests. */ - /* exported importAutofillModule, getTempFile */ +/* exported importAutofillModule, getTempFile */ "use strict"; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://testing-common/MockDocument.jsm"); -// Redirect the path of the resouce in addon to the exact file path. -let defineLazyModuleGetter = XPCOMUtils.defineLazyModuleGetter; -XPCOMUtils.defineLazyModuleGetter = function() { - let result = /^resource\:\/\/formautofill\/(.+)$/.exec(arguments[2]); - if (result) { - arguments[2] = Services.io.newFileURI(do_get_file(result[1])).spec; - } - return defineLazyModuleGetter.apply(this, arguments); -}; - -// Load the module by Service newFileURI API for running extension's XPCShell test -function importAutofillModule(module) { - return Cu.import(Services.io.newFileURI(do_get_file(module)).spec); -} - XPCOMUtils.defineLazyModuleGetter(this, "DownloadPaths", "resource://gre/modules/DownloadPaths.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm"); +// Register the resource path of formautofill +let resHandler = Services.io.getProtocolHandler("resource") + .QueryInterface(Ci.nsISubstitutingProtocolHandler); +let dataURI = NetUtil.newURI(do_get_file(".", true)); +resHandler.setSubstitution("formautofill", dataURI); + // While the previous test file should have deleted all the temporary files it // used, on Windows these might still be pending deletion on the physical file // system. Thus, start from a new base number every time, to make a collision // with a file that is still pending deletion highly unlikely. let gFileCounter = Math.floor(Math.random() * 1000000); /** * Returns a reference to a temporary file, that is guaranteed not to exist, and
new file mode 100644 --- /dev/null +++ b/browser/extensions/formautofill/test/unit/tail.js @@ -0,0 +1,10 @@ +/** + * Cleans up the testing environment. + */ + +/* global resHandler */ + +"use strict"; + +// Unregister the resource path of formautofill. +resHandler.setSubstitution("formautofill", null);
--- a/browser/extensions/formautofill/test/unit/test_autofillFormFields.js +++ b/browser/extensions/formautofill/test/unit/test_autofillFormFields.js @@ -1,15 +1,15 @@ /* * Test for form auto fill content helper fill all inputs function. */ "use strict"; -let {FormAutofillHandler} = importAutofillModule("FormAutofillContent.jsm"); +let {FormAutofillHandler} = Cu.import("resource://formautofill/FormAutofillContent.jsm"); const TESTCASES = [ { description: "Form without autocomplete property", document: `<form><input id="given-name"><input id="family-name"> <input id="street-addr"><input id="city"><input id="country"> <input id='email'><input id="tel"></form>`, fieldDetails: [],
--- a/browser/extensions/formautofill/test/unit/test_collectFormFields.js +++ b/browser/extensions/formautofill/test/unit/test_collectFormFields.js @@ -1,15 +1,15 @@ /* * Test for form auto fill content helper collectFormFields functions. */ "use strict"; -let {FormAutofillHandler} = importAutofillModule("FormAutofillContent.jsm"); +let {FormAutofillHandler} = Cu.import("resource://formautofill/FormAutofillContent.jsm"); const TESTCASES = [ { description: "Form without autocomplete property", document: `<form><input id="given-name"><input id="family-name"> <input id="street-addr"><input id="city"><input id="country"> <input id='email'><input id="tel"></form>`, returnedFormat: [],
--- a/browser/extensions/formautofill/test/unit/test_populateFieldValues.js +++ b/browser/extensions/formautofill/test/unit/test_populateFieldValues.js @@ -1,17 +1,17 @@ /* * Test for populating field values in Form Autofill Parent. */ /* global FormAutofillParent */ "use strict"; -importAutofillModule("FormAutofillParent.jsm"); +Cu.import("resource://formautofill/FormAutofillParent.jsm"); do_get_profile(); const TEST_FIELDS = [ {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "organization"}, {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"}, {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"}, {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level1"},
--- a/browser/extensions/formautofill/test/unit/test_profileStorage.js +++ b/browser/extensions/formautofill/test/unit/test_profileStorage.js @@ -2,17 +2,17 @@ * Tests ProfileStorage object. */ /* global ProfileStorage */ "use strict"; Cu.import("resource://gre/modules/Task.jsm"); -Cu.import(Services.io.newFileURI(do_get_file("ProfileStorage.jsm")).spec); +Cu.import("resource://formautofill/ProfileStorage.jsm"); const TEST_STORE_FILE_NAME = "test-profile.json"; const TEST_PROFILE_1 = { organization: "World Wide Web Consortium", streetAddress: "32 Vassar Street\nMIT Room 32-G524", addressLevel2: "Cambridge", addressLevel1: "MA",
--- a/browser/extensions/formautofill/test/unit/xpcshell.ini +++ b/browser/extensions/formautofill/test/unit/xpcshell.ini @@ -1,11 +1,11 @@ [DEFAULT] head = head.js -tail = +tail = tail.js support-files = ../../content/FormAutofillContent.jsm ../../content/FormAutofillParent.jsm ../../content/ProfileStorage.jsm [test_autofillFormFields.js] [test_collectFormFields.js] [test_populateFieldValues.js]