edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] new window assert
@ 2014-04-26  4:04 Karl Dahlke
  2014-04-26 17:29 ` Adam Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Karl Dahlke @ 2014-04-26  4:04 UTC (permalink / raw)
  To: Edbrowse-dev

Well javascript gets more interesting every day.

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.
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.
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.

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.
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.

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.

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.

Karl Dahlke

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-27 12:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-26  4:04 [Edbrowse-dev] new window assert Karl Dahlke
2014-04-26 17:29 ` Adam Thompson
2014-04-26 18:16   ` Chris Brannon
2014-04-27  6:17     ` Adam Thompson
2014-04-27 12:41       ` Chris Brannon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).