'What are all the ways to regain control of the execution thread in JavaScript

I'm trying to enumerate the entry points from the browser to JavaScript code. This includes initial script execution (the trivial example), and all ways of regaining control of the main execution thread after relinquishing it.

  • initial script execution
  • event listeners, when not fired programmatically (Node.addEventListener, DOMWindow.addEventListener, XMLHttpRequest.addEventListener, all object.oneventname attributes)
  • setTimeout
  • setInterval

Are there any others I should consider?

(For the curious: the point of this is to wrap all entry points in try...catch blocks so that catching and logging errors on iOS is possible within a UIWebView. But it ought to be useful general information to have.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source