mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 13:43:44 +00:00
45942a6da5
- missing bit of Bug 1209403 - Build xpidl stuff in the faster make backend. (2b46f612d4) - Bug 1209875 - Get rid of XULPPFLAGS. r=gps (84b1e0140e) - Bug 1220731 - Refactor embedjs script for use from moz.build rather than makefiles r=shu r=glandium (064363aef4) - Bug 1212015 - Fix an unchecked allocation in AsmJS r=terrence (c77978cae6) - Bug 1218641 - IonMonkey: MIPS64: Add support into asmjs. r=lth (c856ea1842) - Bug 1219821 - remove static failure, make it dynamic r=arai a=me (eec5ffaa57) - Bug 1210611 - Globally define MOZILLA_OFFICIAL. r=glandium (c06518f942) - Bug 1211765 - Remove remnants from --with-libxul-sdk. r=bsmedberg (79a4d4e4aa) - Bug 1221453 - Use SourcePaths for LOCAL_INCLUDES. r=gps (abb032990d) - Bug 1176094 - [ATK] Assign role SECTION to math groups instead of PANEL/UNKNOWN. r=surkov (18b059a017) - Bug 1175182 - Expose fractions and roots as ATK_ROLE_PANEL for ATK < 2.16. r=surkov (6d00256e56) - bug 1171728 - null check the result of ProxyAccessible::OuterDocOfRemoteBrowser (378533bdaf) - Bug 1207253 - make getChildCountCB correctly deal with outerdoc accessibles with proxy children, r=tbsaunde (303d37a9d3) - bug 1209615 - make remote primary docs RELATION_EMBEDS targets for atk r=davidb (782635334d) - bug 1196880 - correctly compute interfaces for proxies r=davidb (2ee6b6ffdd) - bug 1210803 - expose the selection interface on proxied accessibles r=davidb (006b68ee32) - bug 1210884 - expose the action interface on proxied accessibles r=davidb (837add2013) - bug 1185122 - don't try and fire platform events in the child process r=lsocks (622e18ed2c) - Bug 1210108 - Emit object:state-changed:showing event for doorhangers, r=tbsaunde (bd2d410651) - bug 1164193 - emit a few more events on proxied accessibles for atk r=davidb (79b0d7a324) - bug 1213516 - fire showing state change event for atk in place of an alert event r=davidb (08efdc7620) - Bug 1209470 - Remove use of expression closure from Add-on SDK. r=mossop (736026d0e9) - Bug 1212693 - Remove skipCOWCallableChecks. r=bz (e1b7c21fe5) - Bug 877896 - Print stack trace in the console service. r=bholley (4667c5df15) - Bug 1157648 - Make nsScriptError::ToString use only the first 512 characters of mSourceName and mSourceLine. r=bholley (8cabd24397) - Bug 1052139 - Continued work on making the global object's prototype chain immutable, once a switch is flipped. r=bz (3f7549bd11) - Bug 1052139 - Adjust sandbox code to create the sandbox with an (observably) immutable [[Prototype]], once the flag's flipped. r=bz (66b846642c) - Bug 1184382 - Handle a sandboxPrototype we don't subsume. r=gabor (1736954a3e) - Bug 1205707 part 1 - Clean up some is-TypedArrayObject code in Ion. r=Waldo (08d95d5db4) - Bug 1205707 part 2 - Add test. r=Waldo (d1af75fe83)
108 lines
3.6 KiB
JavaScript
108 lines
3.6 KiB
JavaScript
/* 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/. */
|
|
|
|
"use strict";
|
|
|
|
module.metadata = {
|
|
"stability": "unstable"
|
|
};
|
|
|
|
const { Cc, Ci, CC } = require("chrome");
|
|
const { uri: ADDON_URI } = require("../self");
|
|
const loginManager = Cc["@mozilla.org/login-manager;1"].
|
|
getService(Ci.nsILoginManager);
|
|
const { URL: parseURL } = require("../url");
|
|
const LoginInfo = CC("@mozilla.org/login-manager/loginInfo;1",
|
|
"nsILoginInfo", "init");
|
|
|
|
function filterMatchingLogins(loginInfo) {
|
|
return Object.keys(this).every(key => loginInfo[key] === this[key], this);
|
|
}
|
|
|
|
/**
|
|
* Removes `user`, `password` and `path` fields from the given `url` if it's
|
|
* 'http', 'https' or 'ftp'. All other URLs are returned unchanged.
|
|
* @example
|
|
* http://user:pass@www.site.com/foo/?bar=baz#bang -> http://www.site.com
|
|
*/
|
|
function normalizeURL(url) {
|
|
let { scheme, host, port } = parseURL(url);
|
|
// We normalize URL only if it's `http`, `https` or `ftp`. All other types of
|
|
// URLs (`resource`, `chrome`, etc..) should not be normalized as they are
|
|
// used with add-on associated credentials path.
|
|
return scheme === "http" || scheme === "https" || scheme === "ftp" ?
|
|
scheme + "://" + (host || "") + (port ? ":" + port : "") :
|
|
url
|
|
}
|
|
|
|
function Login(options) {
|
|
let login = Object.create(Login.prototype);
|
|
Object.keys(options || {}).forEach(function(key) {
|
|
if (key === 'url')
|
|
login.hostname = normalizeURL(options.url);
|
|
else if (key === 'formSubmitURL')
|
|
login.formSubmitURL = options.formSubmitURL ?
|
|
normalizeURL(options.formSubmitURL) : null;
|
|
else if (key === 'realm')
|
|
login.httpRealm = options.realm;
|
|
else
|
|
login[key] = options[key];
|
|
});
|
|
|
|
return login;
|
|
}
|
|
Login.prototype.toJSON = function toJSON() {
|
|
return {
|
|
url: this.hostname || ADDON_URI,
|
|
realm: this.httpRealm || null,
|
|
formSubmitURL: this.formSubmitURL || null,
|
|
username: this.username || null,
|
|
password: this.password || null,
|
|
usernameField: this.usernameField || '',
|
|
passwordField: this.passwordField || '',
|
|
}
|
|
};
|
|
Login.prototype.toLoginInfo = function toLoginInfo() {
|
|
let { url, realm, formSubmitURL, username, password, usernameField,
|
|
passwordField } = this.toJSON();
|
|
|
|
return new LoginInfo(url, formSubmitURL, realm, username, password,
|
|
usernameField, passwordField);
|
|
};
|
|
|
|
function loginToJSON(value) {
|
|
return Login(value).toJSON();
|
|
}
|
|
|
|
/**
|
|
* Returns array of `nsILoginInfo` objects that are stored in the login manager
|
|
* and have all the properties with matching values as a given `options` object.
|
|
* @param {Object} options
|
|
* @returns {nsILoginInfo[]}
|
|
*/
|
|
exports.search = function search(options) {
|
|
return loginManager.getAllLogins()
|
|
.filter(filterMatchingLogins, Login(options))
|
|
.map(loginToJSON);
|
|
};
|
|
|
|
/**
|
|
* Stores login info created from the given `options` to the applications
|
|
* built-in login management system.
|
|
* @param {Object} options.
|
|
*/
|
|
exports.store = function store(options) {
|
|
loginManager.addLogin(Login(options).toLoginInfo());
|
|
};
|
|
|
|
/**
|
|
* Removes login info from the applications built-in login management system.
|
|
* _Please note: When removing a login info the specified properties must
|
|
* exactly match to the one that is already stored or exception will be thrown._
|
|
* @param {Object} options.
|
|
*/
|
|
exports.remove = function remove(options) {
|
|
loginManager.removeLogin(Login(options).toLoginInfo());
|
|
};
|