Heat the vegetable oil in a medium skillet over moderate heat. Cook the onions until soft, about 10 minutes. Transfer to a food processor fitted with the metal blade or a blender.
Add the remaining ingredients and puree, in batches if you are using a blender, until smooth. Pass through a medium strainer, pressing with a spatula or wooden spoon to push through as much as possible. Pour into a saucepan, and add the salt. Bring to a boil, reduce to a simmer and cook, uncovered, 20 minutes. Adjust the seasonings. Set aside to cool for table salsa or use warm for rice or chilaquiles. Store in the refrigerator 2 to 3 days or in the freezer for weeks.