Created attachment 141736 [details]
See attached testcase. It should say "PASS".
The relevant spec is at http://www.whatwg.org/specs/web-apps/current-work/#already-started and says:
The cloning steps for script elements must set the "already started" flag on the copy if it is
set on the element being cloned.
This should be easy to fix.
One other note: ideally the SVG behavior would be fixed along with the HTML one, though of course the HTML spec can't require behavior for SVG scripts...
Created attachment 141824 [details]
I missed the SVG comment, i'll see if i can make a testcase and fix if needed.
There's already http://trac.webkit.org/browser/trunk/LayoutTests/svg/dom/SVGScriptElement/script-clone-rerun.svg?format=txt which tests that "already started" is copied over when the element is cloned, but the bug here wasn't in the cloning code itself, it was just observable through it.
I'm not very proficient in svg, so if anyone thinks the actual bug here could also be an issue in svg i'd appreciate a testcase or a pointer on how to make one.
There's a testcase at https://bugzilla.mozilla.org/attachment.cgi?id=621309 that shows an <svg:script> running after being imported from a DOMParser-generated document.
I assume the attached patch fixes that situation for <html:script>, right?
(In reply to comment #6)
> There's a testcase at https://bugzilla.mozilla.org/attachment.cgi?id=621309 that shows an <svg:script> running after being imported from a DOMParser-generated document.
> I assume the attached patch fixes that situation for <html:script>, right?
WebKit doesn't support text/html in DOMParser yet, afaik. But that testcase does indeed fail for svg and xhtml.
Implementation-wise, the xml case is a bit trickier to fix since DOMParser uses Document::createElement, which uses the automatically generated element constructors. Also, is there even enough info at that point to decide whether 'already started' should be set or not?
Adam, any ideas?
Btw, should there also be a note for the xml case here:
If I read the specs right, the "already started" flag is set whenever the element is inserted into a document... That should include DOMParser and XMLHttpRequest automatically.
By the way, WebKit seems to fail the similar XMLHttpRequest testcase:
document.body.textContent = 'FAIL';
var xhr = new XMLHttpRequest();
xhr.open("GET", "test.xml", false);
Also see http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-February/030351.html and the bug 12234.
Comment on attachment 141824 [details]
Clearing flags on attachment: 141824
Committed r117611: <http://trac.webkit.org/changeset/117611>
All reviewed patches have been landed. Closing bug.