This was really hard to track down, the comment there really convinced me that
the code was correct, so I ended up looking at everything else before that...

This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1494453.