Commit a9a3c65c authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Set SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION properly.

parent 34209915
...@@ -201,9 +201,33 @@ static BOOL init_script_engine(ScriptHost *script_host, IActiveScript *script) ...@@ -201,9 +201,33 @@ static BOOL init_script_engine(ScriptHost *script_host, IActiveScript *script)
hres = IActiveScript_AddNamedItem(script, L"window", hres = IActiveScript_AddNamedItem(script, L"window",
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS); SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
ScriptHost *first_host;
V_VT(&var) = VT_BOOL; V_VT(&var) = VT_BOOL;
V_BOOL(&var) = VARIANT_TRUE; V_BOOL(&var) = VARIANT_TRUE;
LIST_FOR_EACH_ENTRY(first_host, &script_host->window->script_hosts, ScriptHost, entry) {
if(first_host->script) {
V_BOOL(&var) = VARIANT_FALSE;
break;
}
}
set_script_prop(script, SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION, &var); set_script_prop(script, SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION, &var);
/* if this was second engine initialized, also set it to first engine, since it used to be TRUE */
if(!V_BOOL(&var)) {
struct list *iter = &first_host->entry;
BOOL is_second_init = TRUE;
while((iter = list_next(&script_host->window->script_hosts, iter))) {
if(LIST_ENTRY(iter, ScriptHost, entry)->script) {
is_second_init = FALSE;
break;
}
}
if(is_second_init)
set_script_prop(first_host->script, SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION, &var);
}
}else { }else {
WARN("AddNamedItem failed: %08lx\n", hres); WARN("AddNamedItem failed: %08lx\n", hres);
} }
......
...@@ -103,21 +103,32 @@ const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY = ...@@ -103,21 +103,32 @@ const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
DEFINE_EXPECT(CreateInstance); DEFINE_EXPECT(CreateInstance);
DEFINE_EXPECT(CreateInstance2);
DEFINE_EXPECT(GetInterfaceSafetyOptions); DEFINE_EXPECT(GetInterfaceSafetyOptions);
DEFINE_EXPECT(SetInterfaceSafetyOptions); DEFINE_EXPECT(SetInterfaceSafetyOptions);
DEFINE_EXPECT(GetInterfaceSafetyOptions2);
DEFINE_EXPECT(SetInterfaceSafetyOptions2);
DEFINE_EXPECT(InitNew); DEFINE_EXPECT(InitNew);
DEFINE_EXPECT(InitNew2);
DEFINE_EXPECT(Close); DEFINE_EXPECT(Close);
DEFINE_EXPECT(Close2);
DEFINE_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK); DEFINE_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK);
DEFINE_EXPECT(SetProperty_INVOKEVERSIONING); DEFINE_EXPECT(SetProperty_INVOKEVERSIONING);
DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE); DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_TRUE); DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_TRUE);
DEFINE_EXPECT(SetProperty2_HACK_TRIDENTEVENTSINK);
DEFINE_EXPECT(SetProperty2_INVOKEVERSIONING);
DEFINE_EXPECT(SetProperty2_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
DEFINE_EXPECT(SetScriptSite); DEFINE_EXPECT(SetScriptSite);
DEFINE_EXPECT(SetScriptSite2);
DEFINE_EXPECT(GetScriptState); DEFINE_EXPECT(GetScriptState);
DEFINE_EXPECT(SetScriptState_STARTED); DEFINE_EXPECT(SetScriptState_STARTED);
DEFINE_EXPECT(SetScriptState_CONNECTED); DEFINE_EXPECT(SetScriptState_CONNECTED);
DEFINE_EXPECT(SetScriptState_DISCONNECTED); DEFINE_EXPECT(SetScriptState_DISCONNECTED);
DEFINE_EXPECT(AddNamedItem); DEFINE_EXPECT(AddNamedItem);
DEFINE_EXPECT(AddNamedItem2);
DEFINE_EXPECT(ParseScriptText_script); DEFINE_EXPECT(ParseScriptText_script);
DEFINE_EXPECT(ParseScriptText_script2);
DEFINE_EXPECT(ParseScriptText_execScript); DEFINE_EXPECT(ParseScriptText_execScript);
DEFINE_EXPECT(GetScriptDispatch); DEFINE_EXPECT(GetScriptDispatch);
DEFINE_EXPECT(funcDisp); DEFINE_EXPECT(funcDisp);
...@@ -140,7 +151,6 @@ DEFINE_EXPECT(ChangeType_bstr); ...@@ -140,7 +151,6 @@ DEFINE_EXPECT(ChangeType_bstr);
DEFINE_EXPECT(ChangeType_dispatch); DEFINE_EXPECT(ChangeType_dispatch);
DEFINE_EXPECT(GetTypeInfo); DEFINE_EXPECT(GetTypeInfo);
#define TESTSCRIPT_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80746}"
#define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}" #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
#define DISPID_SCRIPT_TESTPROP 0x100000 #define DISPID_SCRIPT_TESTPROP 0x100000
...@@ -161,8 +171,10 @@ DEFINE_EXPECT(GetTypeInfo); ...@@ -161,8 +171,10 @@ DEFINE_EXPECT(GetTypeInfo);
#define DISPID_EXTERNAL_TESTHOSTCTX 0x30000C #define DISPID_EXTERNAL_TESTHOSTCTX 0x30000C
#define DISPID_EXTERNAL_GETMIMETYPE 0x30000D #define DISPID_EXTERNAL_GETMIMETYPE 0x30000D
static const GUID CLSID_TestScript = static const GUID CLSID_TestScript[] = {
{0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}}; {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}},
{0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x08,0x46}},
};
static const GUID CLSID_TestActiveX = static const GUID CLSID_TestActiveX =
{0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}}; {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
...@@ -178,25 +190,25 @@ static HRESULT ax_getopt_hres = S_OK, ax_setopt_dispex_hres = S_OK; ...@@ -178,25 +190,25 @@ static HRESULT ax_getopt_hres = S_OK, ax_setopt_dispex_hres = S_OK;
static HRESULT ax_setopt_disp_caller_hres = S_OK, ax_setopt_disp_data_hres = S_OK; static HRESULT ax_setopt_disp_caller_hres = S_OK, ax_setopt_disp_data_hres = S_OK;
static BOOL skip_loadobject_tests; static BOOL skip_loadobject_tests;
static IActiveScriptSite *site; static IActiveScriptSite *site, *site2;
static SCRIPTSTATE state; static SCRIPTSTATE state, state2;
static BOOL init_key(const char *key_name, const char *def_value, BOOL init) static BOOL init_key(const WCHAR *key_name, const WCHAR *def_value, BOOL init)
{ {
HKEY hkey; HKEY hkey;
DWORD res; DWORD res;
if(!init) { if(!init) {
RegDeleteKeyA(HKEY_CLASSES_ROOT, key_name); RegDeleteKeyW(HKEY_CLASSES_ROOT, key_name);
return TRUE; return TRUE;
} }
res = RegCreateKeyA(HKEY_CLASSES_ROOT, key_name, &hkey); res = RegCreateKeyW(HKEY_CLASSES_ROOT, key_name, &hkey);
if(res != ERROR_SUCCESS) if(res != ERROR_SUCCESS)
return FALSE; return FALSE;
if(def_value) if(def_value)
res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value)); res = RegSetValueW(hkey, NULL, REG_SZ, def_value, wcslen(def_value));
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -1927,9 +1939,9 @@ static IObjectSafety AXObjectSafety = { &AXObjectSafetyVtbl }; ...@@ -1927,9 +1939,9 @@ static IObjectSafety AXObjectSafety = { &AXObjectSafetyVtbl };
static BOOL set_safe_reg(BOOL safe_call, BOOL safe_data) static BOOL set_safe_reg(BOOL safe_call, BOOL safe_data)
{ {
return init_key("CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}", return init_key(L"CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
NULL, safe_call) NULL, safe_call)
&& init_key("CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}", && init_key(L"CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}",
NULL, safe_data); NULL, safe_data);
} }
...@@ -3336,6 +3348,252 @@ static const IActiveScriptVtbl ActiveScriptVtbl = { ...@@ -3336,6 +3348,252 @@ static const IActiveScriptVtbl ActiveScriptVtbl = {
static IActiveScript ActiveScript = { &ActiveScriptVtbl }; static IActiveScript ActiveScript = { &ActiveScriptVtbl };
static HRESULT WINAPI ObjectSafety2_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
{
CHECK_EXPECT(GetInterfaceSafetyOptions2);
ok(IsEqualGUID(&IID_IActiveScriptParse, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
ok(pdwSupportedOptions != NULL, "pdwSupportedOptions == NULL\n");
ok(pdwEnabledOptions != NULL, "pdwEnabledOptions == NULL\n");
*pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_DISPEX | INTERFACE_USES_SECURITY_MANAGER;
*pdwEnabledOptions = INTERFACE_USES_DISPEX;
return S_OK;
}
static HRESULT WINAPI ObjectSafety2_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
DWORD dwOptionSetMask, DWORD dwEnabledOptions)
{
CHECK_EXPECT(SetInterfaceSafetyOptions2);
ok(IsEqualGUID(&IID_IActiveScriptParse, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
ok(dwOptionSetMask == (INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_DISPEX | INTERFACE_USES_SECURITY_MANAGER),
"dwOptionSetMask = %08lx\n", dwOptionSetMask);
ok(dwEnabledOptions == (INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_DISPEX | INTERFACE_USES_SECURITY_MANAGER),
"dwEnabledOptions = %08lx\n", dwOptionSetMask);
return S_OK;
}
static const IObjectSafetyVtbl ObjectSafety2Vtbl = {
ObjectSafety_QueryInterface,
ObjectSafety_AddRef,
ObjectSafety_Release,
ObjectSafety2_GetInterfaceSafetyOptions,
ObjectSafety2_SetInterfaceSafetyOptions
};
static IObjectSafety ObjectSafety2 = { &ObjectSafety2Vtbl };
static HRESULT WINAPI ActiveScriptProperty2_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
VARIANT *pvarIndex, VARIANT *pvarValue)
{
switch(dwProperty) {
case SCRIPTPROP_HACK_TRIDENTEVENTSINK:
CHECK_EXPECT(SetProperty2_HACK_TRIDENTEVENTSINK);
ok(V_VT(pvarValue) == VT_BOOL, "V_VT(pvarValue) = %d\n", V_VT(pvarValue));
ok(V_BOOL(pvarValue) == VARIANT_TRUE, "V_BOOL(pvarValue) = %x\n", V_BOOL(pvarValue));
break;
case SCRIPTPROP_INVOKEVERSIONING:
CHECK_EXPECT(SetProperty2_INVOKEVERSIONING);
ok(V_VT(pvarValue) == VT_I4, "V_VT(pvarValue) = %d\n", V_VT(pvarValue));
ok(V_I4(pvarValue) == 1, "V_I4(pvarValue) = %ld\n", V_I4(pvarValue));
break;
case SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION:
CHECK_EXPECT(SetProperty2_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
ok(V_VT(pvarValue) == VT_BOOL, "V_VT(pvarValue) = %d\n", V_VT(pvarValue));
ok(!V_BOOL(pvarValue), "ABBREVIATE_GLOBALNAME_RESOLUTION is TRUE\n");
break;
case 0x70000003: /* Undocumented property set by IE10 */
return E_NOTIMPL;
default:
ok(0, "unexpected property %08lx\n", dwProperty);
return E_NOTIMPL;
}
ok(!pvarIndex, "pvarIndex != NULL\n");
ok(pvarValue != NULL, "pvarValue == NULL\n");
return S_OK;
}
static const IActiveScriptPropertyVtbl ActiveScriptProperty2Vtbl = {
ActiveScriptProperty_QueryInterface,
ActiveScriptProperty_AddRef,
ActiveScriptProperty_Release,
ActiveScriptProperty_GetProperty,
ActiveScriptProperty2_SetProperty
};
static IActiveScriptProperty ActiveScriptProperty2 = { &ActiveScriptProperty2Vtbl };
static HRESULT WINAPI ActiveScriptParse2_InitNew(IActiveScriptParse *iface)
{
CHECK_EXPECT(InitNew2);
return S_OK;
}
static HRESULT WINAPI ActiveScriptParse2_ParseScriptText(IActiveScriptParse *iface, LPCOLESTR pstrCode,
LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie,
ULONG ulStartingLine, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
ok(pvarResult != NULL, "pvarResult == NULL\n");
ok(pexcepinfo != NULL, "pexcepinfo == NULL\n");
if(!lstrcmpW(pstrCode, L"second script")) {
CHECK_EXPECT(ParseScriptText_script2);
ok(!lstrcmpW(pstrItemName, L"window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName));
ok(!lstrcmpW(pstrDelimiter, L"</SCRIPT>"), "pstrDelimiter = %s\n", wine_dbgstr_w(pstrDelimiter));
ok(dwFlags == (SCRIPTTEXT_ISVISIBLE | SCRIPTTEXT_HOSTMANAGESSOURCE), "dwFlags = %08lx\n", dwFlags);
return S_OK;
}
ok(0, "unexpected script %s\n", wine_dbgstr_w(pstrCode));
return E_FAIL;
}
static const IActiveScriptParseVtbl ActiveScriptParse2Vtbl = {
ActiveScriptParse_QueryInterface,
ActiveScriptParse_AddRef,
ActiveScriptParse_Release,
ActiveScriptParse2_InitNew,
ActiveScriptParse_AddScriptlet,
ActiveScriptParse2_ParseScriptText
};
static IActiveScriptParse ActiveScriptParse2 = { &ActiveScriptParse2Vtbl };
static HRESULT WINAPI ActiveScript2_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IActiveScript, riid)) {
*ppv = iface;
return S_OK;
}
if(IsEqualGUID(&IID_IActiveScriptParse, riid)) {
*ppv = &ActiveScriptParse2;
return S_OK;
}
if(IsEqualGUID(&IID_IActiveScriptParseProcedure2, riid)) {
*ppv = &ActiveScriptParseProcedure;
return S_OK;
}
if(IsEqualGUID(&IID_IActiveScriptProperty, riid)) {
*ppv = &ActiveScriptProperty2;
return S_OK;
}
if(IsEqualGUID(&IID_IObjectSafety, riid)) {
*ppv = &ObjectSafety2;
return S_OK;
}
if(IsEqualGUID(&IID_IActiveScriptDebug, riid))
return E_NOINTERFACE;
trace("QI(%s)\n", wine_dbgstr_guid(riid));
return E_NOINTERFACE;
}
static HRESULT WINAPI ActiveScript2_SetScriptSite(IActiveScript *iface, IActiveScriptSite *pass)
{
HRESULT hres;
CHECK_EXPECT(SetScriptSite2);
ok(pass != NULL, "pass == NULL\n");
ok(pass != site, "pass == site\n");
hres = IActiveScriptSite_OnStateChange(pass, (state2 = SCRIPTSTATE_INITIALIZED));
ok(hres == S_OK, "OnStateChange failed: %08lx\n", hres);
site2 = pass;
IActiveScriptSite_AddRef(site2);
return S_OK;
}
static HRESULT WINAPI ActiveScript2_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
{
HRESULT hres = IActiveScriptSite_OnStateChange(site2, (state2 = ss));
ok(hres == S_OK, "OnStateChange failed: %08lx\n", hres);
return S_OK;
}
static HRESULT WINAPI ActiveScript2_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
{
*pssState = state2;
return S_OK;
}
static HRESULT WINAPI ActiveScript2_Close(IActiveScript *iface)
{
CHECK_EXPECT(Close2);
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScript2_AddNamedItem(IActiveScript *iface, LPCOLESTR pstrName, DWORD dwFlags)
{
IHTMLWindow2 *window, *window2;
IUnknown *unk = NULL;
HRESULT hres;
CHECK_EXPECT(AddNamedItem2);
ok(!wcscmp(pstrName, L"window"), "pstrName = %s\n", wine_dbgstr_w(pstrName));
ok(dwFlags == (SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE | SCRIPTITEM_GLOBALMEMBERS), "dwFlags = %lx\n", dwFlags);
hres = IActiveScriptSite_GetItemInfo(site2, L"window", SCRIPTINFO_IUNKNOWN, &unk, NULL);
ok(hres == S_OK, "GetItemInfo failed: %08lx\n", hres);
ok(unk != NULL, "unk == NULL\n");
/* Native is pretty broken here, it gives a different IUnknown than first site's SCRIPTINFO_IUNKNOWN,
* and querying for IDispatchEx gives different interfaces on both these *and* our window_dispex!
* That said, querying for IHTMLWindow2 *does* give the same interface for both?!?
*/
hres = IDispatchEx_QueryInterface(window_dispex, &IID_IHTMLWindow2, (void**)&window);
ok(hres == S_OK, "Could not get IHTMLWindow2 interface: %08lx\n", hres);
hres = IUnknown_QueryInterface(unk, &IID_IHTMLWindow2, (void**)&window2);
ok(hres == S_OK, "Could not get IHTMLWindow2 interface: %08lx\n", hres);
ok(window == window2, "first site window != second site window\n");
IHTMLWindow2_Release(window2);
IHTMLWindow2_Release(window);
IUnknown_Release(unk);
return S_OK;
}
static HRESULT WINAPI ActiveScript2_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName, IDispatch **ppdisp)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static const IActiveScriptVtbl ActiveScript2Vtbl = {
ActiveScript2_QueryInterface,
ActiveScript_AddRef,
ActiveScript_Release,
ActiveScript2_SetScriptSite,
ActiveScript_GetScriptSite,
ActiveScript2_SetScriptState,
ActiveScript2_GetScriptState,
ActiveScript2_Close,
ActiveScript2_AddNamedItem,
ActiveScript_AddTypeLib,
ActiveScript2_GetScriptDispatch,
ActiveScript_GetCurrentScriptThreadID,
ActiveScript_GetScriptThreadID,
ActiveScript_GetScriptThreadState,
ActiveScript_InterruptScriptThread,
ActiveScript_Clone
};
static IActiveScript ActiveScript2 = { &ActiveScript2Vtbl };
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{ {
*ppv = NULL; *ppv = NULL;
...@@ -3388,7 +3646,25 @@ static const IClassFactoryVtbl ClassFactoryVtbl = { ...@@ -3388,7 +3646,25 @@ static const IClassFactoryVtbl ClassFactoryVtbl = {
ClassFactory_LockServer ClassFactory_LockServer
}; };
static IClassFactory script_cf = { &ClassFactoryVtbl }; static HRESULT WINAPI ClassFactory2_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
CHECK_EXPECT(CreateInstance2);
ok(!outer, "outer = %p\n", outer);
ok(IsEqualGUID(&IID_IActiveScript, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
*ppv = &ActiveScript2;
return S_OK;
}
static const IClassFactoryVtbl ClassFactory2Vtbl = {
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
ClassFactory2_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory script_cf[] = { { &ClassFactoryVtbl }, { &ClassFactory2Vtbl } };
typedef struct { typedef struct {
IInternetProtocolEx IInternetProtocolEx_iface; IInternetProtocolEx IInternetProtocolEx_iface;
...@@ -3901,9 +4177,50 @@ static IClassFactory protocol_cf = { &ProtocolCFVtbl }; ...@@ -3901,9 +4177,50 @@ static IClassFactory protocol_cf = { &ProtocolCFVtbl };
static const char simple_script_str[] = static const char simple_script_str[] =
"<html><head></head><body>" "<html><head></head><body>"
"<div id=\"divid\"></div>" "<div id=\"divid\"></div>"
"<script language=\"TestScript\">simple script</script>" "<script language=\"TestScript1\">simple script</script>"
"</body></html>"; "</body></html>";
static void test_insert_script_elem(IHTMLDocument2 *doc, const WCHAR *code, const WCHAR *lang)
{
IHTMLDOMNode *node, *body_node, *inserted_node;
IHTMLScriptElement *script;
IHTMLElement *elem, *body;
HRESULT hres;
BSTR bstr;
bstr = SysAllocString(L"script");
hres = IHTMLDocument2_createElement(doc, bstr, &elem);
ok(hres == S_OK, "createElement failed: %08lx\n", hres);
SysFreeString(bstr);
bstr = SysAllocString(lang);
hres = IHTMLElement_put_language(elem, bstr);
ok(hres == S_OK, "put_language failed: %08lx\n", hres);
SysFreeString(bstr);
bstr = SysAllocString(code);
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
ok(hres == S_OK, "Could not get IHTMLScriptElement iface: %08lx\n", hres);
hres = IHTMLScriptElement_put_text(script, bstr);
ok(hres == S_OK, "put_text failed: %08lx\n", hres);
IHTMLScriptElement_Release(script);
SysFreeString(bstr);
hres = IHTMLDocument2_get_body(doc, &body);
ok(hres == S_OK, "get_body failed: %08lx\n", hres);
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLDOMNode, (void**)&node);
ok(hres == S_OK, "Could not get IHTMLDOMNode iface: %08lx\n", hres);
hres = IHTMLElement_QueryInterface(body, &IID_IHTMLDOMNode, (void**)&body_node);
ok(hres == S_OK, "Could not get IHTMLDOMNode iface: %08lx\n", hres);
hres = IHTMLDOMNode_appendChild(body_node, node, &inserted_node);
ok(hres == S_OK, "appendChild failed: %08lx\n", hres);
IHTMLDOMNode_Release(inserted_node);
IHTMLDOMNode_Release(body_node);
IHTMLDOMNode_Release(node);
IHTMLElement_Release(body);
IHTMLElement_Release(elem);
}
static void test_exec_script(IHTMLDocument2 *doc, const WCHAR *codew, const WCHAR *langw) static void test_exec_script(IHTMLDocument2 *doc, const WCHAR *codew, const WCHAR *langw)
{ {
IHTMLWindow2 *window; IHTMLWindow2 *window;
...@@ -3974,20 +4291,50 @@ static void test_simple_script(void) ...@@ -3974,20 +4291,50 @@ static void test_simple_script(void)
CHECK_CALLED(ParseScriptText_script); CHECK_CALLED(ParseScriptText_script);
CHECK_CALLED(SetScriptState_CONNECTED); CHECK_CALLED(SetScriptState_CONNECTED);
test_exec_script(doc, L"execScript call", L"TestScript"); SET_EXPECT(CreateInstance2);
SET_EXPECT(GetInterfaceSafetyOptions2);
SET_EXPECT(SetInterfaceSafetyOptions2);
SET_EXPECT(SetProperty2_INVOKEVERSIONING);
SET_EXPECT(SetProperty2_HACK_TRIDENTEVENTSINK);
SET_EXPECT(InitNew2);
SET_EXPECT(SetScriptSite2);
SET_EXPECT(AddNamedItem2);
SET_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
SET_EXPECT(SetProperty2_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
SET_EXPECT(ParseScriptText_script2);
test_insert_script_elem(doc, L"second script", L"TestScript2");
CHECK_CALLED(CreateInstance2);
CHECK_CALLED(GetInterfaceSafetyOptions2);
CHECK_CALLED(SetInterfaceSafetyOptions2);
CHECK_CALLED(SetProperty2_INVOKEVERSIONING);
CHECK_CALLED(SetProperty2_HACK_TRIDENTEVENTSINK);
CHECK_CALLED(InitNew2);
CHECK_CALLED(SetScriptSite2);
CHECK_CALLED(AddNamedItem2);
CHECK_CALLED(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
CHECK_CALLED(SetProperty2_ABBREVIATE_GLOBALNAME_RESOLUTION_FALSE);
CHECK_CALLED(ParseScriptText_script2);
test_exec_script(doc, L"execScript call", L"TestScript1");
if(site) if(site)
IActiveScriptSite_Release(site); IActiveScriptSite_Release(site);
if(site2)
IActiveScriptSite_Release(site2);
if(window_dispex) if(window_dispex)
IDispatchEx_Release(window_dispex); IDispatchEx_Release(window_dispex);
SET_EXPECT(SetScriptState_DISCONNECTED); SET_EXPECT(SetScriptState_DISCONNECTED);
SET_EXPECT(Close); SET_EXPECT(Close);
SET_EXPECT(Close2);
IHTMLDocument2_Release(doc); IHTMLDocument2_Release(doc);
CHECK_CALLED(SetScriptState_DISCONNECTED); CHECK_CALLED(SetScriptState_DISCONNECTED);
CHECK_CALLED(Close); CHECK_CALLED(Close);
CHECK_CALLED(Close2);
} }
static void run_from_moniker(IMoniker *mon) static void run_from_moniker(IMoniker *mon)
...@@ -4193,16 +4540,33 @@ static void run_js_tests(void) ...@@ -4193,16 +4540,33 @@ static void run_js_tests(void)
static BOOL init_registry(BOOL init) static BOOL init_registry(BOOL init)
{ {
return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID, init) static const WCHAR fmt[] = L"CLSID\\%s\\Implemented Categories\\{%08lX-9847-11CF-8F20-00805F2CD064}";
&& init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}", WCHAR *clsid, buf[ARRAY_SIZE(fmt) + 40];
NULL, init) BOOL ret = TRUE;
&& init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}", HRESULT hres;
NULL, init); unsigned i;
for(i = 0; i < ARRAY_SIZE(CLSID_TestScript) && ret; i++) {
hres = StringFromCLSID(&CLSID_TestScript[i], &clsid);
ok(hres == S_OK, "StringFromCLSID failed: %08lx\n", hres);
swprintf(buf, ARRAY_SIZE(buf), L"TestScript%u\\CLSID", i + 1);
if((ret = init_key(buf, clsid, init))) {
swprintf(buf, ARRAY_SIZE(buf), fmt, clsid, 0xf0b7a1a1);
if((ret = init_key(buf, NULL, init))) {
swprintf(buf, ARRAY_SIZE(buf), fmt, clsid, 0xf0b7a1a2);
ret = init_key(buf, NULL, init);
}
}
CoTaskMemFree(clsid);
}
return ret;
} }
static BOOL register_script_engine(void) static BOOL register_script_engine(void)
{ {
DWORD regid; DWORD regid;
unsigned i;
HRESULT hres; HRESULT hres;
if(!init_registry(TRUE)) { if(!init_registry(TRUE)) {
...@@ -4210,9 +4574,11 @@ static BOOL register_script_engine(void) ...@@ -4210,9 +4574,11 @@ static BOOL register_script_engine(void)
return FALSE; return FALSE;
} }
hres = CoRegisterClassObject(&CLSID_TestScript, (IUnknown *)&script_cf, for(i = 0; i < ARRAY_SIZE(CLSID_TestScript); i++) {
CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid); hres = CoRegisterClassObject(&CLSID_TestScript[i], (IUnknown *)&script_cf[i],
ok(hres == S_OK, "Could not register script engine: %08lx\n", hres); CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
ok(hres == S_OK, "Could not register TestScript%u engine: %08lx\n", i + 1, hres);
}
return TRUE; return TRUE;
} }
...@@ -4299,7 +4665,7 @@ START_TEST(script) ...@@ -4299,7 +4665,7 @@ START_TEST(script)
test_simple_script(); test_simple_script();
init_registry(FALSE); init_registry(FALSE);
}else { }else {
skip("Could not register TestScript engine\n"); skip("Could not register TestScript engines\n");
} }
run_js_tests(); run_js_tests();
}else { }else {
......
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