The foam performance in the presence of oil plays an important role in foam application in enhancing oil recovery. The present study systematically investigated the effect of oil type, oil content, surfactant type, surfactant concentration, alkane chain length, salinity, and polymer concentration on foam performance in both the absence and presence of oil. The results showed that oil viscosity and oil density as well as oil component all contributed to foam performance in the presence of oil. Within a certain oil content, both light oil and heavy oil had a positive effect on foam, but heavy oil had a higher tendency to stabilize the foam. The order of foam performance by different surfactants was changed by the oil. It is noteworthy that heavy oil is detrimental to sodium dibutyl naphthalene sulfonate (BM) foam. Light oil can improve foam performance while heavy oil can harm foam in some specific cases. Lower salinity, longer alkane chain length, higher surfactant concentration and the presence of a polymer all benefited foam in the presence of crude oil.