Bug 838114 uplifting to v1-train

For some reason the patches for https://bugzilla.mozilla.org/show_bug.cgi?id=889301 have not landed in v1-train. This pull request includes those patches solving the conflicts which have arisen.