Bug 788416 - Remove ancient and unused tests in toolkit\mozapps\extensions\test\unit. r=Mossop

This commit is contained in:
Blair McBride 2012-09-18 16:48:01 +12:00
parent 89da4904a8
commit aa4ebfe7cf
13 changed files with 0 additions and 1054 deletions

View File

@ -1,64 +0,0 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<RDF:Description RDF:about="urn:mozilla:item:bug356370_1@tests.mozilla.org">
<em:installLocation>app-profile</em:installLocation>
<em:version>1</em:version>
<em:name>Bug 356370 test 1</em:name>
<em:type NC:parseType="Integer">2</em:type>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<RDF:Description RDF:about="urn:mozilla:item:bug356370_2@tests.mozilla.org">
<em:installLocation>invalid-hi</em:installLocation>
<em:version>1</em:version>
<em:name>Bug 356370 test 2</em:name>
<em:type NC:parseType="Integer">2</em:type>
<em:userDisabled>true</em:userDisabled>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<RDF:Description RDF:about="urn:mozilla:item:bug356370_3@tests.mozilla.org">
<em:installLocation>invalid</em:installLocation>
<em:version>1</em:version>
<em:name>Bug 356370 test 3</em:name>
<em:type NC:parseType="Integer">2</em:type>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<RDF:Description RDF:about="urn:mozilla:item:bug356370_4@tests.mozilla.org">
<em:installLocation>invalid</em:installLocation>
<em:version>1</em:version>
<em:name>Bug 356370 test 4</em:name>
<em:type NC:parseType="Integer">4</em:type>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<RDF:Seq RDF:about="urn:mozilla:item:root">
<RDF:li RDF:resource="urn:mozilla:item:bug356370_1@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:bug356370_2@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:bug356370_3@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:bug356370_4@tests.mozilla.org"/>
</RDF:Seq>
</RDF:RDF>

View File

@ -1,20 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug356370_1@tests.mozilla.org</em:id>
<em:version>1</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 356370 test 1</em:name>
</Description>
</RDF>

View File

@ -1,20 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug356370_2@tests.mozilla.org</em:id>
<em:version>1</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 356370 test 2</em:name>
</Description>
</RDF>

View File

@ -1,21 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug356370_4@tests.mozilla.org</em:id>
<em:version>1</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 356370 test 4</em:name>
<em:type NC:parseType="Integer">4</em:type>
</Description>
</RDF>

View File

@ -1 +0,0 @@
# blank file to stop the EM attempting to create one anyway

View File

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug421396@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>bug421396 test</em:name>
</Description>
</RDF>

View File

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:test_bug463819_2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:test_bug463819_5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:test_bug463819_8@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem id="test_bug463819_4@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="test_bug463819_5@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="test_bug463819_6@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="test_bug463819_7@tests.mozilla.org">
<versionRange severity="3"/>
</emItem>
<emItem id="test_bug463819_8@tests.mozilla.org">
<versionRange severity="3"/>
</emItem>
<emItem id="test_bug463819_9@tests.mozilla.org">
<versionRange severity="3"/>
</emItem>
</emItems>
</blocklist>

View File

