Hang on. Mark said to select All. That means a selection and no Crop tool. Hello!
When I crop an image to get rid "pixel overflow" (my words, not Adobe's), I drag the Crop tool outside of the canvas to the other side. It automatically snaps to the doc boundaries with such an exaggerated motion.
When using the Crop tool on the inside, and you don't want it to snap to canvas boundaries, hold either alt or ctrl (I forget which).
You hold Ctrl Stroker.
And i suggested the CROP command because of what you later noticed -- that i said "select all". If you only want to remove extra data, and not actually resize the document, that's one method you'd use.
And yes G, i meant exactly what i said. Your sentence here -- "Select, invert, delete only removes the visible area and not the parts outside the canvas." -- prompted me to use the explanation i did.
If however i read wrong, and now i see i may very well have [stuned], and you actually wanted to crop your document to fit the size of one specific layer's contents, then you do this:
Hide all layers but the one you want to crop to. Do this with one click, by holding the ALT key and clicking the eye icon of the desired layer.
Under the IMAGE menu choose TRIM. Accept the defaults, and click OK.
NOTE: this DOES trim off any extraneous pixel data that's beyond the visible canvas area.
No Mark, but I think I should be more clear, so forgive me for not being that in the first place.
I said: Select, invert, delete.
This is however not totally correct. I should have written "I select an area, invert the selection and press delete".
Also, if I would select all, it wouldn't work, because we will get the message that No pixels were selected.
Look at my example:
I have 3 layers. Layer 1 and 2 both contain an image with a size equal to the canvas size.
Layer 3 contains an image tjhas is larger than the canvas. The red area is the area that I want to keep, so in this case I only want to crop this layer. If I would just select this area, invert it and press delete, I would still have the pixels outside the canvas area, with the risk of moving them inside this canvas area if I move the layer. Of course what I can do is crop the image before I paste it inside my document, but the question is; can it also be done afterwards.
Stroker's idea with CTRL+J is a good solution, but maybe you might have some other ideas.