Strange behaviour using headings and frames

If I set some headings inside a frame, the ordering on Navigator window is wrong, including on PDF export, but a generated Table of Contents in Write is correct.

I don’t know if this is intended behaviour, or if it is a bug.

Occurs in LibreOffice 4.3 and 5.0.0.5, on Linux and Windows.

[edit: lo5 tag]

That all looks fine to me.