@ -1,234 +0,0 @@
/* 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/.
*/
/*
* These are intended to be a set of base functions enabling unit testing
* for the Extension Manager component.
*/
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const PREFIX_NS_CHROME = "http://www.mozilla.org/rdf/chrome#";
const PREFIX_ITEM_URI = "urn:mozilla:item:";
const NS_INSTALL_LOCATION_APPPROFILE = "app-profile";
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
var gXULAppInfo = null;
var gEM = null;
var gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
.getService(Components.interfaces.nsIRDFService);
/**
* Utility functions
*/
function EM_NS(property) {
return PREFIX_NS_EM + property;
}
function CHROME_NS(property) {
return PREFIX_NS_CHROME + property;
}
function EM_R(property) {
return gRDF.GetResource(EM_NS(property));
}
function EM_L(literal) {
return gRDF.GetLiteral(literal);
}
function EM_I(integer) {
return gRDF.GetIntLiteral(integer);
}
function EM_D(integer) {
return gRDF.GetDateLiteral(integer);
}
/**
* Extract the string value from a RDF Literal or Resource
* @param literalOrResource
* RDF String Literal or Resource
* @returns String value of the literal or resource, or undefined if the object
* supplied is not a RDF string literal or resource.
*/
function stringData(literalOrResource) {
if (literalOrResource instanceof Components.interfaces.nsIRDFLiteral)
return literalOrResource.Value;
if (literalOrResource instanceof Components.interfaces.nsIRDFResource)
return literalOrResource.Value;
return undefined;
}
/**
* Extract the integer value of a RDF Literal
* @param literal
* nsIRDFInt literal
* @return integer value of the literal
*/
function intData(literal) {
if (literal instanceof Components.interfaces.nsIRDFInt)
return literal.Value;
return undefined;
}
/**
* Gets a RDF Resource for item with the given ID
* @param id
* The GUID of the item to construct a RDF resource to the
* active item for
* @returns The RDF Resource to the Active item.
*/
function getResourceForID(id) {
return gRDF.GetResource(PREFIX_ITEM_URI + id);
}
/**
* Extract a string property for an add-on
* @param id
* ID of the add-on to retrieve a property for
* @param property
* The localname of the property
* @returns String value of the property or undefined if the property
* does not exist
*/
function getManifestProperty(id, property) {
return stringData(gEM.datasource.GetTarget(getResourceForID(id), EM_R(property), true));
}
/**
* Returns a testcase xpi
* @param name
* The name of the testcase (without extension)
* @returns an nsIFile pointing to the testcase xpi
*/
function do_get_addon(name)
{
return do_get_file("addons/" + name + ".xpi");
}
/**
* Creates an nsIXULAppInfo
* @param id
* The ID of the test application
* @param name
* A name for the test application
* @param version
* The version of the application
* @param platformVersion
* The gecko version of the application
*/
function createAppInfo(id, name, version, platformVersion)
{
gXULAppInfo = {
vendor: "Mozilla",
name: name,
ID: id,
version: version,
appBuildID: "2007010101",
platformVersion: platformVersion,
platformBuildID: "2007010101",
inSafeMode: false,
logConsoleErrors: true,
OS: "XPCShell",
XPCOMABI: "noarch-spidermonkey",
invalidateCachesOnRestart: function invalidateCachesOnRestart() {},
QueryInterface: function QueryInterface(iid) {
if (iid.equals(Components.interfaces.nsIXULAppInfo)
|| iid.equals(Components.interfaces.nsIXULRuntime)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
var XULAppInfoFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return gXULAppInfo.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
XULAPPINFO_CONTRACTID, XULAppInfoFactory);
}
function startEM(upgraded) {
var needsRestart = false;
if (upgraded) {
try {
needsRestart = gEM.checkForMismatches();
}
catch (e) {
do_throw("checkForMismatches threw an exception: " + e + "\n");
needsRestart = false;
upgraded = false;
}
}
if (!upgraded || !needsRestart)
needsRestart = gEM.start();
if (needsRestart)
restartEM();
}
/**
* This simulates an application startup. Since we will be starting from an
* empty profile we follow that path.
*/
function startupEM()
{
gEM = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
gEM.QueryInterface(Components.interfaces.nsIObserver);
gEM.observe(null, "profile-after-change", "startup");
// First run is a new profile which nsAppRunner would consider as an update
// (no existing compatibility.ini)
startEM(true);
}
/**
* Simple function to simulate the termination of an app to the EM.
* This harness does not support creating a new EM after calling this.
*/
function shutdownEM()
{
// xpcshell calls xpcom-shutdown so we don't actually do anything here.
gEM = null;
}
/**
* Many operations require restarts to take effect. This function should
* perform all that is necessary for this to happen.
*/
function restartEM(newVersion)
{
if (newVersion) {
gXULAppInfo.version = newVersion;
startEM(true);
}
else {
startEM(false);
}
}
var gDirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
// Need to create and register a profile folder.
var gProfD = do_get_profile();
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
// Enable more extensive EM logging
gPrefs.setBoolPref("extensions.logging.enabled", true);

View File

@ -1,8 +0,0 @@
/* 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/.
*/
// Close down any remaining EM
if (gEM)
shutdownEM();

View File

@ -1,128 +0,0 @@
/* 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/.
*/
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
openWindow: function(parent, url, name, features, arguments) {
// It is expected that the update dialog is shown during this test.
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIWindowWatcher)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
function write_cache_line(stream, location, id, mtime) {
var line = location + "\t" + id + "\trel%" + id + "\t" + Math.floor(mtime / 1000) + "\t\r\n";
stream.write(line, line.length);
}
/**
* This copies two extensions, a default extensions datasource into the profile
* It also manufactures an extensions.cache file with invalid items.
* There are 4 test extensions:
* bug356370_1@tests.mozilla.org exists in app-profile and an unused version is in invalid-lo
* bug356370_2@tests.mozilla.org exists in invalid-hi and an unused version is in app-profile
* bug356370_3@tests.mozilla.org exists in invalid
* bug356370_4@tests.mozilla.org is a theme existing in invalid and a new install
* will be detected in app-profile
*
* After startup only the first two should exist in the correct install location
* and installing extensions should be successful.
*/
function setup_profile() {
// Set up the profile with some existing extensions
// Not nice to copy the extensions datasource in, but bringing up the EM to
// create it properly will invalidate the test
var source = do_get_file("data/test_bug356370.rdf");
source.copyTo(gProfD, "extensions.rdf");
// Must programmatically generate the cache since it depends on the mimetimes
// being accurate.
var cache = gProfD.clone();
cache.append("extensions.cache");
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
foStream.init(cache, 0x02 | 0x08 | 0x20, 0666, 0); // Write, create, truncate
var addon = gProfD.clone();
addon.append("extensions");
addon.append("bug356370_1@tests.mozilla.org");
source = do_get_file("data/test_bug356370_1.rdf");
addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source.copyTo(addon, "install.rdf");
write_cache_line(foStream, "app-profile", "bug356370_1@tests.mozilla.org",
addon.lastModifiedTime);
addon = gProfD.clone();
addon.append("extensions");
addon.append("bug356370_2@tests.mozilla.org");
source = do_get_file("data/test_bug356370_2.rdf");
addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source.copyTo(addon, "install.rdf");
write_cache_line(foStream, "app-profile", "bug356370_2@tests.mozilla.org",
addon.lastModifiedTime);
addon = gProfD.clone();
addon.append("extensions");
addon.append("bug356370_4@tests.mozilla.org");
source = do_get_file("data/test_bug356370_4.rdf");
addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source.copyTo(addon, "install.rdf");
// Write out a set of invalid entries
write_cache_line(foStream, "invalid-lo", "bug356370_1@tests.mozilla.org", 0);
write_cache_line(foStream, "invalid-hi", "bug356370_2@tests.mozilla.org", 0);
write_cache_line(foStream, "invalid", "bug356370_3@tests.mozilla.org", 0);
write_cache_line(foStream, "invalid", "bug356370_4@tests.mozilla.org", 0);
foStream.close();
}
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
gPrefs.setCharPref("extensions.lastAppVersion", "4");
setup_profile();
startupEM();
do_check_neq(gEM.getItemForID("bug356370_1@tests.mozilla.org"), null);
do_check_eq(getManifestProperty("bug356370_1@tests.mozilla.org", "installLocation"), "app-profile");
do_check_neq(gEM.getItemForID("bug356370_2@tests.mozilla.org"), null);
do_check_eq(getManifestProperty("bug356370_2@tests.mozilla.org", "installLocation"), "app-profile");
// This should still be disabled
do_check_eq(getManifestProperty("bug356370_2@tests.mozilla.org", "isDisabled"), "true");
do_check_eq(gEM.getItemForID("bug356370_3@tests.mozilla.org"), null);
do_check_neq(gEM.getItemForID("bug356370_4@tests.mozilla.org"), null);
do_check_eq(getManifestProperty("bug356370_4@tests.mozilla.org", "installLocation"), "app-profile");
gEM.installItemFromFile(do_get_addon("test_bug257155"), NS_INSTALL_LOCATION_APPPROFILE);
do_check_neq(gEM.getItemForID("bug257155@tests.mozilla.org"), null);
restartEM();
do_check_neq(gEM.getItemForID("bug257155@tests.mozilla.org"), null);
do_check_neq(gEM.getItemForID("bug356370_1@tests.mozilla.org"), null);
do_check_neq(gEM.getItemForID("bug356370_2@tests.mozilla.org"), null);
do_check_eq(gEM.getItemForID("bug356370_3@tests.mozilla.org"), null);
do_check_neq(gEM.getItemForID("bug356370_4@tests.mozilla.org"), null);
}

View File

@ -1,220 +0,0 @@
/* 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/.
*/
const TESTID = "bug421396@tests.mozilla.org";
var INSTALLED = true;
// This creates a fake directory that cannot be modified. Nothing exists inside
// the directory.
function RestrictedPath(source, isVisible) {
this.source = source;
this.isVisible = isVisible;
}
// This doesn't implement all of nsIFile, just enough to keep the EM happy.
RestrictedPath.prototype = {
// A real nsIFile that this shadows
source: null,
// If this file is visible or not. Only the main directory for the addon is visible.
isVisible: null,
append: function(node) {
this.source.append(node);
this.isVisible = false;
},
normalize: function() {
this.source.normalize();
},
create: function(type, permissions) {
if (this.isVisible)
throw Components.errors.NS_ERROR_FILE_ALREADY_EXISTS;
throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED;
},
get leafName() {
return this.source.leafName;
},
copyTo: function(parentdir, name) {
throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED;
},
copyToFollowingLinks: function(parentdir, name) {
throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED;
},
moveTo: function(parentdir, name) {
throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED;
},
remove: function(recursive) {
if (this.isVisible)
throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED;
throw Components.errors.NS_ERROR_FILE_NOT_FOUND;
},
get lastModifiedTime() {
if (this.isVisible)
return Date.now();
throw Components.errors.NS_ERROR_FILE_NOT_FOUND;
},
get lastModifiedTimeOfLink() {
return this.lastModifiedTime;
},
get path() { return this.source.path; },
exists: function() { return this.isVisible; },
isDirectory: function() { return this.isVisible; },
isFile: function() { return !this.isVisible; },
clone: function() {
return new RestrictedPath(this.source.clone(), this.isVisible);
},
get parent() {
return new RestrictedPath(this.source.parent, false);
},
getRelativeDescriptor: function(basedir) {
return this.source.getRelativeDescriptor(basedir);
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIFile)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
function DirectoryEnumerator(files) {
this.files = files;
this.pos = 0;
}
DirectoryEnumerator.prototype = {
pos: null,
files: null,
get nextFile() {
if (this.pos < this.files.length)
return this.files[this.pos++];
return null;
},
close: function() {
}
};
var InstallLocation = {
name: "test-location",
location: null,
restricted: null,
canAccess: null,
priority: Components.interfaces.nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL,
get itemLocations() {
return new DirectoryEnumerator([ this.getItemLocation(TESTID) ]);
},
getItemLocation: function(id) {
if (id == TESTID) {
var file = do_get_file("data/test_bug421396");
if (INSTALLED)
return file;
// If we are simulating after the extension is "removed" then return the
// empty undeletable directory.
return new RestrictedPath(file, true);
}
var file = do_get_cwd();
file.append("INVALIDNAME");
file.append(id);
return file;
},
getIDForLocation: function(file) {
if (file.leafName == "test_bug421396")
return TESTID;
return file.leafName;
},
getItemFile: function(id, filePath) {
var itemLocation = this.getItemLocation(id).clone();
var parts = filePath.split("/");
for (let part of parts)
itemLocation.append(part);
return itemLocation;
},
itemIsManagedIndependently: function(id) {
return false;
},
stageFile: function(file, id) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
getStageFile: function(id) {
return null;
},
removeFile: function(file) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIInstallLocation)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
var InstallLocationFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return InstallLocation.QueryInterface(iid);
}
};
const IL_CID = Components.ID("{6bdd8320-57c7-4f19-81ad-c32fdfc2b423}");
const IL_CONTRACT = "@tests.mozilla.org/installlocation;1";
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(IL_CID, "Test Install Location",
IL_CONTRACT, InstallLocationFactory);
var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager);
categoryManager.addCategoryEntry("extension-install-locations", "test-location",
IL_CONTRACT, false, true);
function run_test()
{
// EM needs to be running.
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
startupEM();
// Addon in the fake location should be installed now.
do_check_neq(gEM.getItemForID(TESTID), null);
// Mark the add-on as uninstalled and restart ot pickup the change.
INSTALLED = false;
restartEM();
do_check_eq(gEM.getItemForID(TESTID), null);
// Test install something.
gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE);
do_check_neq(gEM.getItemForID("bug397778@tests.mozilla.org"), null);
restartEM();
do_check_eq(gEM.getItemForID(TESTID), null);
do_check_neq(gEM.getItemForID("bug397778@tests.mozilla.org"), null);
}

