Backports for 46.6
A quick note on the first commit:
It adds API that explicitly targets extensions, which is why I left it out of 46.5.
But Alessandro would really like in it 46.x and promised to do proper error handling when the API is missing (i.e. on 46.0-5).
Given that that's the only consumer of the API for the foreseeable future, I agreed to make an exception and include it in 46.6.
Other than that, it's a subset of the commits from the 47.1 MR.
Edited by Florian Müllner