I found on this site www.freefilesdownloads.com , that they show different content for "Mediapartners-Google" bot and visitors. And ads appears on any theme that they show to bot. It's allowed?
Technically, I think it is not hard to detect, but it is just if they want to do it. Simply use another bot with different IP, and send header information like a browser, then compare the results.
It's allowed if you have permission. I've seen some large sites doing this. Like in their source, you would see things like student load consolidation, insurance, etc. Basically they tell adsense what ads they want displayed.