We have an IE extension implemented as a Browser Helper Object (BHO). We have a utility function written in C++ that we add to the window object of the page so that other scripts in the page can use it to load local script files dynamically. In order to resolve relative paths to these local script files, however, we need to determine the path of the JavaScript file that calls our function:
myfunc()
written in C++ and exposed to the page's JavaScript- file:///path/to/some/javascript.js
- (additional stack frames)
From the top frame I want to get the information that the script calling myfunc()
is located in file:///path/to/some/javascript.js.
I first expected that we could simply use the IActiveScriptDebug
interface to get a stacktrace from our utility function. However, it appears to be impossible to get the IActiveScript
interface from an IWebBrowser2
interface or associated document (see Full callstack for multiple frames JS on IE8).
The only thing I can think of is to register our own script debugger implementation and have myfunc()
break into the debugger. However, I'm skeptical that this will work without prompting the user about whether they want to break into the debugger.
Before doing more thorough tests of this approach, I wanted to check whether anyone has definitive information about whether this is likely to work and/or can suggest an alternative approach that will enable a function written in C++ to get a stack trace from the scripting engine that invoked it.