[crx] document element cloning issue

27 views
Skip to first unread message

Gildas

unread,
May 7, 2010, 2:49:09 PM5/7/10
to Chromium-extensions
Hi,

I have an issue with this code on chrome :
doc = document.documentElement.cloneNode(true);
document.replaceChild(doc, document.documentElement);

It should replace the document element by its clone and remain intact.
Most of the time, the page becomes blank or style sheets are not
interpreted. Does anyone know a workaround ?

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Gildas

unread,
May 7, 2010, 2:52:58 PM5/7/10
to Chromium-extensions
PS : I run this script after the page is loaded into the web developer
console

On 7 mai, 20:49, Gildas <gildas.lorm...@gmail.com> wrote:
> Hi,
>
> I have an issue with this code on chrome :
> doc = document.documentElement.cloneNode(true);
> document.replaceChild(doc, document.documentElement);
>
> It should replace the document element by its clone and remain intact.
> Most of the time, the page becomes blank or style sheets are not
> interpreted. Does anyone know a workaround ?
>
> --
> You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> To post to this group, send email to chromium-extensi...@chromium.org.
> To unsubscribe from this group, send email to chromium-extensions+unsubscr...@chromium.org.

PhistucK

unread,
May 7, 2010, 3:50:15 PM5/7/10
to Gildas, Chromium-extensions
Works for me (5.0.396.0 Dev) on Windows XP SP 3.
Tried it on this page, through the Developer Tools console (Ctrl+Shift+J).
With this script -
doc = document.documentElement.cloneNode(true); document.replaceChild(doc, document.documentElement);

☆PhistucK

Gildas

unread,
May 7, 2010, 5:01:40 PM5/7/10
to Chromium-extensions
It does not work for me on this page with chrome 4.1.249.1064 (45376)
and chromium 6.0.399.0 (46685) with all extensions disabled on Win 7
(64 bits).

On 7 mai, 21:50, PhistucK <phist...@gmail.com> wrote:
> Works for me (5.0.396.0 Dev) on Windows XP SP 3.
> Tried it on this page, through the Developer Tools console (Ctrl+Shift+J).
> With this script -
> doc = document.documentElement.cloneNode(true); document.replaceChild(doc,
> document.documentElement);
>
> ☆PhistucK

PhistucK

unread,
May 7, 2010, 5:16:33 PM5/7/10
to Gildas, Chromium-extensions
Try it with the new beta maybe?

☆PhistucK

Gildas

unread,
May 7, 2010, 6:32:47 PM5/7/10
to Chromium-extensions
Same issue with chrome 5.0.375.29 beta without any installed
extension, the page becomes blank. The only thing I can see are 3
first style elements in the head element. There's no body element in
the DOM.

On 7 mai, 23:16, PhistucK <phist...@gmail.com> wrote:
> Try it with the new beta maybe?
>
> ☆PhistucK
>

PhistucK

unread,
May 8, 2010, 2:41:32 AM5/8/10
to Gildas, Chromium-extensions
Try with the latest Dev version then?
:)

☆PhistucK

Gildas

unread,
May 8, 2010, 5:55:28 AM5/8/10
to Chromium-extensions
Exactly the same issue with chrome 5.0.396.0 dev.

On 8 mai, 08:41, PhistucK <phist...@gmail.com> wrote:
> Try with the latest Dev version then?
> :)
>
> ☆PhistucK
>

PhistucK

unread,
May 8, 2010, 6:31:39 AM5/8/10
to Gildas, Chromium-extensions
So, with the URL I specified, with the code I quoted - it does not work on Windows 7 with the same Chrome version I have?
If so, that is really, really weird.

☆PhistucK

Gildas

unread,
May 8, 2010, 7:25:07 AM5/8/10
to Chromium-extensions
Yes. To summarize : when I try to run this code into the web developer
console (after the page is fully loaded) :

doc = document.documentElement.cloneNode(true);
document.replaceChild(doc, document.documentElement);

On :
- chrome 4.1.249.1064
- chrome 5.0.375.29 (beta)
- chrome 5.0.396.0 (dev)
- chromium 6.0.399.0
running on Win 7 64 bits (without any extension enabled)

With this URL :
http://bit.ly/bNTlvz

All I get is a blank page with only 3 "script" elements in the "head"
of and no "body" element in the document.

On 8 mai, 12:31, PhistucK <phist...@gmail.com> wrote:
> So, with the URL I specified, with the code I quoted - it does not work on
> Windows 7 with the same Chrome version I have?
> If so, that is really, really weird.
>
> ☆PhistucK
>

Gildas

unread,
May 8, 2010, 7:27:31 AM5/8/10
to Chromium-extensions
>
> All I get is a blank page with only 3 "script" elements in the "head"

Sorry for the mistake : 3 "style" elements, not 3 "script" elements.

PhistucK

unread,
May 8, 2010, 10:26:31 AM5/8/10
to Gildas, Chromium-extensions
Oh, sorry, I did not specify the URL before. I meant https://developer.mozilla.org/en/cloneNode.
You are right, it does not work with the URL on which you tried it.

☆PhistucK

Gildas

unread,
May 9, 2010, 8:07:54 AM5/9/10
to Chromium-extensions
At least, this issue has been much tested ;)

On May 8, 4:26 pm, PhistucK <phist...@gmail.com> wrote:
> Oh, sorry, I did not specify the URL before. I meanthttps://developer.mozilla.org/en/cloneNode.
> You are right, it does not work with the URL on which you tried it.
>
> ☆PhistucK

Message has been deleted

PhistucK

unread,
May 12, 2010, 12:21:15 AM5/12/10
to Gildas, Chromium-extensions
Can you check the original code with Safari?
Also, with FireFox (and Internet Explorer, if it supports it)?

If it happens also on Safari, can you file a bug on bugs.webkit.org (after searching for an existing one)?
If it does not happen on Safari, can you file a bug on new.crbug.com (after searching for an existing one at crbug.com)?

Thank you.


☆PhistucK


On Tue, May 11, 2010 at 23:23, Gildas <gildas....@gmail.com> wrote:
Maybe it may interest someone, the work-around for this buggy code on
chrome :


doc = document.documentElement.cloneNode(true);
document.replaceChild(doc, document.documentElement);

is :

doc = document.documentElement.cloneNode(true);
document.outerHTML = doc.outerHTML;


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Gildas

unread,
May 12, 2010, 7:47:11 AM5/12/10
to Chromium-extensions
Hi PhistucK,

The same bug happens on Safari 4.0.5, the only difference is that I
see is a "script" element after the 3 "style" elements in the "head"
element. It does not happen with firefox 3.6.3, opera 10.53 and ie8.
So, it seems to be a webkit bug.

I've filled the bug description here : https://bugs.webkit.org/show_bug.cgi?id=38984

Thank you for your help,

Gildas.

On 12 mai, 06:21, PhistucK <phist...@gmail.com> wrote:
> Can you check the original code with Safari?
> Also, with FireFox (and Internet Explorer, if it supports it)?
>
> If it happens also on Safari, can you file a bug on bugs.webkit.org (after
> searching for an existing one)?
> If it does not happen on Safari, can you file a bug on new.crbug.com (after
> searching for an existing one at crbug.com)?
>
> Thank you.
>
> ☆PhistucK
>
>

Reply all
Reply to author
Forward
0 new messages