* [Edbrowse-dev] Amazon can of worms
@ 2014-04-21 8:53 Karl Dahlke
2014-04-22 14:17 ` Adam Thompson
0 siblings, 1 reply; 4+ messages in thread
From: Karl Dahlke @ 2014-04-21 8:53 UTC (permalink / raw)
To: Edbrowse-dev
Adam writes:
> 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.
Perhaps, but in this case, Amazon.com, the script element is added
to the head section, which is about 1000 lines in the past.
It is not placed in some tag in the future.
Since we don't have time travle,
the best we can do is to execute the script right now.
I guess, it's all rather merky.
Karl Dahlke
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Edbrowse-dev] Amazon can of worms
2014-04-21 8:53 [Edbrowse-dev] Amazon can of worms Karl Dahlke
@ 2014-04-22 14:17 ` Adam Thompson
0 siblings, 0 replies; 4+ messages in thread
From: Adam Thompson @ 2014-04-22 14:17 UTC (permalink / raw)
To: Karl Dahlke; +Cc: Edbrowse-dev
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
On Mon, Apr 21, 2014 at 08:53:54AM +0000, Karl Dahlke wrote:
> Adam writes:
> > 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.
>
> Perhaps, but in this case, Amazon.com, the script element is added
> to the head section, which is about 1000 lines in the past.
> It is not placed in some tag in the future.
> Since we don't have time travle,
> the best we can do is to execute the script right now.
> I guess, it's all rather merky.
Yeah, that's seriously weird. I fail to see how this is expected to work,
since even if the DOM is created first then script elements executed in the
order they appear, the addition of an extra script element in the head section
after that part of the DOM has had all its script elements executed would be a bit pointless.
The only way this could possibly work without invoking the script out of place
would be to re-check the DOM on each update executing new script elements.
This just sounds like a bit of a recipe for disaster.
Before doing anything with this I'd be tempted to look at how other browsers
handle this case, assuming it's not just a bug in amazon's page which no one
has noticed yet.
Cheers,
Adam.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Edbrowse-dev] Amazon can of worms
2014-04-21 0:48 Karl Dahlke
@ 2014-04-21 11:17 ` Adam Thompson
0 siblings, 0 replies; 4+ messages in thread
From: Adam Thompson @ 2014-04-21 11:17 UTC (permalink / raw)
To: Karl Dahlke; +Cc: Edbrowse-dev
[-- 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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Edbrowse-dev] Amazon can of worms
@ 2014-04-21 0:48 Karl Dahlke
2014-04-21 11:17 ` Adam Thompson
0 siblings, 1 reply; 4+ messages in thread
From: Karl Dahlke @ 2014-04-21 0:48 UTC (permalink / raw)
To: Edbrowse-dev
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.
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?
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!
Karl Dahlke
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-22 14:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-21 8:53 [Edbrowse-dev] Amazon can of worms Karl Dahlke
2014-04-22 14:17 ` Adam Thompson
-- strict thread matches above, loose matches on Subject: below --
2014-04-21 0:48 Karl Dahlke
2014-04-21 11:17 ` Adam Thompson
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).