Re-land patch from bug 1088904