edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] Amazon can of worms
Date: Mon, 21 Apr 2014 12:17:00 +0100	[thread overview]
Message-ID: <20140421111700.GD6603@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20140321004822.eklhad@comcast.net>

[-- Attachment #1: Type: text/plain, Size: 2300 bytes --]

On Mon, Apr 21, 2014 at 12:48:22AM +0000, Karl Dahlke wrote:
> Ok remember when I said amazon.com had its javascript in its home page,
> in modest pieces? No such luck.
> I found this snip of code that tries to execute
> but doesn't, because I don't have it implemented.
> 
>   var scriptElem = document.createElement('script');
>   scriptElem.src = "http://z-ecx.images-amazon.com/images/G/01/s9-campaigns/s9-multipack-min._V366882549_.js";
>   document.getElementsByTagName('head')[0].appendChild(scriptElem);
> 
> I am fairly certain this pulls in and executes javascript code dynamically.

Yep, that's my understanding as well.

> But when?
> When the src attribute is assigned?
> When the script object is placed in the head section?
> Or when that piece of javascript returns?
> 
> I really hope it's the latter.
> Otherwise all sorts of code has to be reentrant.
> I could stack up, actually fifo up, any such js urls and execute them
> after the invoking js returns.
> Not too hard to do, but it means I am missing entire swaths of js code
> in amazon.com, probably in the dog vomit category,
> which probably spends 90% of its time doing visual effects,
> and can I really afford to spend the next 4 months trying to figure it out?

I think in this case it is expected that the script element is placed (and thus
executed) in the DOM just as it would be if it was done in the html.
This basically means (I think) that we need to put the element in with the src
attribute then continue parsing all the script tags including the new addition.
This is slightly different from just running through the urls as there may be
(and probably are in some cases) script elements between where this bit of dynamic
weirdness is ran and where the script sits in the DOM.
This could mean that things it relies on aren't defined yet etc,
hence why if we support this we need to do it properly.

> It does confirm something though: as I keep going I keep finding little
> objects and methods that I just don't have implemented,
> and they don't usually entail the big rewrite, they are more like enhancements,
> but there are so many of them!

Agreed, though proper element creation support like this is going to be a bit
non-trivial I suspect.

Cheers,
Adam.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-04-21 11:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21  0:48 Karl Dahlke
2014-04-21 11:17 ` Adam Thompson [this message]
2014-04-21  8:53 Karl Dahlke
2014-04-22 14:17 ` Adam Thompson

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=20140421111700.GD6603@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /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).