edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] infinite loop js while()
@ 2017-01-28 10:27 Karl Dahlke
  2017-01-28 17:02 ` Geoff McLane
  2017-01-29  2:18 ` Kevin Carhart
  0 siblings, 2 replies; 5+ messages in thread
From: Karl Dahlke @ 2017-01-28 10:27 UTC (permalink / raw)
  To: Edbrowse-dev

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

After some detective work, here is the js that causes the infinite loop.
It creates two nodes, ft and fg, uses ft.innerHTML to put some nodes beneath ft,
then has a while loop that, I assume, moves the nodes from ft to fg.
Here's the code, then more thoughts below.

var rid=oio.at_ei,fg=document.createDocumentFragment(),ft=document.createElement('div');
ft.innerHTML='<'+'div class="'+oio.at_ec+'" id="'+rid+'" style="'+oio.at_es+'">&nbsp;'+'<'+'/div'+'>';
while(ft.firstChild)fg.appendChild(ft.firstChild);
document.body.insertBefore(fg,document.body.childNodes[0]);

Ok, so the generated html looks like this.

<div class="MBoxAdMain gp-ui" id="sponsoredwellcontainertop" style="position:absolute;display:block;">&nbsp;</div>

Running through innerHTML, that creates a node under ft.
All good so far.
Then comes the while loop, and the only way this isn't an infinite loop is if appendChild removes the node first from wherever it is, then appends it.
I've been talking about this on the edbrowse side, in our own tree of nodes, but here it is on the js side, strictly within dom, and it's the same issue.
I think this is not just compelling evidence, but a smoking gun.
Even if it doesn't say so in the spec, appendChild and insertBefore should remove the child from wherever it is first, then put it beneath the new node.
Then the while loop above simply moves all the children from ft to fg.  Zip zap.

I'm going to think about this for a bit, cause if I just start writing code I'll screw it up, but I'm pretty sure I understand the problem now.
I just need to fix it with a small amount of code, and not breaking anything else.
I imagine if I fix it on the js side, by issuing a remove when necessary, before the append, then all those actions will carry over to the edbrowse side in our sideEffects, and I won't have to change any code over there, it will just all work.

Karl Dahlke

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

* Re: [Edbrowse-dev] infinite loop js while()
  2017-01-28 10:27 [Edbrowse-dev] infinite loop js while() Karl Dahlke
@ 2017-01-28 17:02 ` Geoff McLane
  2017-01-29  2:18 ` Kevin Carhart
  1 sibling, 0 replies; 5+ messages in thread
From: Geoff McLane @ 2017-01-28 17:02 UTC (permalink / raw)
  To: edbrowse-dev

Actually, it was reading about this infinite loop
that got me interested in re-compiling edbrowse
using the later msvc140, so I could see if I could
find this...

But it sounds like you are getting there before I
actually got around to a trial ;=))

Good detective work Sherlock... oops mean Karl...

Regards, Geoff.


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

* Re: [Edbrowse-dev] infinite loop js while()
  2017-01-28 10:27 [Edbrowse-dev] infinite loop js while() Karl Dahlke
  2017-01-28 17:02 ` Geoff McLane
@ 2017-01-29  2:18 ` Kevin Carhart
  2017-01-29  3:34   ` Karl Dahlke
  1 sibling, 1 reply; 5+ messages in thread
From: Kevin Carhart @ 2017-01-29  2:18 UTC (permalink / raw)
  To: Edbrowse-dev



This is great!  Very exciting!


On Sat, 28 Jan 2017, Karl Dahlke wrote:

> After some detective work, here is the js that causes the infinite loop.
> It creates two nodes, ft and fg, uses ft.innerHTML to put some nodes beneath ft,
> then has a while loop that, I assume, moves the nodes from ft to fg.
> Here's the code, then more thoughts below.
>
> var rid=oio.at_ei,fg=document.createDocumentFragment(),ft=document.createElement('div');
> ft.innerHTML='<'+'div class="'+oio.at_ec+'" id="'+rid+'" style="'+oio.at_es+'">&nbsp;'+'<'+'/div'+'>';
> while(ft.firstChild)fg.appendChild(ft.firstChild);
> document.body.insertBefore(fg,document.body.childNodes[0]);
>
> Ok, so the generated html looks like this.
>
> <div class="MBoxAdMain gp-ui" id="sponsoredwellcontainertop" style="position:absolute;display:block;">&nbsp;</div>
>
> Running through innerHTML, that creates a node under ft.
> All good so far.
> Then comes the while loop, and the only way this isn't an infinite loop is if appendChild removes the node first from wherever it is, then appends it.
> I've been talking about this on the edbrowse side, in our own tree of nodes, but here it is on the js side, strictly within dom, and it's the same issue.
> I think this is not just compelling evidence, but a smoking gun.
> Even if it doesn't say so in the spec, appendChild and insertBefore should remove the child from wherever it is first, then put it beneath the new node.
> Then the while loop above simply moves all the children from ft to fg.  Zip zap.
>
> I'm going to think about this for a bit, cause if I just start writing code I'll screw it up, but I'm pretty sure I understand the problem now.
> I just need to fix it with a small amount of code, and not breaking anything else.
> I imagine if I fix it on the js side, by issuing a remove when necessary, before the append, then all those actions will carry over to the edbrowse side in our sideEffects, and I won't have to change any code over there, it will just all work.
>
> Karl Dahlke
>

--------
Kevin Carhart * 415 225 5306 * The Ten Ninety Nihilists

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

* [Edbrowse-dev]  infinite loop js while()
  2017-01-29  2:18 ` Kevin Carhart
@ 2017-01-29  3:34   ` Karl Dahlke
  2017-01-29  4:43     ` Kevin Carhart
  0 siblings, 1 reply; 5+ messages in thread
From: Karl Dahlke @ 2017-01-29  3:34 UTC (permalink / raw)
  To: Edbrowse-dev

This is fixed now - the infinite loop is gone.

Karl Dahlke

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

* Re: [Edbrowse-dev] infinite loop js while()
  2017-01-29  3:34   ` Karl Dahlke
@ 2017-01-29  4:43     ` Kevin Carhart
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Carhart @ 2017-01-29  4:43 UTC (permalink / raw)
  To: Edbrowse-dev



So the Washington Post example now works!
I noticed that Raw Story still crashes.
I was rooting for the possibility that the new great work would wipe out 
both of these.





On Sat, 28 Jan 2017, Karl Dahlke wrote:

> This is fixed now - the infinite loop is gone.
>
> Karl Dahlke
> _______________________________________________
> Edbrowse-dev mailing list
> Edbrowse-dev@lists.the-brannons.com
> http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev
>

--------
Kevin Carhart * 415 225 5306 * The Ten Ninety Nihilists

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

end of thread, other threads:[~2017-01-29  4:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-28 10:27 [Edbrowse-dev] infinite loop js while() Karl Dahlke
2017-01-28 17:02 ` Geoff McLane
2017-01-29  2:18 ` Kevin Carhart
2017-01-29  3:34   ` Karl Dahlke
2017-01-29  4:43     ` Kevin Carhart

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