mshtml: Use bind_to_tree callback to parse dynamically added scripts.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
acef7258ab
commit
339ebdb11d
|
@ -398,6 +398,25 @@ static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
|
||||||
return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, 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)
|
static void HTMLScriptElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
|
||||||
{
|
{
|
||||||
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
||||||
|
@ -433,7 +452,7 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
|
||||||
HTMLScriptElement_get_readystate,
|
HTMLScriptElement_get_readystate,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
HTMLScriptElement_bind_to_tree,
|
||||||
HTMLScriptElement_traverse,
|
HTMLScriptElement_traverse,
|
||||||
HTMLScriptElement_unlink
|
HTMLScriptElement_unlink
|
||||||
};
|
};
|
||||||
|
|
|
@ -767,20 +767,10 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
|
||||||
|
|
||||||
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
if(NS_SUCCEEDED(nsres)) {
|
||||||
HTMLScriptElement *script_elem;
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
TRACE("script element\n");
|
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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,17 +104,20 @@ function testPutText2() {
|
||||||
elem.text = "exec_cnt++;"; /* forces evaluation, but src will be executed */
|
elem.text = "exec_cnt++;"; /* forces evaluation, but src will be executed */
|
||||||
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
|
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
|
||||||
ok(extern_cnt === 6, "< extern_cnt = " + extern_cnt + " expected 6");
|
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");
|
elem = document.createElement("script");
|
||||||
exec_cnt = 0;
|
exec_cnt = 0;
|
||||||
elem.text = "exec_cnt++;";
|
elem.text = "exec_cnt++;";
|
||||||
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
|
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
|
||||||
elem.src = "externscr.js";
|
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);
|
document.body.appendChild(elem);
|
||||||
ok(exec_cnt === 0, "script exec_cnt " + exec_cnt);
|
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() {
|
document.body.onload = function() {
|
||||||
|
|
Loading…
Reference in New Issue