2 * Copyright 2008-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
40 #include "mshtml_test.h"
42 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
45 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
46 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
50 #define CTXARG_T DWORDLONG
51 #define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
52 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
56 #define CTXARG_T DWORD
57 #define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
58 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
62 #define DEFINE_EXPECT(func) \
63 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
65 #define SET_EXPECT(func) \
66 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
68 #define CHECK_EXPECT2(func) \
70 ok(expect_ ##func, "unexpected call " #func "\n"); \
71 called_ ## func = TRUE; \
74 #define CHECK_EXPECT(func) \
76 CHECK_EXPECT2(func); \
77 expect_ ## func = FALSE; \
80 #define CHECK_CALLED(func) \
82 ok(called_ ## func, "expected " #func "\n"); \
83 expect_ ## func = called_ ## func = FALSE; \
86 #define CHECK_CALLED_BROKEN(func) \
88 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
89 expect_ ## func = called_ ## func = FALSE; \
92 #define CHECK_NOT_CALLED(func) \
94 ok(!called_ ## func, "unexpected " #func "\n"); \
95 expect_ ## func = called_ ## func = FALSE; \
98 #define CLEAR_CALLED(func) \
99 expect_ ## func = called_ ## func = FALSE
102 DEFINE_EXPECT(CreateInstance);
103 DEFINE_EXPECT(GetInterfaceSafetyOptions);
104 DEFINE_EXPECT(SetInterfaceSafetyOptions);
105 DEFINE_EXPECT(InitNew);
106 DEFINE_EXPECT(Close);
107 DEFINE_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK);
108 DEFINE_EXPECT(SetProperty_INVOKEVERSIONING);
109 DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION);
110 DEFINE_EXPECT(SetScriptSite);
111 DEFINE_EXPECT(GetScriptState);
112 DEFINE_EXPECT(SetScriptState_STARTED);
113 DEFINE_EXPECT(SetScriptState_CONNECTED);
114 DEFINE_EXPECT(SetScriptState_DISCONNECTED);
115 DEFINE_EXPECT(AddNamedItem);
116 DEFINE_EXPECT(ParseScriptText);
117 DEFINE_EXPECT(GetScriptDispatch);
118 DEFINE_EXPECT(funcDisp);
119 DEFINE_EXPECT(script_divid_d);
120 DEFINE_EXPECT(script_testprop_d);
121 DEFINE_EXPECT(script_testprop_i);
122 DEFINE_EXPECT(script_testprop2_d);
123 DEFINE_EXPECT(AXQueryInterface_IActiveScript);
124 DEFINE_EXPECT(AXQueryInterface_IObjectSafety);
125 DEFINE_EXPECT(AXGetInterfaceSafetyOptions);
126 DEFINE_EXPECT(AXSetInterfaceSafetyOptions);
127 DEFINE_EXPECT(external_success);
129 #define TESTSCRIPT_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80746}"
130 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
132 #define DISPID_SCRIPT_TESTPROP 0x100000
133 #define DISPID_SCRIPT_TESTPROP2 0x100001
135 #define DISPID_EXTERNAL_OK 0x300000
136 #define DISPID_EXTERNAL_TRACE 0x300001
137 #define DISPID_EXTERNAL_REPORTSUCCESS 0x300002
139 static const GUID CLSID_TestScript =
140 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}};
141 static const GUID CLSID_TestActiveX =
142 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
144 static IHTMLDocument2 *notif_doc;
145 static IOleDocumentView *view;
146 static IDispatchEx *window_dispex;
147 static BOOL doc_complete;
148 static IDispatch *script_disp;
149 static BOOL ax_objsafe;
150 static HWND container_hwnd;
152 static const char *debugstr_guid(REFIID riid)
156 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
157 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
158 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
159 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
164 static int strcmp_wa(LPCWSTR strw, const char *stra)
167 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
168 return lstrcmpA(stra, buf);
171 static BSTR a2bstr(const char *str)
176 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
177 ret = SysAllocStringLen(NULL, len);
178 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
183 static BOOL init_key(const char *key_name, const char *def_value, BOOL init)
189 RegDeleteKey(HKEY_CLASSES_ROOT, key_name);
193 res = RegCreateKeyA(HKEY_CLASSES_ROOT, key_name, &hkey);
194 if(res != ERROR_SUCCESS)
198 res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value));
202 return res == ERROR_SUCCESS;
205 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
206 REFIID riid, void**ppv)
208 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
213 return E_NOINTERFACE;
216 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
221 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
226 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
228 if(dispID == DISPID_READYSTATE){
232 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
234 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
235 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
237 if(!lstrcmpW(state, completeW))
240 SysFreeString(state);
246 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
248 ok(0, "unexpected call\n");
252 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
253 PropertyNotifySink_QueryInterface,
254 PropertyNotifySink_AddRef,
255 PropertyNotifySink_Release,
256 PropertyNotifySink_OnChanged,
257 PropertyNotifySink_OnRequestEdit
260 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
262 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
266 if(IsEqualGUID(riid, &IID_IUnknown)
267 || IsEqualGUID(riid, &IID_IDispatch)
268 || IsEqualGUID(riid, &IID_IDispatchEx))
271 return E_NOINTERFACE;
276 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
281 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
286 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
288 ok(0, "unexpected call\n");
292 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
293 LCID lcid, ITypeInfo **ppTInfo)
295 ok(0, "unexpected call\n");
299 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
300 LPOLESTR *rgszNames, UINT cNames,
301 LCID lcid, DISPID *rgDispId)
303 ok(0, "unexpected call\n");
307 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
308 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
309 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
311 ok(0, "unexpected call\n");
315 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
317 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
321 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
323 ok(0, "unexpected call\n");
327 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
329 ok(0, "unexpected call\n");
333 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
335 ok(0, "unexpected call\n");
339 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
341 ok(0, "unexpected call\n");
345 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
347 ok(0, "unexpected call\n");
351 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
353 ok(0, "unexpected call\n");
357 static HRESULT WINAPI funcDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
358 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
360 CHECK_EXPECT(funcDisp);
362 ok(id == DISPID_VALUE, "id = %d\n", id);
363 ok(lcid == 0, "lcid = %x\n", lcid);
364 ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
365 ok(pdp != NULL, "pdp == NULL\n");
366 ok(pdp->cArgs == 2, "pdp->cArgs = %d\n", pdp->cArgs);
367 ok(pdp->cNamedArgs == 1, "pdp->cNamedArgs = %d\n", pdp->cNamedArgs);
368 ok(pdp->rgdispidNamedArgs[0] == DISPID_THIS, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
369 ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg));
370 ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(rgvarg[1]) = %d\n", V_VT(pdp->rgvarg));
371 ok(V_BOOL(pdp->rgvarg+1) == VARIANT_TRUE, "V_BOOL(rgvarg[1]) = %x\n", V_BOOL(pdp->rgvarg));
372 ok(pvarRes != NULL, "pvarRes == NULL\n");
373 ok(pei != NULL, "pei == NULL\n");
374 ok(!pspCaller, "pspCaller != NULL\n");
376 V_VT(pvarRes) = VT_I4;
381 static IDispatchExVtbl testObjVtbl = {
382 DispatchEx_QueryInterface,
385 DispatchEx_GetTypeInfoCount,
386 DispatchEx_GetTypeInfo,
387 DispatchEx_GetIDsOfNames,
389 DispatchEx_GetDispID,
391 DispatchEx_DeleteMemberByName,
392 DispatchEx_DeleteMemberByDispID,
393 DispatchEx_GetMemberProperties,
394 DispatchEx_GetMemberName,
395 DispatchEx_GetNextDispID,
396 DispatchEx_GetNameSpaceParent
399 static IDispatchEx funcDisp = { &testObjVtbl };
401 static HRESULT WINAPI scriptDisp_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
403 if(!strcmp_wa(bstrName, "testProp")) {
404 CHECK_EXPECT(script_testprop_d);
405 ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
406 *pid = DISPID_SCRIPT_TESTPROP;
410 if(!strcmp_wa(bstrName, "testProp2")) {
411 CHECK_EXPECT(script_testprop2_d);
412 ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
413 *pid = DISPID_SCRIPT_TESTPROP2;
417 if(!strcmp_wa(bstrName, "divid")) {
418 CHECK_EXPECT(script_divid_d);
419 ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
423 ok(0, "unexpected call\n");
427 static HRESULT WINAPI scriptDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
428 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
431 case DISPID_SCRIPT_TESTPROP:
432 CHECK_EXPECT(script_testprop_i);
434 ok(lcid == 0, "lcid = %x\n", lcid);
435 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
436 ok(pdp != NULL, "pdp == NULL\n");
437 ok(pdp->cArgs == 0, "pdp->cArgs = %d\n", pdp->cArgs);
438 ok(pdp->cNamedArgs == 0, "pdp->cNamedArgs = %d\n", pdp->cNamedArgs);
439 ok(!pdp->rgdispidNamedArgs, "pdp->rgdispidNamedArgs != NULL\n");
440 ok(!pdp->rgvarg, "rgvarg != NULL\n");
441 ok(pvarRes != NULL, "pvarRes == NULL\n");
442 ok(pei != NULL, "pei == NULL\n");
443 ok(!pspCaller, "pspCaller != NULL\n");
445 V_VT(pvarRes) = VT_NULL;
448 ok(0, "unexpected call\n");
455 static IDispatchExVtbl scriptDispVtbl = {
456 DispatchEx_QueryInterface,
459 DispatchEx_GetTypeInfoCount,
460 DispatchEx_GetTypeInfo,
461 DispatchEx_GetIDsOfNames,
463 scriptDisp_GetDispID,
465 DispatchEx_DeleteMemberByName,
466 DispatchEx_DeleteMemberByDispID,
467 DispatchEx_GetMemberProperties,
468 DispatchEx_GetMemberName,
469 DispatchEx_GetNextDispID,
470 DispatchEx_GetNameSpaceParent
473 static IDispatchEx scriptDisp = { &scriptDispVtbl };
475 static HRESULT WINAPI externalDisp_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
477 if(!strcmp_wa(bstrName, "ok")) {
478 *pid = DISPID_EXTERNAL_OK;
481 if(!strcmp_wa(bstrName, "trace")) {
482 *pid = DISPID_EXTERNAL_TRACE;
485 if(!strcmp_wa(bstrName, "reportSuccess")) {
486 *pid = DISPID_EXTERNAL_REPORTSUCCESS;
490 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
491 return DISP_E_UNKNOWNNAME;
494 static HRESULT WINAPI externalDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
495 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
498 case DISPID_EXTERNAL_OK:
499 ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
500 ok(pdp != NULL, "pdp == NULL\n");
501 ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
502 ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
503 ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
504 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
505 ok(pei != NULL, "pei == NULL\n");
507 ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
508 ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp->rgvarg));
509 ok(V_BOOL(pdp->rgvarg+1), "%s\n", wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
513 case DISPID_EXTERNAL_TRACE:
514 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
515 ok(pdp != NULL, "pdp == NULL\n");
516 ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
517 ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
518 ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
519 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
520 ok(!pvarRes, "pvarRes != NULL\n");
521 ok(pei != NULL, "pei == NULL\n");
523 ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
524 if(V_VT(pdp->rgvarg) == VT_BSTR)
525 trace("%s\n", wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
529 case DISPID_EXTERNAL_REPORTSUCCESS:
530 CHECK_EXPECT(external_success);
532 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
533 ok(pdp != NULL, "pdp == NULL\n");
534 ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
535 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
536 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
537 ok(!pvarRes, "pvarRes != NULL\n");
538 ok(pei != NULL, "pei == NULL\n");
543 ok(0, "unexpected call\n");
550 static IDispatchExVtbl externalDispVtbl = {
551 DispatchEx_QueryInterface,
554 DispatchEx_GetTypeInfoCount,
555 DispatchEx_GetTypeInfo,
556 DispatchEx_GetIDsOfNames,
558 externalDisp_GetDispID,
559 externalDisp_InvokeEx,
560 DispatchEx_DeleteMemberByName,
561 DispatchEx_DeleteMemberByDispID,
562 DispatchEx_GetMemberProperties,
563 DispatchEx_GetMemberName,
564 DispatchEx_GetNextDispID,
565 DispatchEx_GetNameSpaceParent
568 static IDispatchEx externalDisp = { &externalDispVtbl };
570 static HRESULT QueryInterface(REFIID,void**);
572 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
574 return QueryInterface(riid, ppv);
577 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
582 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
587 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
588 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
593 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
598 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
599 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
600 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
605 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
610 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
615 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
620 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
625 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
630 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
631 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
636 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
637 const GUID *pguidCmdGroup, DWORD nCmdID)
642 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
643 LPOLESTR *pchKey, DWORD dw)
648 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
649 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
654 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
656 *ppDispatch = (IDispatch*)&externalDisp;
660 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
661 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
666 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
667 IDataObject **ppPORet)
672 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
673 LPOLESTR *pchKey, DWORD dw)
678 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
679 DocHostUIHandler_QueryInterface,
680 DocHostUIHandler_AddRef,
681 DocHostUIHandler_Release,
682 DocHostUIHandler_ShowContextMenu,
683 DocHostUIHandler_GetHostInfo,
684 DocHostUIHandler_ShowUI,
685 DocHostUIHandler_HideUI,
686 DocHostUIHandler_UpdateUI,
687 DocHostUIHandler_EnableModeless,
688 DocHostUIHandler_OnDocWindowActivate,
689 DocHostUIHandler_OnFrameWindowActivate,
690 DocHostUIHandler_ResizeBorder,
691 DocHostUIHandler_TranslateAccelerator,
692 DocHostUIHandler_GetOptionKeyPath,
693 DocHostUIHandler_GetDropTarget,
694 DocHostUIHandler_GetExternal,
695 DocHostUIHandler_TranslateUrl,
696 DocHostUIHandler_FilterDataObject,
697 DocHostUIHandler_GetOverrideKeyPath
700 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
702 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
704 return E_NOINTERFACE;
707 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
712 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
717 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
722 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
727 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
732 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
733 LPCBORDERWIDTHS pborderwidths)
738 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
739 LPCBORDERWIDTHS pborderwidths)
744 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
745 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
750 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
751 LPOLEMENUGROUPWIDTHS lpMenuWidths)
756 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
757 HOLEMENU holemenu, HWND hwndActiveObject)
759 ok(0, "unexpected call\n");
763 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
774 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
779 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
781 ok(0, "unexpected call\n");
785 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
786 InPlaceFrame_QueryInterface,
788 InPlaceFrame_Release,
789 InPlaceFrame_GetWindow,
790 InPlaceFrame_ContextSensitiveHelp,
791 InPlaceFrame_GetBorder,
792 InPlaceFrame_RequestBorderSpace,
793 InPlaceFrame_SetBorderSpace,
794 InPlaceFrame_SetActiveObject,
795 InPlaceFrame_InsertMenus,
796 InPlaceFrame_SetMenu,
797 InPlaceFrame_RemoveMenus,
798 InPlaceFrame_SetStatusText,
799 InPlaceFrame_EnableModeless,
800 InPlaceFrame_TranslateAccelerator
803 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
805 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
807 return QueryInterface(riid, ppv);
810 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
815 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
820 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
822 *phwnd = container_hwnd;
826 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
828 ok(0, "unexpected call\n");
832 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
837 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
842 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
847 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
848 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
849 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
851 static const RECT rect = {0,0,300,300};
853 *ppFrame = &InPlaceFrame;
854 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceFrame;
856 *lprcClipRect = rect;
858 lpFrameInfo->cb = sizeof(*lpFrameInfo);
859 lpFrameInfo->fMDIApp = FALSE;
860 lpFrameInfo->hwndFrame = container_hwnd;
861 lpFrameInfo->haccel = NULL;
862 lpFrameInfo->cAccelEntries = 0;
867 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
872 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
877 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
882 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
887 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
892 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
897 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
898 InPlaceSite_QueryInterface,
901 InPlaceSite_GetWindow,
902 InPlaceSite_ContextSensitiveHelp,
903 InPlaceSite_CanInPlaceActivate,
904 InPlaceSite_OnInPlaceActivate,
905 InPlaceSite_OnUIActivate,
906 InPlaceSite_GetWindowContext,
908 InPlaceSite_OnUIDeactivate,
909 InPlaceSite_OnInPlaceDeactivate,
910 InPlaceSite_DiscardUndoState,
911 InPlaceSite_DeactivateAndUndo,
912 InPlaceSite_OnPosRectChange,
915 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
917 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
919 return QueryInterface(riid, ppv);
922 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
927 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
932 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
934 ok(0, "unexpected call\n");
938 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
941 ok(0, "unexpected call\n");
945 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
950 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
952 ok(0, "unexpected call\n");
956 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
958 ok(0, "unexpected call\n");
962 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
964 ok(0, "unexpected call\n");
968 static const IOleClientSiteVtbl ClientSiteVtbl = {
969 ClientSite_QueryInterface,
972 ClientSite_SaveObject,
973 ClientSite_GetMoniker,
974 ClientSite_GetContainer,
975 ClientSite_ShowObject,
976 ClientSite_OnShowWindow,
977 ClientSite_RequestNewObjectLayout
980 static IOleClientSite ClientSite = { &ClientSiteVtbl };
982 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
984 return QueryInterface(riid, ppv);
987 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
992 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
997 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
999 RECT rect = {0,0,300,300};
1000 IOleDocument *document;
1003 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1004 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1006 hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
1007 IOleDocument_Release(document);
1008 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1010 hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
1011 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1013 hres = IOleDocumentView_UIActivate(view, TRUE);
1014 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1016 hres = IOleDocumentView_SetRect(view, &rect);
1017 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1019 hres = IOleDocumentView_Show(view, TRUE);
1020 ok(hres == S_OK, "Show failed: %08x\n", hres);
1025 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1026 DocumentSite_QueryInterface,
1027 DocumentSite_AddRef,
1028 DocumentSite_Release,
1029 DocumentSite_ActivateMe
1032 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1034 static HRESULT QueryInterface(REFIID riid, void **ppv)
1038 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
1040 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
1041 *ppv = &DocumentSite;
1042 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
1043 *ppv = &InPlaceSite;
1044 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1045 *ppv = &DocHostUIHandler;
1047 return *ppv ? S_OK : E_NOINTERFACE;
1050 static IHTMLDocument2 *create_document(void)
1052 IHTMLDocument2 *doc;
1055 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1056 &IID_IHTMLDocument2, (void**)&doc);
1057 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
1062 static void load_string(IHTMLDocument2 *doc, const char *str)
1064 IPersistStreamInit *init;
1069 doc_complete = FALSE;
1071 mem = GlobalAlloc(0, len);
1072 memcpy(mem, str, len);
1073 CreateStreamOnHGlobal(mem, TRUE, &stream);
1075 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
1077 IPersistStreamInit_Load(init, stream);
1078 IPersistStreamInit_Release(init);
1079 IStream_Release(stream);
1082 static void do_advise(IHTMLDocument2 *doc, REFIID riid, IUnknown *unk_advise)
1084 IConnectionPointContainer *container;
1085 IConnectionPoint *cp;
1089 hres = IHTMLDocument2_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container);
1090 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
1092 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
1093 IConnectionPointContainer_Release(container);
1094 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
1098 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
1099 IConnectionPoint_Release(cp);
1100 ok(hres == S_OK, "Advise failed: %08x\n", hres);
1103 static void set_client_site(IHTMLDocument2 *doc, BOOL set)
1109 IOleDocumentView_Show(view, FALSE);
1110 IOleDocumentView_CloseView(view, 0);
1111 IOleDocumentView_SetInPlaceSite(view, NULL);
1112 IOleDocumentView_Release(view);
1116 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
1117 ok(hres == S_OK, "Could not et IOleObject: %08x\n", hres);
1119 hres = IOleObject_SetClientSite(oleobj, set ? &ClientSite : NULL);
1120 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1123 IHlinkTarget *hlink;
1125 hres = IOleObject_QueryInterface(oleobj, &IID_IHlinkTarget, (void**)&hlink);
1126 ok(hres == S_OK, "Could not get IHlinkTarget iface: %08x\n", hres);
1128 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
1129 ok(hres == S_OK, "Navgate failed: %08x\n", hres);
1131 IHlinkTarget_Release(hlink);
1134 IOleObject_Release(oleobj);
1137 typedef void (*domtest_t)(IHTMLDocument2*);
1139 static void load_doc(IHTMLDocument2 *doc, const char *str)
1141 IHTMLElement *body = NULL;
1144 static const WCHAR ucPtr[] = {'b','a','c','k','g','r','o','u','n','d',0};
1148 load_string(doc, str);
1149 do_advise(doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
1151 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
1152 TranslateMessage(&msg);
1153 DispatchMessage(&msg);
1156 hres = IHTMLDocument2_get_body(doc, &body);
1157 ok(hres == S_OK, "get_body failed: %08x\n", hres);
1159 /* Check we can query for function on the IHTMLElementBody interface */
1160 name = (WCHAR*)ucPtr;
1161 hres = IHTMLElement_GetIDsOfNames(body, &IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispID);
1162 ok(hres == S_OK, "GetIDsOfNames(background) failed %08x\n", hres);
1163 ok(dispID == DISPID_IHTMLBODYELEMENT_BACKGROUND, "Incorrect dispID got (%d)\n", dispID);
1165 IHTMLElement_Release(body);
1168 static IActiveScriptSite *site;
1169 static SCRIPTSTATE state;
1171 static HRESULT WINAPI ObjectSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
1174 ok(0, "unexpected call %s\n", debugstr_guid(riid));
1175 return E_NOINTERFACE;
1178 static ULONG WINAPI ObjectSafety_AddRef(IObjectSafety *iface)
1183 static ULONG WINAPI ObjectSafety_Release(IObjectSafety *iface)
1188 static HRESULT WINAPI ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
1189 DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
1191 CHECK_EXPECT(GetInterfaceSafetyOptions);
1193 ok(IsEqualGUID(&IID_IActiveScriptParse, riid), "unexpected riid %s\n", debugstr_guid(riid));
1194 ok(pdwSupportedOptions != NULL, "pdwSupportedOptions == NULL\n");
1195 ok(pdwEnabledOptions != NULL, "pdwEnabledOptions == NULL\n");
1197 *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER;
1198 *pdwEnabledOptions = INTERFACE_USES_DISPEX;
1203 static HRESULT WINAPI ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
1204 DWORD dwOptionSetMask, DWORD dwEnabledOptions)
1206 CHECK_EXPECT(SetInterfaceSafetyOptions);
1208 ok(IsEqualGUID(&IID_IActiveScriptParse, riid), "unexpected riid %s\n", debugstr_guid(riid));
1210 ok(dwOptionSetMask == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
1211 "dwOptionSetMask=%x\n", dwOptionSetMask);
1212 ok(dwEnabledOptions == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
1213 "dwEnabledOptions=%x\n", dwOptionSetMask);
1218 static const IObjectSafetyVtbl ObjectSafetyVtbl = {
1219 ObjectSafety_QueryInterface,
1220 ObjectSafety_AddRef,
1221 ObjectSafety_Release,
1222 ObjectSafety_GetInterfaceSafetyOptions,
1223 ObjectSafety_SetInterfaceSafetyOptions
1226 static IObjectSafety ObjectSafety = { &ObjectSafetyVtbl };
1228 static HRESULT WINAPI AXObjectSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
1232 if(IsEqualGUID(&IID_IActiveScript, riid)) {
1233 CHECK_EXPECT(AXQueryInterface_IActiveScript);
1234 return E_NOINTERFACE;
1237 if(IsEqualGUID(&IID_IObjectSafety, riid)) {
1238 CHECK_EXPECT(AXQueryInterface_IObjectSafety);
1240 return E_NOINTERFACE;
1245 ok(0, "unexpected call %s\n", debugstr_guid(riid));
1246 return E_NOINTERFACE;
1249 static HRESULT WINAPI AXObjectSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
1250 DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
1252 CHECK_EXPECT(AXGetInterfaceSafetyOptions);
1254 ok(IsEqualGUID(&IID_IDispatchEx, riid), "unexpected riid %s\n", debugstr_guid(riid));
1255 ok(pdwSupportedOptions != NULL, "pdwSupportedOptions == NULL\n");
1256 ok(pdwEnabledOptions != NULL, "pdwEnabledOptions == NULL\n");
1258 *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER;
1259 *pdwEnabledOptions = INTERFACE_USES_DISPEX;
1264 static HRESULT WINAPI AXObjectSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
1265 DWORD dwOptionSetMask, DWORD dwEnabledOptions)
1267 CHECK_EXPECT(AXSetInterfaceSafetyOptions);
1269 ok(IsEqualGUID(&IID_IDispatchEx, riid), "unexpected riid %s\n", debugstr_guid(riid));
1271 ok(dwOptionSetMask == (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACE_USES_SECURITY_MANAGER),
1272 "dwOptionSetMask=%x\n", dwOptionSetMask);
1273 ok(dwEnabledOptions == (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACE_USES_SECURITY_MANAGER),
1274 "dwEnabledOptions=%x\n", dwOptionSetMask);
1279 static const IObjectSafetyVtbl AXObjectSafetyVtbl = {
1280 AXObjectSafety_QueryInterface,
1281 ObjectSafety_AddRef,
1282 ObjectSafety_Release,
1283 AXObjectSafety_GetInterfaceSafetyOptions,
1284 AXObjectSafety_SetInterfaceSafetyOptions
1287 static IObjectSafety AXObjectSafety = { &AXObjectSafetyVtbl };
1289 static BOOL set_safe_reg(BOOL init)
1291 return init_key("CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
1295 static void test_security(void)
1297 IInternetHostSecurityManager *sec_mgr;
1298 IServiceProvider *sp;
1299 DWORD policy, policy_size;
1300 struct CONFIRMSAFETY cs;
1304 hres = IActiveScriptSite_QueryInterface(site, &IID_IServiceProvider, (void**)&sp);
1305 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
1307 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager,
1308 &IID_IInternetHostSecurityManager, (void**)&sec_mgr);
1309 IServiceProvider_Release(sp);
1310 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
1312 hres = IInternetHostSecurityManager_ProcessUrlAction(sec_mgr, URLACTION_ACTIVEX_RUN, (BYTE*)&policy, sizeof(policy),
1313 (BYTE*)&CLSID_TestActiveX, sizeof(CLSID), 0, 0);
1314 ok(hres == S_OK, "ProcessUrlAction failed: %08x\n", hres);
1315 ok(policy == URLPOLICY_ALLOW, "policy = %x\n", policy);
1317 cs.clsid = CLSID_TestActiveX;
1318 cs.pUnk = (IUnknown*)&AXObjectSafety;
1322 SET_EXPECT(AXQueryInterface_IActiveScript);
1323 SET_EXPECT(AXQueryInterface_IObjectSafety);
1324 SET_EXPECT(AXGetInterfaceSafetyOptions);
1325 SET_EXPECT(AXSetInterfaceSafetyOptions);
1326 hres = IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
1327 &ppolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
1328 CHECK_CALLED(AXQueryInterface_IActiveScript);
1329 CHECK_CALLED(AXQueryInterface_IObjectSafety);
1330 CHECK_CALLED(AXGetInterfaceSafetyOptions);
1331 CHECK_CALLED(AXSetInterfaceSafetyOptions);
1333 ok(hres == S_OK, "QueryCusromPolicy failed: %08x\n", hres);
1334 ok(policy_size == sizeof(DWORD), "policy_size = %d\n", policy_size);
1335 ok(*(DWORD*)ppolicy == URLPOLICY_ALLOW, "policy = %x\n", *(DWORD*)ppolicy);
1336 CoTaskMemFree(ppolicy);
1339 SET_EXPECT(AXQueryInterface_IActiveScript);
1340 SET_EXPECT(AXQueryInterface_IObjectSafety);
1341 hres = IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
1342 &ppolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
1343 CHECK_CALLED(AXQueryInterface_IActiveScript);
1344 CHECK_CALLED(AXQueryInterface_IObjectSafety);
1346 ok(hres == S_OK, "QueryCusromPolicy failed: %08x\n", hres);
1347 ok(policy_size == sizeof(DWORD), "policy_size = %d\n", policy_size);
1348 ok(*(DWORD*)ppolicy == URLPOLICY_DISALLOW, "policy = %x\n", *(DWORD*)ppolicy);
1349 CoTaskMemFree(ppolicy);
1351 if(set_safe_reg(TRUE)) {
1353 SET_EXPECT(AXQueryInterface_IActiveScript);
1354 SET_EXPECT(AXQueryInterface_IObjectSafety);
1355 hres = IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
1356 &ppolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
1357 CHECK_CALLED(AXQueryInterface_IActiveScript);
1358 CHECK_CALLED(AXQueryInterface_IObjectSafety);
1360 ok(hres == S_OK, "QueryCusromPolicy failed: %08x\n", hres);
1361 ok(policy_size == sizeof(DWORD), "policy_size = %d\n", policy_size);
1362 ok(*(DWORD*)ppolicy == URLPOLICY_ALLOW, "policy = %x\n", *(DWORD*)ppolicy);
1363 CoTaskMemFree(ppolicy);
1366 SET_EXPECT(AXQueryInterface_IActiveScript);
1367 SET_EXPECT(AXQueryInterface_IObjectSafety);
1368 SET_EXPECT(AXGetInterfaceSafetyOptions);
1369 SET_EXPECT(AXSetInterfaceSafetyOptions);
1370 hres = IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
1371 &ppolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
1372 CHECK_CALLED(AXQueryInterface_IActiveScript);
1373 CHECK_CALLED(AXQueryInterface_IObjectSafety);
1374 CHECK_CALLED(AXGetInterfaceSafetyOptions);
1375 CHECK_CALLED(AXSetInterfaceSafetyOptions);
1377 ok(hres == S_OK, "QueryCusromPolicy failed: %08x\n", hres);
1378 ok(policy_size == sizeof(DWORD), "policy_size = %d\n", policy_size);
1379 ok(*(DWORD*)ppolicy == URLPOLICY_ALLOW, "policy = %x\n", *(DWORD*)ppolicy);
1380 CoTaskMemFree(ppolicy);
1382 set_safe_reg(FALSE);
1384 skip("Could not set safety registry\n");
1387 IInternetHostSecurityManager_Release(sec_mgr);
1390 static HRESULT WINAPI ActiveScriptProperty_QueryInterface(IActiveScriptProperty *iface, REFIID riid, void **ppv)
1393 ok(0, "unexpected call\n");
1394 return E_NOINTERFACE;
1397 static ULONG WINAPI ActiveScriptProperty_AddRef(IActiveScriptProperty *iface)
1402 static ULONG WINAPI ActiveScriptProperty_Release(IActiveScriptProperty *iface)
1407 static HRESULT WINAPI ActiveScriptProperty_GetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
1408 VARIANT *pvarIndex, VARIANT *pvarValue)
1410 ok(0, "unexpected call\n");
1414 static HRESULT WINAPI ActiveScriptProperty_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
1415 VARIANT *pvarIndex, VARIANT *pvarValue)
1417 switch(dwProperty) {
1418 case SCRIPTPROP_HACK_TRIDENTEVENTSINK:
1419 CHECK_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK);
1420 ok(V_VT(pvarValue) == VT_BOOL, "V_VT(pvarValue)=%d\n", V_VT(pvarValue));
1421 ok(V_BOOL(pvarValue) == VARIANT_TRUE, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue));
1423 case SCRIPTPROP_INVOKEVERSIONING:
1424 CHECK_EXPECT(SetProperty_INVOKEVERSIONING);
1425 ok(V_VT(pvarValue) == VT_I4, "V_VT(pvarValue)=%d\n", V_VT(pvarValue));
1426 ok(V_I4(pvarValue) == 1, "V_I4(pvarValue)=%d\n", V_I4(pvarValue));
1428 case SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION:
1429 CHECK_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION);
1430 ok(V_VT(pvarValue) == VT_BOOL, "V_VT(pvarValue)=%d\n", V_VT(pvarValue));
1431 ok(V_BOOL(pvarValue) == VARIANT_TRUE, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue));
1434 ok(0, "unexpected property %x\n", dwProperty);
1438 ok(!pvarIndex, "pvarIndex != NULL\n");
1439 ok(pvarValue != NULL, "pvarValue == NULL\n");
1444 static const IActiveScriptPropertyVtbl ActiveScriptPropertyVtbl = {
1445 ActiveScriptProperty_QueryInterface,
1446 ActiveScriptProperty_AddRef,
1447 ActiveScriptProperty_Release,
1448 ActiveScriptProperty_GetProperty,
1449 ActiveScriptProperty_SetProperty
1452 static IActiveScriptProperty ActiveScriptProperty = { &ActiveScriptPropertyVtbl };
1454 static HRESULT WINAPI ActiveScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
1457 ok(0, "unexpected call\n");
1458 return E_NOINTERFACE;
1461 static ULONG WINAPI ActiveScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
1466 static ULONG WINAPI ActiveScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
1471 static HRESULT WINAPI ActiveScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
1472 LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
1473 LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
1474 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
1476 ok(0, "unexpected call\n");
1480 static const IActiveScriptParseProcedure2Vtbl ActiveScriptParseProcedureVtbl = {
1481 ActiveScriptParseProcedure_QueryInterface,
1482 ActiveScriptParseProcedure_AddRef,
1483 ActiveScriptParseProcedure_Release,
1484 ActiveScriptParseProcedure_ParseProcedureText
1487 static IActiveScriptParseProcedure2 ActiveScriptParseProcedure = { &ActiveScriptParseProcedureVtbl };
1489 static HRESULT WINAPI ActiveScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
1492 ok(0, "unexpected call\n");
1493 return E_NOINTERFACE;
1496 static ULONG WINAPI ActiveScriptParse_AddRef(IActiveScriptParse *iface)
1501 static ULONG WINAPI ActiveScriptParse_Release(IActiveScriptParse *iface)
1506 static HRESULT WINAPI ActiveScriptParse_InitNew(IActiveScriptParse *iface)
1508 CHECK_EXPECT(InitNew);
1512 static HRESULT WINAPI ActiveScriptParse_AddScriptlet(IActiveScriptParse *iface,
1513 LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
1514 LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
1515 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
1516 BSTR *pbstrName, EXCEPINFO *pexcepinfo)
1518 ok(0, "unexpected call\n");
1522 static HRESULT dispex_propput(IDispatchEx *obj, DISPID id, DWORD flags, VARIANT *var)
1524 DISPID propput_arg = DISPID_PROPERTYPUT;
1525 DISPPARAMS dp = {var, &propput_arg, 1, 1};
1528 return IDispatchEx_InvokeEx(obj, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT|flags, &dp, NULL, &ei, NULL);
1531 static void test_func(IDispatchEx *obj)
1534 IDispatchEx *dispex;
1542 str = a2bstr("toString");
1543 hres = IDispatchEx_GetDispID(obj, str, fdexNameCaseSensitive, &id);
1545 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1546 ok(id == DISPID_IOMNAVIGATOR_TOSTRING, "id = %x\n", id);
1548 memset(&dp, 0, sizeof(dp));
1549 memset(&ei, 0, sizeof(ei));
1551 hres = IDispatchEx_InvokeEx(obj, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
1552 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1553 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
1554 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
1555 disp = V_DISPATCH(&var);
1557 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
1558 IDispatch_Release(disp);
1559 ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
1561 /* FIXME: Test InvokeEx(DISPATCH_METHOD) */
1563 memset(&dp, 0, sizeof(dp));
1564 memset(&ei, 0, sizeof(ei));
1566 hres = IDispatchEx_Invoke(dispex, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dp, &var, &ei, NULL);
1567 ok(hres == S_OK || broken(E_ACCESSDENIED), "InvokeEx failed: %08x\n", hres);
1568 if(SUCCEEDED(hres)) {
1569 ok(V_VT(&var) == VT_BSTR, "V_VT(var)=%d\n", V_VT(&var));
1570 ok(!strcmp_wa(V_BSTR(&var), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var)));
1576 hres = dispex_propput(obj, id, 0, &var);
1577 ok(hres == E_NOTIMPL, "InvokeEx failed: %08x\n", hres);
1579 IDispatchEx_Release(dispex);
1582 static void test_nextdispid(IDispatchEx *dispex)
1584 DISPID last_id = DISPID_STARTENUM, id, dyn_id;
1589 name = a2bstr("dynVal");
1590 hres = IDispatchEx_GetDispID(dispex, name, fdexNameCaseSensitive|fdexNameEnsure, &dyn_id);
1591 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1592 SysFreeString(name);
1594 V_VT(&var) = VT_EMPTY;
1595 hres = dispex_propput(dispex, dyn_id, 0, &var);
1597 while(last_id != dyn_id) {
1598 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, last_id, &id);
1599 ok(hres == S_OK, "GetNextDispID returned: %08x\n", hres);
1600 ok(id != DISPID_STARTENUM, "id == DISPID_STARTENUM\n");
1601 ok(id != DISPID_IOMNAVIGATOR_TOSTRING, "id == DISPID_IOMNAVIGATOR_TOSTRING\n");
1603 hres = IDispatchEx_GetMemberName(dispex, id, &name);
1604 ok(hres == S_OK, "GetMemberName failed: %08x\n", hres);
1607 ok(!strcmp_wa(name, "dynVal"), "name = %s\n", wine_dbgstr_w(name));
1608 else if(id == DISPID_IOMNAVIGATOR_PLATFORM)
1609 ok(!strcmp_wa(name, "platform"), "name = %s\n", wine_dbgstr_w(name));
1611 SysFreeString(name);
1615 hres = IDispatchEx_GetNextDispID(dispex, 0, id, &id);
1616 ok(hres == S_FALSE, "GetNextDispID returned: %08x\n", hres);
1617 ok(id == DISPID_STARTENUM, "id != DISPID_STARTENUM\n");
1620 static void test_global_id(void)
1629 SET_EXPECT(GetScriptDispatch);
1630 SET_EXPECT(script_divid_d);
1631 tmp = a2bstr("divid");
1632 hres = IDispatchEx_GetDispID(window_dispex, tmp, fdexNameCaseSensitive, &id);
1633 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1635 CHECK_CALLED(GetScriptDispatch);
1636 CHECK_CALLED(script_divid_d);
1639 memset(&ei, 0, sizeof(ei));
1640 memset(&dp, 0, sizeof(dp));
1641 hres = IDispatchEx_InvokeEx(window_dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
1642 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1643 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var) = %d\n", V_VT(&var));
1647 static HRESULT WINAPI ActiveScriptParse_ParseScriptText(IActiveScriptParse *iface,
1648 LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
1649 LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
1650 DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
1652 IDispatchEx *document, *dispex;
1653 IHTMLWindow2 *window;
1654 IOmNavigator *navigator;
1663 static const WCHAR documentW[] = {'d','o','c','u','m','e','n','t',0};
1664 static const WCHAR testW[] = {'t','e','s','t',0};
1665 static const WCHAR funcW[] = {'f','u','n','c',0};
1667 CHECK_EXPECT(ParseScriptText);
1669 SET_EXPECT(GetScriptDispatch);
1671 tmp = SysAllocString(documentW);
1672 hres = IDispatchEx_GetDispID(window_dispex, tmp, fdexNameCaseSensitive, &id);
1674 ok(hres == S_OK, "GetDispID(document) failed: %08x\n", hres);
1675 ok(id == DISPID_IHTMLWINDOW2_DOCUMENT, "id=%x\n", id);
1677 CHECK_CALLED(GetScriptDispatch);
1680 memset(&dp, 0, sizeof(dp));
1681 memset(&ei, 0, sizeof(ei));
1683 hres = IDispatchEx_InvokeEx(window_dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
1684 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1685 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
1686 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(&var) == NULL\n");
1688 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IDispatchEx, (void**)&document);
1690 ok(hres == S_OK, "Could not get DispatchEx: %08x\n", hres);
1692 tmp = SysAllocString(testW);
1693 hres = IDispatchEx_GetDispID(document, tmp, fdexNameCaseSensitive, &id);
1694 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
1695 hres = IDispatchEx_GetDispID(document, tmp, fdexNameCaseSensitive | fdexNameImplicit, &id);
1696 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
1700 tmp = SysAllocString(testW);
1701 hres = IDispatchEx_GetDispID(document, tmp, fdexNameCaseSensitive|fdexNameEnsure, &id);
1703 ok(hres == S_OK, "GetDispID(document) failed: %08x\n", hres);
1704 ok(id, "id == 0\n");
1708 hres = dispex_propput(document, id, 0, &var);
1709 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1711 tmp = SysAllocString(testW);
1712 hres = IDispatchEx_GetDispID(document, tmp, fdexNameCaseSensitive, &id);
1714 ok(hres == S_OK, "GetDispID(document) failed: %08x\n", hres);
1717 memset(&dp, 0, sizeof(dp));
1718 memset(&ei, 0, sizeof(ei));
1719 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
1720 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1721 ok(V_VT(&var) == VT_I4, "V_VT(var)=%d\n", V_VT(&var));
1722 ok(V_I4(&var) == 100, "V_I4(&var) = %d\n", V_I4(&var));
1726 hres = dispex_propput(document, id, DISPATCH_PROPERTYPUTREF, &var);
1727 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1730 memset(&dp, 0, sizeof(dp));
1731 memset(&ei, 0, sizeof(ei));
1732 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
1733 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1734 ok(V_VT(&var) == VT_I4, "V_VT(var)=%d\n", V_VT(&var));
1735 ok(V_I4(&var) == 200, "V_I4(&var) = %d\n", V_I4(&var));
1737 memset(&dp, 0, sizeof(dp));
1738 memset(&ei, 0, sizeof(ei));
1743 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_PROPERTYPUT, &dp, NULL, &ei, NULL);
1744 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1747 memset(&dp, 0, sizeof(dp));
1748 memset(&ei, 0, sizeof(ei));
1749 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
1750 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1751 ok(V_VT(&var) == VT_I4, "V_VT(var)=%d\n", V_VT(&var));
1752 ok(V_I4(&var) == 300, "V_I4(&var) = %d\n", V_I4(&var));
1754 unk = (void*)0xdeadbeef;
1755 hres = IDispatchEx_GetNameSpaceParent(window_dispex, &unk);
1756 ok(hres == S_OK, "GetNameSpaceParent failed: %08x\n", hres);
1757 ok(!unk, "unk=%p, expected NULL\n", unk);
1760 tmp = SysAllocString(funcW);
1761 hres = IDispatchEx_GetDispID(document, tmp, fdexNameCaseSensitive|fdexNameEnsure, &id);
1763 ok(hres == S_OK, "GetDispID(func) failed: %08x\n", hres);
1764 ok(id, "id == 0\n");
1769 dp.rgdispidNamedArgs = NULL;
1770 V_VT(&var) = VT_DISPATCH;
1771 V_DISPATCH(&var) = (IDispatch*)&funcDisp;
1772 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_PROPERTYPUT, &dp, NULL, &ei, NULL);
1773 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1776 memset(&dp, 0, sizeof(dp));
1777 memset(&ei, 0, sizeof(ei));
1778 V_VT(&arg) = VT_BOOL;
1779 V_BOOL(&arg) = VARIANT_TRUE;
1783 SET_EXPECT(funcDisp);
1784 hres = IDispatchEx_InvokeEx(document, id, LOCALE_NEUTRAL, INVOKE_FUNC, &dp, &var, &ei, NULL);
1785 CHECK_CALLED(funcDisp);
1787 ok(hres == S_OK, "InvokeEx(INVOKE_FUNC) failed: %08x\n", hres);
1788 ok(V_VT(&var) == VT_I4, "V_VT(var)=%d\n", V_VT(&var));
1789 ok(V_I4(&var) == 100, "V_I4(&var) == NULL\n");
1791 IDispatchEx_Release(document);
1793 hres = IDispatchEx_QueryInterface(window_dispex, &IID_IHTMLWindow2, (void**)&window);
1794 ok(hres == S_OK, "Could not get IHTMLWindow2 iface: %08x\n", hres);
1796 hres = IHTMLWindow2_get_navigator(window, &navigator);
1797 IHTMLWindow2_Release(window);
1798 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
1800 hres = IOmNavigator_QueryInterface(navigator, &IID_IDispatchEx, (void**)&dispex);
1801 IOmNavigator_Release(navigator);
1802 ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
1805 test_nextdispid(dispex);
1806 IDispatchEx_Release(dispex);
1808 script_disp = (IDispatch*)&scriptDisp;
1810 SET_EXPECT(GetScriptDispatch);
1811 SET_EXPECT(script_testprop_d);
1812 tmp = a2bstr("testProp");
1813 hres = IDispatchEx_GetDispID(window_dispex, tmp, fdexNameCaseSensitive, &id);
1814 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1815 ok(id != DISPID_SCRIPT_TESTPROP, "id == DISPID_SCRIPT_TESTPROP\n");
1816 CHECK_CALLED(GetScriptDispatch);
1817 CHECK_CALLED(script_testprop_d);
1820 tmp = a2bstr("testProp");
1821 hres = IDispatchEx_GetDispID(window_dispex, tmp, fdexNameCaseSensitive, &id);
1822 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1823 ok(id != DISPID_SCRIPT_TESTPROP, "id == DISPID_SCRIPT_TESTPROP\n");
1826 SET_EXPECT(GetScriptDispatch);
1827 SET_EXPECT(script_testprop_i);
1828 memset(&ei, 0, sizeof(ei));
1829 memset(&dp, 0, sizeof(dp));
1830 hres = IDispatchEx_InvokeEx(window_dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
1831 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1832 ok(V_VT(&var) == VT_NULL, "V_VT(var) = %d\n", V_VT(&var));
1833 CHECK_CALLED(GetScriptDispatch);
1834 CHECK_CALLED(script_testprop_i);
1836 SET_EXPECT(GetScriptDispatch);
1837 SET_EXPECT(script_testprop2_d);
1838 tmp = a2bstr("testProp2");
1839 hres = IDispatchEx_GetDispID(window_dispex, tmp, fdexNameCaseSensitive|fdexNameEnsure, &id);
1840 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1841 ok(id != DISPID_SCRIPT_TESTPROP2, "id == DISPID_SCRIPT_TESTPROP2\n");
1842 CHECK_CALLED(GetScriptDispatch);
1843 CHECK_CALLED(script_testprop2_d);
1853 static const IActiveScriptParseVtbl ActiveScriptParseVtbl = {
1854 ActiveScriptParse_QueryInterface,
1855 ActiveScriptParse_AddRef,
1856 ActiveScriptParse_Release,
1857 ActiveScriptParse_InitNew,
1858 ActiveScriptParse_AddScriptlet,
1859 ActiveScriptParse_ParseScriptText
1862 static IActiveScriptParse ActiveScriptParse = { &ActiveScriptParseVtbl };
1864 static HRESULT WINAPI ActiveScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
1868 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IActiveScript, riid)) {
1873 if(IsEqualGUID(&IID_IActiveScriptParse, riid)) {
1874 *ppv = &ActiveScriptParse;
1878 if(IsEqualGUID(&IID_IActiveScriptParseProcedure2, riid)) {
1879 *ppv = &ActiveScriptParseProcedure;
1883 if(IsEqualGUID(&IID_IActiveScriptProperty, riid)) {
1884 *ppv = &ActiveScriptProperty;
1888 if(IsEqualGUID(&IID_IObjectSafety, riid)) {
1889 *ppv = &ObjectSafety;
1893 if(IsEqualGUID(&IID_IActiveScriptDebug, riid))
1894 return E_NOINTERFACE;
1896 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1897 return E_NOINTERFACE;
1900 static ULONG WINAPI ActiveScript_AddRef(IActiveScript *iface)
1905 static ULONG WINAPI ActiveScript_Release(IActiveScript *iface)
1910 static HRESULT WINAPI ActiveScript_SetScriptSite(IActiveScript *iface, IActiveScriptSite *pass)
1912 IActiveScriptSiteInterruptPoll *poll;
1913 IActiveScriptSiteDebug *debug;
1914 IServiceProvider *service;
1915 ICanHandleException *canexpection;
1919 CHECK_EXPECT(SetScriptSite);
1921 ok(pass != NULL, "pass == NULL\n");
1923 hres = IActiveScriptSite_QueryInterface(pass, &IID_IActiveScriptSiteInterruptPoll, (void**)&poll);
1924 ok(hres == S_OK, "Could not get IActiveScriptSiteInterruptPoll interface: %08x\n", hres);
1926 IActiveScriptSiteInterruptPoll_Release(poll);
1928 hres = IActiveScriptSite_GetLCID(pass, &lcid);
1929 ok(hres == S_OK, "GetLCID failed: %08x\n", hres);
1931 hres = IActiveScriptSite_OnStateChange(pass, (state = SCRIPTSTATE_INITIALIZED));
1932 ok(hres == S_OK, "OnStateChange failed: %08x\n", hres);
1934 hres = IActiveScriptSite_QueryInterface(pass, &IID_IActiveScriptSiteDebug, (void**)&debug);
1935 ok(hres == S_OK, "Could not get IActiveScriptSiteDebug interface: %08x\n", hres);
1937 IActiveScriptSiteDebug32_Release(debug);
1939 hres = IActiveScriptSite_QueryInterface(pass, &IID_ICanHandleException, (void**)&canexpection);
1940 ok(hres == E_NOINTERFACE, "Could not get IID_ICanHandleException interface: %08x\n", hres);
1942 hres = IActiveScriptSite_QueryInterface(pass, &IID_IServiceProvider, (void**)&service);
1943 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1945 IServiceProvider_Release(service);
1948 IActiveScriptSite_AddRef(site);
1952 static HRESULT WINAPI ActiveScript_GetScriptSite(IActiveScript *iface, REFIID riid,
1955 ok(0, "unexpected call\n");
1959 static HRESULT WINAPI ActiveScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
1964 case SCRIPTSTATE_STARTED:
1965 CHECK_EXPECT(SetScriptState_STARTED);
1967 case SCRIPTSTATE_CONNECTED:
1968 CHECK_EXPECT(SetScriptState_CONNECTED);
1970 case SCRIPTSTATE_DISCONNECTED:
1971 CHECK_EXPECT(SetScriptState_DISCONNECTED);
1974 ok(0, "unexpected state %d\n", ss);
1978 hres = IActiveScriptSite_OnStateChange(site, (state = ss));
1982 static HRESULT WINAPI ActiveScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
1984 CHECK_EXPECT(GetScriptState);
1990 static HRESULT WINAPI ActiveScript_Close(IActiveScript *iface)
1992 CHECK_EXPECT(Close);
1996 static HRESULT WINAPI ActiveScript_AddNamedItem(IActiveScript *iface,
1997 LPCOLESTR pstrName, DWORD dwFlags)
2000 IUnknown *unk = NULL, *unk2;
2003 static const WCHAR windowW[] = {'w','i','n','d','o','w',0};
2005 static const IID unknown_iid = {0x719C3050,0xF9D3,0x11CF,{0xA4,0x93,0x00,0x40,0x05,0x23,0xA8,0xA0}};
2007 CHECK_EXPECT(AddNamedItem);
2009 ok(!lstrcmpW(pstrName, windowW), "pstrName=%s\n", wine_dbgstr_w(pstrName));
2010 ok(dwFlags == (SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS), "dwFlags=%x\n", dwFlags);
2012 hres = IActiveScriptSite_GetItemInfo(site, windowW, SCRIPTINFO_IUNKNOWN, &unk, NULL);
2013 ok(hres == S_OK, "GetItemInfo failed: %08x\n", hres);
2014 ok(unk != NULL, "unk == NULL\n");
2016 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
2017 ok(hres == S_OK, "Could not get IDispatch interface: %08x\n", hres);
2019 IDispatch_Release(disp);
2021 hres = IUnknown_QueryInterface(unk, &unknown_iid, (void**)&unk2);
2022 ok(hres == E_NOINTERFACE, "Got ?? interface: %p\n", unk2);
2024 IUnknown_Release(unk2);
2026 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&window_dispex);
2027 ok(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
2029 IUnknown_Release(unk);
2033 static HRESULT WINAPI ActiveScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib,
2034 DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
2036 ok(0, "unexpected call\n");
2040 static HRESULT WINAPI ActiveScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName,
2043 CHECK_EXPECT(GetScriptDispatch);
2045 ok(!strcmp_wa(pstrItemName, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName));
2050 *ppdisp = script_disp;
2054 static HRESULT WINAPI ActiveScript_GetCurrentScriptThreadID(IActiveScript *iface,
2055 SCRIPTTHREADID *pstridThread)
2057 ok(0, "unexpected call\n");
2061 static HRESULT WINAPI ActiveScript_GetScriptThreadID(IActiveScript *iface,
2062 DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
2064 ok(0, "unexpected call\n");
2068 static HRESULT WINAPI ActiveScript_GetScriptThreadState(IActiveScript *iface,
2069 SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
2071 ok(0, "unexpected call\n");
2075 static HRESULT WINAPI ActiveScript_InterruptScriptThread(IActiveScript *iface,
2076 SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
2078 ok(0, "unexpected call\n");
2082 static HRESULT WINAPI ActiveScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
2084 ok(0, "unexpected call\n");
2088 static const IActiveScriptVtbl ActiveScriptVtbl = {
2089 ActiveScript_QueryInterface,
2090 ActiveScript_AddRef,
2091 ActiveScript_Release,
2092 ActiveScript_SetScriptSite,
2093 ActiveScript_GetScriptSite,
2094 ActiveScript_SetScriptState,
2095 ActiveScript_GetScriptState,
2097 ActiveScript_AddNamedItem,
2098 ActiveScript_AddTypeLib,
2099 ActiveScript_GetScriptDispatch,
2100 ActiveScript_GetCurrentScriptThreadID,
2101 ActiveScript_GetScriptThreadID,
2102 ActiveScript_GetScriptThreadState,
2103 ActiveScript_InterruptScriptThread,
2107 static IActiveScript ActiveScript = { &ActiveScriptVtbl };
2109 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2113 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2118 if(IsEqualGUID(&IID_IMarshal, riid))
2119 return E_NOINTERFACE;
2120 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
2121 return E_NOINTERFACE;
2123 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2127 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2132 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2137 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2139 CHECK_EXPECT(CreateInstance);
2141 ok(!outer, "outer = %p\n", outer);
2142 ok(IsEqualGUID(&IID_IActiveScript, riid), "unexpected riid %s\n", debugstr_guid(riid));
2143 *ppv = &ActiveScript;
2147 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2149 ok(0, "unexpected call\n");
2153 static const IClassFactoryVtbl ClassFactoryVtbl = {
2154 ClassFactory_QueryInterface,
2155 ClassFactory_AddRef,
2156 ClassFactory_Release,
2157 ClassFactory_CreateInstance,
2158 ClassFactory_LockServer
2161 static IClassFactory script_cf = { &ClassFactoryVtbl };
2163 static const char simple_script_str[] =
2164 "<html><head></head><body>"
2165 "<div id=\"divid\"></div>"
2166 "<script language=\"TestScript\">simple script</script>"
2169 static void test_simple_script(void)
2171 IHTMLDocument2 *doc;
2173 doc = create_document();
2177 SET_EXPECT(CreateInstance);
2178 SET_EXPECT(GetInterfaceSafetyOptions);
2179 SET_EXPECT(SetInterfaceSafetyOptions);
2180 SET_EXPECT(SetProperty_INVOKEVERSIONING); /* IE8 */
2181 SET_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK);
2182 SET_EXPECT(InitNew);
2183 SET_EXPECT(SetScriptSite);
2184 SET_EXPECT(GetScriptState);
2185 SET_EXPECT(SetScriptState_STARTED);
2186 SET_EXPECT(AddNamedItem);
2187 SET_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION); /* IE8 */
2188 SET_EXPECT(ParseScriptText);
2189 SET_EXPECT(SetScriptState_CONNECTED);
2191 load_doc(doc, simple_script_str);
2193 CHECK_CALLED(CreateInstance);
2194 CHECK_CALLED(GetInterfaceSafetyOptions);
2195 CHECK_CALLED(SetInterfaceSafetyOptions);
2196 CHECK_CALLED_BROKEN(SetProperty_INVOKEVERSIONING); /* IE8 */
2197 CHECK_CALLED(SetProperty_HACK_TRIDENTEVENTSINK);
2198 CHECK_CALLED(InitNew);
2199 CHECK_CALLED(SetScriptSite);
2200 CHECK_CALLED(GetScriptState);
2201 CHECK_CALLED(SetScriptState_STARTED);
2202 CHECK_CALLED(AddNamedItem);
2203 CHECK_CALLED_BROKEN(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION); /* IE8 */
2204 CHECK_CALLED(ParseScriptText);
2205 CHECK_CALLED(SetScriptState_CONNECTED);
2208 IActiveScriptSite_Release(site);
2210 IDispatchEx_Release(window_dispex);
2212 SET_EXPECT(SetScriptState_DISCONNECTED);
2215 IHTMLDocument2_Release(doc);
2217 CHECK_CALLED(SetScriptState_DISCONNECTED);
2218 CHECK_CALLED(Close);
2221 static void run_js_script(const char *test_name)
2223 WCHAR url[INTERNET_MAX_URL_LENGTH];
2224 IPersistMoniker *persist;
2225 IHTMLDocument2 *doc;
2231 static const WCHAR resW[] = {'r','e','s',':','/','/'};
2233 trace("running %s...\n", test_name);
2235 doc = create_document();
2239 set_client_site(doc, TRUE);
2240 do_advise(doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
2242 memcpy(url, resW, sizeof(resW));
2243 ptr = url + sizeof(resW)/sizeof(WCHAR);
2244 GetModuleFileNameW(NULL, ptr, sizeof(url)/sizeof(WCHAR) - (ptr-url));
2245 ptr += lstrlenW(ptr);
2247 MultiByteToWideChar(CP_ACP, 0, test_name, -1, ptr, sizeof(url)/sizeof(WCHAR) - (ptr-url));
2249 hres = CreateURLMoniker(NULL, url, &mon);
2250 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2252 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist);
2253 ok(hres == S_OK, "Could not get IPersistMoniker iface: %08x\n", hres);
2255 hres = IPersistMoniker_Load(persist, FALSE, mon, NULL, 0);
2256 ok(hres == S_OK, "Load failed: %08x\n", hres);
2258 IMoniker_Release(mon);
2259 IPersistMoniker_Release(persist);
2261 SET_EXPECT(external_success);
2263 while(!called_external_success && GetMessage(&msg, NULL, 0, 0)) {
2264 TranslateMessage(&msg);
2265 DispatchMessage(&msg);
2268 CHECK_CALLED(external_success);
2270 set_client_site(doc, FALSE);
2271 IHTMLDocument2_Release(doc);
2274 static void run_js_tests(void)
2276 run_js_script("jstest.html");
2279 static BOOL init_registry(BOOL init)
2281 return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID, init)
2282 && init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}",
2284 && init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}",
2288 static BOOL register_script_engine(void)
2293 if(!init_registry(TRUE)) {
2294 init_registry(FALSE);
2298 hres = CoRegisterClassObject(&CLSID_TestScript, (IUnknown *)&script_cf,
2299 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2300 ok(hres == S_OK, "Could not register screipt engine: %08x\n", hres);
2305 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2307 return DefWindowProc(hwnd, msg, wParam, lParam);
2310 static HWND create_container_window(void)
2312 static const CHAR szHTMLDocumentTest[] = "HTMLDocumentTest";
2313 static WNDCLASSEXA wndclass = {
2314 sizeof(WNDCLASSEXA),
2317 0, 0, NULL, NULL, NULL, NULL, NULL,
2322 RegisterClassExA(&wndclass);
2323 return CreateWindowA(szHTMLDocumentTest, szHTMLDocumentTest,
2324 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
2325 300, 300, NULL, NULL, NULL, NULL);
2331 container_hwnd = create_container_window();
2333 if(winetest_interactive || ! is_ie_hardened()) {
2334 if(register_script_engine()) {
2335 test_simple_script();
2337 init_registry(FALSE);
2339 skip("Could not register TestScript engine\n");
2342 skip("IE running in Enhanced Security Configuration\n");
2345 DestroyWindow(container_hwnd);