Guys, many thanks for your replies.
We decided not to go with the foam for several reasons, including your points above.
In the end, I have opted for wet-blown borate-treated cellulose, which I hear is a good sound blocker. The entire cavity will be filled with the cellulose.
The subfloor is not exactly 'shared' (there will be the same insulation space between subfloors as there is between the walls), but it's not sheetrocked. However, I got the builder to put a 1/2" of ply all the way along the outside of the neighbor's subfloor in the demising wall. Hopefully this will assist as a sound block? I didn't want to put another against my studs on the demising wall too, otherwise there would only be 4" of insulation between the sheets of ply, with no insulation on the other sides. Instead on my side the cellulose will go back between the joists up to the inside edge of my 2x6 studs, which will mean an additional 5.5" of cellulose there. Hopefully this will be of equivalent effect to another 1/2" of ply without the 5.5" extra cellulose.
If, on the other hand, the insulation contractors end up putting in ply on my side too (perhaps to hold the cellulose into the wall so there's no chance of it gradually pushing out into the floor space), maybe I will get some open-cell foam and foam up around the other side of the ply to provide a good air barrier and help insulate that weak spot there too.