The PCB is the heatsink for most of the power, so the actual maximum ambient temperature for a given power dissipation will vary greatly with the nature of the substrate and what else is mounted nearby. For example, consumer paper-base phenolics are worse than epoxy-glass which are much worse than ceramic or aluminum-core substrates.
There is also the factor of "hot spots" in the resistor construction due to current crowding caused by trimming cuts in the resistive film. Conservative designs may avoid using a resistor above 30-40% of rated power. If you've got a situation where the power is being stressed you'll need to take a lot more care.
Here is a document from Koa Speers on resistor derating. And another which uses thermal camera measurements of terminal temperatures to calculate derating. Note that they do not recommend going over 100% of rated power under any conditions. If you do, you are on your own. And this similar note.
You can also refer to this Yageo document on mounting which illustrates effects of substrates and other mounting factors:
Edit: As pointed out in comments, the Vishay link pointed to by @Cursorkeys mentions the standard conditions for measurement EN 140400 said (in that document, not the standard, which I do not have):
2.3.3: FR4 base material
100 mm x 65 mm x 1.4 mm, 35 μm Cu-layer, pad/circuit path
2.0 mm width.
.. which are fairly optimistic conditions for the resistor