Rootkits for JavaScript Environments [pdf]
static.usenix.org
static.usenix.org
The question is... how do you create an iframe or worker safely? document.createElement and window.Worker can be poisoned too.
Perhaps its possible to verify the functions you're using are native and not created in user-land? that way, at least you could identify the attack and stop execution.