mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Bug 1263935 - Forward AddonManager.mapURIToAddonId to AddonPathService.mapURIToAddonId
Issue #102
This commit is contained in:
parent
a055ca91ec
commit
9ff88cf7df
2 changed files with 10 additions and 13 deletions
|
|
@ -52,6 +52,10 @@ XPCOMUtils.defineLazyServiceGetter(this,
|
||||||
"ResProtocolHandler",
|
"ResProtocolHandler",
|
||||||
"@mozilla.org/network/protocol;1?name=resource",
|
"@mozilla.org/network/protocol;1?name=resource",
|
||||||
"nsIResProtocolHandler");
|
"nsIResProtocolHandler");
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this,
|
||||||
|
"AddonPathService",
|
||||||
|
"@mozilla.org/addon-path-service;1",
|
||||||
|
"amIAddonPathService");
|
||||||
|
|
||||||
const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
|
const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
|
||||||
"initWithPath");
|
"initWithPath");
|
||||||
|
|
@ -1887,8 +1891,7 @@ this.XPIProvider = {
|
||||||
logger.info("Mapping " + aID + " to " + aFile.path);
|
logger.info("Mapping " + aID + " to " + aFile.path);
|
||||||
this._addonFileMap.set(aID, aFile.path);
|
this._addonFileMap.set(aID, aFile.path);
|
||||||
|
|
||||||
let service = Cc["@mozilla.org/addon-path-service;1"].getService(Ci.amIAddonPathService);
|
AddonPathService.insertPath(aFile.path, aID);
|
||||||
service.insertPath(aFile.path, aID);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3916,16 +3919,8 @@ this.XPIProvider = {
|
||||||
* @see amIAddonManager.mapURIToAddonID
|
* @see amIAddonManager.mapURIToAddonID
|
||||||
*/
|
*/
|
||||||
mapURIToAddonID: function XPI_mapURIToAddonID(aURI) {
|
mapURIToAddonID: function XPI_mapURIToAddonID(aURI) {
|
||||||
let resolved = this._resolveURIToFile(aURI);
|
// Returns `null` instead of empty string if the URI can't be mapped.
|
||||||
if (!resolved || !(resolved instanceof Ci.nsIFileURL))
|
return AddonPathService.mapURIToAddonId(aURI) || null;
|
||||||
return null;
|
|
||||||
|
|
||||||
for (let [id, path] of this._addonFileMap) {
|
|
||||||
if (resolved.file.path.startsWith(path))
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,10 @@ function run_test_early() {
|
||||||
"resource://gre/modules/addons/XPIProvider.jsm", {});
|
"resource://gre/modules/addons/XPIProvider.jsm", {});
|
||||||
|
|
||||||
// Make the early API call.
|
// Make the early API call.
|
||||||
do_check_null(s.XPIProvider.mapURIToAddonID(uri));
|
// AddonManager still misses its provider and so doesn't work yet.
|
||||||
do_check_null(AddonManager.mapURIToAddonID(uri));
|
do_check_null(AddonManager.mapURIToAddonID(uri));
|
||||||
|
// But calling XPIProvider directly works immediately
|
||||||
|
do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id);
|
||||||
|
|
||||||
// Actually start up the manager.
|
// Actually start up the manager.
|
||||||
startupManager(false);
|
startupManager(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue