From: Karl Dahlke <eklhad@comcast.net>
To: Edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] new window assert
Date: Sat, 26 Apr 2014 04:04:15 +0000 [thread overview]
Message-ID: <20140326040415.eklhad@comcast.net> (raw)
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
next reply other threads:[~2014-04-26 8:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-26 4:04 Karl Dahlke [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140326040415.eklhad@comcast.net \
--to=eklhad@comcast.net \
--cc=Edbrowse-dev@lists.the-brannons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).