Fix JS execution from root context (#12927)

Change-Id: Iafdb1e4a738ab69362a8f50d1f30efca7ea00978