Here is a little handy function for removing files with Javascript on Mozzila platform:

function delete_file_by_path(path)
{
var file = Components.classes['@mozilla.org/file/local;1']
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(path);
if (file.exists())
file.remove(false);
}

Create a new instance of nsILocalFile, and the use the initWithPath function to initialize the file, and the delete the file is exists.