I am able to work around this problem by loading a dummy first page, but I'd like to find a real permanent solution.
I added code to enumerate all the members using IDispatchEx::GetNextDispID(), but it doesn't ever enumerate any of JavaScript functions. It does enumerate non-JavaScript members such as "onbeforeunload", "onafterprint", "top", "self", etc...
This really has me stumped. The fact that it doesn't happen every time, and certain computers seem to reproduce the problem and others don't makes me think it is perhaps a race condition.