View File

@ -1,229 +0,0 @@
/* 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/.
*/
const INSTALLERROR_SUCCESS = 0;
const INSTALLERROR_INCOMPATIBLE_VERSION = -3;
const INSTALLERROR_BLOCKLISTED = -6;
const INSTALLERROR_SOFTBLOCKED = -10;
// Disables security checking our updates which haven't been signed
gPrefs.setBoolPref("extensions.checkUpdateSecurity", false);
// Get the HTTP server.
const Cr = Components.results;
Components.utils.import("resource://testing-common/httpd.js");
var testserver;
// This allows the EM to attempt to display errors to the user without failing
var promptService = {
alert: function(aParent, aDialogTitle, aText) {
},
alertCheck: function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) {
},
confirm: function(aParent, aDialogTitle, aText) {
},
confirmCheck: function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) {
},
confirmEx: function(aParent, aDialogTitle, aText, aButtonFlags, aButton0Title, aButton1Title, aButton2Title, aCheckMsg, aCheckState) {
},
prompt: function(aParent, aDialogTitle, aText, aValue, aCheckMsg, aCheckState) {
},
promptUsernameAndPassword: function(aParent, aDialogTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState) {
},
promptPassword: function(aParent, aDialogTitle, aText, aPassword, aCheckMsg, aCheckState) {
},
select: function(aParent, aDialogTitle, aText, aCount, aSelectList, aOutSelection) {
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIPromptService)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
// This will be called to show the blocklist message, we just make it look like
// it was dismissed.
var WindowWatcher = {
openWindow: function(parent, url, name, features, arguments) {
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIWindowWatcher)
|| iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var PromptServiceFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return promptService.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"),
"PromptService",
"@mozilla.org/embedcomp/prompt-service;1", PromptServiceFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
var gNextTest, gLastStatus;
// nsIAddonInstallListener
var installListener = {
onDownloadStarted: function(aAddon) {
},
onDownloadEnded: function(aAddon) {
},
onInstallStarted: function(aAddon) {
},
onCompatibilityCheckStarted: function(aAddon) {
},
onCompatibilityCheckEnded: function(aAddon, aStatus) {
},
onInstallEnded: function(aAddon, aStatus) {
gLastStatus = aStatus;
},
onInstallsCompleted: function() {
gNextTest();
},
onDownloadProgress: function onProgress(aAddon, aValue, aMaxValue) {
}
}
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9");
// Install the blocklist
var blocklist = do_get_file("data/test_bug463819.xml");
blocklist.copyTo(gProfD, "blocklist.xml");
// Create and configure the HTTP server.
testserver = new HttpServer();
testserver.registerDirectory("/", do_get_file("data"));
testserver.start(4444);
startupEM();
gEM.addInstallListener(installListener);
// These add-ons require no update check so will complete installation immediately
dump("Installing add-on 1\n");
gNextTest = test_addon_1;
gEM.installItemFromFile(do_get_addon("test_bug463819_1"), NS_INSTALL_LOCATION_APPPROFILE);
dump("Installing add-on 4\n");
gNextTest = test_addon_4;
gEM.installItemFromFile(do_get_addon("test_bug463819_4"), NS_INSTALL_LOCATION_APPPROFILE);
dump("Installing add-on 7\n");
gNextTest = test_addon_7;
gEM.installItemFromFile(do_get_addon("test_bug463819_7"), NS_INSTALL_LOCATION_APPPROFILE);
do_test_pending();
// These add-ons will perform a compatibility check before responding.
dump("Installing add-on 2\n");
gNextTest = test_addon_2;
gEM.installItemFromFile(do_get_addon("test_bug463819_2"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Compatible in install.rdf and not in blocklist
function test_addon_1() {
do_check_eq(gLastStatus, INSTALLERROR_SUCCESS);
}
// Compatible in install.rdf and low severity in blocklist
function test_addon_4() {
do_check_eq(gLastStatus, INSTALLERROR_SOFTBLOCKED);
}
// Compatible in install.rdf and high severity in blocklist
function test_addon_7() {
do_check_eq(gLastStatus, INSTALLERROR_BLOCKLISTED);
}
// Incompatible in install.rdf, compatible in update.rdf, not in blocklist
function test_addon_2() {
do_check_eq(gLastStatus, INSTALLERROR_SUCCESS);
dump("Installing add-on 3\n");
gNextTest = test_addon_3;
gEM.installItemFromFile(do_get_addon("test_bug463819_3"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Incompatible in install.rdf, incompatible in update.rdf, not in blocklist
function test_addon_3() {
do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION);
dump("Installing add-on 5\n");
gNextTest = test_addon_5;
gEM.installItemFromFile(do_get_addon("test_bug463819_5"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Incompatible in install.rdf, compatible in update.rdf, low severity in blocklist
function test_addon_5() {
do_check_eq(gLastStatus, INSTALLERROR_SOFTBLOCKED);
dump("Installing add-on 6\n");
gNextTest = test_addon_6;
gEM.installItemFromFile(do_get_addon("test_bug463819_6"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Incompatible in install.rdf, incompatible in update.rdf, low severity in blocklist
function test_addon_6() {
do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION);
dump("Installing add-on 8\n");
gNextTest = test_addon_8;
gEM.installItemFromFile(do_get_addon("test_bug463819_8"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Incompatible in install.rdf, compatible in update.rdf, high severity in blocklist
function test_addon_8() {
do_check_eq(gLastStatus, INSTALLERROR_BLOCKLISTED);
dump("Installing add-on 9\n");
gNextTest = test_addon_9;
gEM.installItemFromFile(do_get_addon("test_bug463819_9"), NS_INSTALL_LOCATION_APPPROFILE);
}
// Incompatible in install.rdf, incompatible in update.rdf, high severity in blocklist
function test_addon_9() {
do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION);
finish_test();
}
function finish_test() {
testserver.stop(do_test_finished);
}