Backport fix for bug 1590538

Mozilla landed a fix for our legacy/trac#31764 (moved). We should backport their fix and remove our workaround