Commit 339ebdb1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use bind_to_tree callback to parse dynamically added scripts.

parent acef7258
......@@ -398,6 +398,25 @@ static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, p);
}
static HRESULT HTMLScriptElement_bind_to_tree(HTMLDOMNode *iface)
{
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
TRACE("(%p)\n", This);
if(!This->parse_on_bind)
return S_OK;
if(!This->element.node.doc || !This->element.node.doc->window) {
ERR("No window\n");
return E_UNEXPECTED;
}
This->parse_on_bind = FALSE;
doc_insert_script(This->element.node.doc->window, This);
return S_OK;
}
static void HTMLScriptElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
{
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
......@@ -433,7 +452,7 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
HTMLScriptElement_get_readystate,
NULL,
NULL,
NULL,
HTMLScriptElement_bind_to_tree,
HTMLScriptElement_traverse,
HTMLScriptElement_unlink
};
......
......@@ -767,20 +767,10 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
if(NS_SUCCEEDED(nsres)) {
HTMLScriptElement *script_elem;
HRESULT hres;
TRACE("script element\n");
hres = script_elem_from_nsscript(This, nsscript, &script_elem);
add_script_runner(This, run_bind_to_tree, (nsISupports*)nsscript, NULL);
nsIDOMHTMLScriptElement_Release(nsscript);
if(FAILED(hres))
return;
if(script_elem->parse_on_bind)
add_script_runner(This, run_insert_script, (nsISupports*)nsscript, NULL);
IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface);
return;
}
......
......@@ -104,17 +104,20 @@ function testPutText2() {
elem.text = "exec_cnt++;"; /* forces evaluation, but src will be executed */
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
ok(extern_cnt === 6, "< extern_cnt = " + extern_cnt + " expected 6");
elem.text = "exec_cnt++;"; /* forces evaluation, but src will be executed */
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
ok(extern_cnt === 7, "< extern_cnt = " + extern_cnt + " expected 6");
elem = document.createElement("script");
exec_cnt = 0;
elem.text = "exec_cnt++;";
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
elem.src = "externscr.js";
ok(extern_cnt === 6, "extern_cnt = " + extern_cnt + " expected 6");
ok(extern_cnt === 7, "extern_cnt = " + extern_cnt + " expected 7");
document.body.appendChild(elem);
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
ok(extern_cnt === 7, "extern_cnt = " + extern_cnt + " expected 7");
ok(extern_cnt === 8, "extern_cnt = " + extern_cnt + " expected 8");
}
document.body.onload = function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment