There's a bug here, which I described in comments on this file over in https://github.com/mozilla-b2g/gaia/pull/16959/files

Justin may have a fix, but it isn't in this version of the PR.