And even then, poking fun, to me, is a personal thing. There are poking-fun-type things I might say to a close friend that I would never say to an acquaintance. Making fun of a random-stranger foreigner who is doing you the honor of trying to learn your language is just mean-spirited, no matter how you look at it. Makes me wonder about the kind of people who would do that. As to your specific statement:
> In Chinese media it is common to make fun of how foreigners look and how they speak Chinese.
To me that just sounds like propaganda. The Chinese media is promoting the idea of Chinese superiority. "All those people from other nations look funny, and are too stupid to speak our language properly." Anecdotally, an ethnically-Chinese friend of mine who lived in China for a few years (and traveled around the country quite a bit) used to tell me that many, many native-born Chinese people speak Mandarin poorly, some to the point of being difficult to understand. So poking fun at foreigners for their bad Chinese is ironic, perhaps to the point of being a little sad.
A caricature of a French, British, or German person in American media, for example, is much more acceptable than a caricature of a Chinese person.
I'm not saying that we should be going out of our way to make fun of everyone every chance we get, but this idea that "oh, those people are different so they are off limits for jokes or criticism" is a good way to make sure those people never develop any level of resilience.