On Sat, Apr 26, 2014 at 04:04:15AM +0000, Karl Dahlke wrote: > In js you can call new Window(url) to bring up a new window, > a new web page; then use the back key to go back to the first window. > But there is also the native method window.open(url) > which does exactly the same thing. > I had native functions in jsdom.cpp to do both these, > and I really dislike redundant code. Yeah, i didn't know about the new window syntax. > Isn't there some way to convert open into new Window? > There is, but I had to google around to find it. > Answer on stackoverflow.com, they have a lot of answers over there. Agreed, I've spent much of my life over the last few years looking at stackoverflow.com answers. > So I got rid of the native code window.open() in jsdom.cpp and put this > in startwindow.js. > > function open() { > return Window.apply(this, arguments); > } > > You can't use the new Window syntax here, no way to make that work, > but fortunately calling Window is the same as calling new Window, > or any class/constructor for that matter, > and if you do it this way you can apply the arguments of the calling function. > So open(), which can have from 1 to 3 arguments, > those are just passed through to the constructor. > Pretty cool eh? > I mean I didn't know js could do that. It certainly looks useful. > Here's something even cooler. > When I do it this way the assert goes away. > No, I don't really know why. > I guess it didn't have anything to do with global flags, > as I wrote in my last email. That's a bit odd. > Perhaps the problem was the way I was mapping open() over to the constructor in C, > using the spider API. > It was messy and hairy, and hard to get right. Yeah, it certainly looks that way, but I'd like to know what was wrong. > This reaffirms my theme of putting as much as possible into startwindow.js. > It's much less code here, easier to read and maintain, > less potential for bugs, and independent of the js api. > Even if we switch js engines some day, we won't have to change startwindow.js. Well, hopefully we won't as long as we stick to standard ECMA script. > So now I can go to BankOfAmerica.com and click on > {Where do I enter my Passcode?} > and it works. > The more I play with edbrowse, the more problems I find and fix. Yeah, it's hard to test everything, particularly where js is concerned. On the subject of testing is there full window coverage in jsrt? Cheers, Adam.