Add regression test against endless loop spotted in bug #853879

Link to the bug in question: https://bugzilla.mozilla.org/show_bug.cgi?id=853879