User:GijsKruitbosch/JS Debugging/DocumentFromException: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(I finally understood. . . :))
 
Line 20: Line 20:


We then continue chasing references from globalObject and finally get to a window thanks to [http://lxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-utils.js#602 getBaseWindowFromWindow].
We then continue chasing references from globalObject and finally get to a window thanks to [http://lxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-utils.js#602 getBaseWindowFromWindow].
''This is a fine solution but I fail to see how this can be used to react only to '''uncaught''' exceptions. For this purpose Plan A seems the way to go since it becomes an "error" only once nobody caught it.''

Latest revision as of 13:30, 16 August 2007

Main aim

Be able to determine the document an error came off from within chrome js/extension/etc.

We'll use plan A unless we run out of time to do this on branch, in which case we have plan B for backup..

Plan A

  • Make nsIConsoleMessage implement nsIException (rather, make nsConsoleMessage also implement nsIException if it is from an uncaught exception; the QI should fail if it's a message that isn't from an exception, ideally --shaver)
  • Make nsIException have useful stuff in its data field that can be used to determine the document that the message came off. Note: what? (as in, exactly) (How about an nsIDocument? Should check with bz and the docshell mafia here. --shaver)

Plan B

Discussion

Rob showed me an easier, all JS way:

The starting point is the jsdIStackFrame "frame" parameter in function jsdExecutionHook, from which we obtain the globalObject of its executionContext.

We then continue chasing references from globalObject and finally get to a window thanks to getBaseWindowFromWindow.