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_IDispatch
);
127 DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
128 DEFINE_EXPECT(external_success
);
130 #define TESTSCRIPT_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80746}"
131 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
133 #define DISPID_SCRIPT_TESTPROP 0x100000
134 #define DISPID_SCRIPT_TESTPROP2 0x100001
136 #define DISPID_EXTERNAL_OK 0x300000
137 #define DISPID_EXTERNAL_TRACE 0x300001
138 #define DISPID_EXTERNAL_REPORTSUCCESS 0x300002
140 static const GUID CLSID_TestScript
=
141 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}};
142 static const GUID CLSID_TestActiveX
=
143 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
145 static IHTMLDocument2
*notif_doc
;
146 static IOleDocumentView
*view
;
147 static IDispatchEx
*window_dispex
;
148 static BOOL doc_complete
;
149 static IDispatch
*script_disp
;
150 static BOOL ax_objsafe
;
151 static HWND container_hwnd
;
152 static HRESULT ax_getopt_hres
= S_OK
, ax_setopt_dispex_hres
= S_OK
, ax_setopt_disp_hres
= S_OK
;
153 static DWORD ax_setopt
;
155 static const char *debugstr_guid(REFIID riid
)
159 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
160 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
161 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
162 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
167 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
170 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
171 return lstrcmpA(stra
, buf
);
174 static BSTR
a2bstr(const char *str
)
179 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
180 ret
= SysAllocStringLen(NULL
, len
);
181 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
186 static BOOL
init_key(const char *key_name
, const char *def_value
, BOOL init
)
192 RegDeleteKey(HKEY_CLASSES_ROOT
, key_name
);
196 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, key_name
, &hkey
);
197 if(res
!= ERROR_SUCCESS
)
201 res
= RegSetValueA(hkey
, NULL
, REG_SZ
, def_value
, strlen(def_value
));
205 return res
== ERROR_SUCCESS
;
208 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
209 REFIID riid
, void**ppv
)
211 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
216 return E_NOINTERFACE
;
219 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
224 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
229 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
231 if(dispID
== DISPID_READYSTATE
){
235 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
237 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
238 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
240 if(!lstrcmpW(state
, completeW
))
243 SysFreeString(state
);
249 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
251 ok(0, "unexpected call\n");
255 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
256 PropertyNotifySink_QueryInterface
,
257 PropertyNotifySink_AddRef
,
258 PropertyNotifySink_Release
,
259 PropertyNotifySink_OnChanged
,
260 PropertyNotifySink_OnRequestEdit
263 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
265 static HRESULT WINAPI
DispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
269 if(IsEqualGUID(riid
, &IID_IUnknown
)
270 || IsEqualGUID(riid
, &IID_IDispatch
)
271 || IsEqualGUID(riid
, &IID_IDispatchEx
))
274 return E_NOINTERFACE
;
279 static ULONG WINAPI
DispatchEx_AddRef(IDispatchEx
*iface
)
284 static ULONG WINAPI
DispatchEx_Release(IDispatchEx
*iface
)
289 static HRESULT WINAPI
DispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI
DispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
296 LCID lcid
, ITypeInfo
**ppTInfo
)
298 ok(0, "unexpected call\n");
302 static HRESULT WINAPI
DispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
303 LPOLESTR
*rgszNames
, UINT cNames
,
304 LCID lcid
, DISPID
*rgDispId
)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI
DispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
311 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
312 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
314 ok(0, "unexpected call\n");
318 static HRESULT WINAPI
DispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
320 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName
), grfdex
);
324 static HRESULT WINAPI
DispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
326 ok(0, "unexpected call\n");
330 static HRESULT WINAPI
DispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
332 ok(0, "unexpected call\n");
336 static HRESULT WINAPI
DispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
338 ok(0, "unexpected call\n");
342 static HRESULT WINAPI
DispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
344 ok(0, "unexpected call\n");
348 static HRESULT WINAPI
DispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
350 ok(0, "unexpected call\n");
354 static HRESULT WINAPI
DispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
356 ok(0, "unexpected call\n");
360 static HRESULT WINAPI
funcDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
361 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
363 CHECK_EXPECT(funcDisp
);
365 ok(id
== DISPID_VALUE
, "id = %d\n", id
);
366 ok(lcid
== 0, "lcid = %x\n", lcid
);
367 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
368 ok(pdp
!= NULL
, "pdp == NULL\n");
369 ok(pdp
->cArgs
== 2, "pdp->cArgs = %d\n", pdp
->cArgs
);
370 ok(pdp
->cNamedArgs
== 1, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
371 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_THIS
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
372 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
373 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(rgvarg[1]) = %d\n", V_VT(pdp
->rgvarg
));
374 ok(V_BOOL(pdp
->rgvarg
+1) == VARIANT_TRUE
, "V_BOOL(rgvarg[1]) = %x\n", V_BOOL(pdp
->rgvarg
));
375 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
376 ok(pei
!= NULL
, "pei == NULL\n");
377 ok(!pspCaller
, "pspCaller != NULL\n");
379 V_VT(pvarRes
) = VT_I4
;
384 static IDispatchExVtbl testObjVtbl
= {
385 DispatchEx_QueryInterface
,
388 DispatchEx_GetTypeInfoCount
,
389 DispatchEx_GetTypeInfo
,
390 DispatchEx_GetIDsOfNames
,
392 DispatchEx_GetDispID
,
394 DispatchEx_DeleteMemberByName
,
395 DispatchEx_DeleteMemberByDispID
,
396 DispatchEx_GetMemberProperties
,
397 DispatchEx_GetMemberName
,
398 DispatchEx_GetNextDispID
,
399 DispatchEx_GetNameSpaceParent
402 static IDispatchEx funcDisp
= { &testObjVtbl
};
404 static HRESULT WINAPI
scriptDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
406 if(!strcmp_wa(bstrName
, "testProp")) {
407 CHECK_EXPECT(script_testprop_d
);
408 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
409 *pid
= DISPID_SCRIPT_TESTPROP
;
413 if(!strcmp_wa(bstrName
, "testProp2")) {
414 CHECK_EXPECT(script_testprop2_d
);
415 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
416 *pid
= DISPID_SCRIPT_TESTPROP2
;
420 if(!strcmp_wa(bstrName
, "divid")) {
421 CHECK_EXPECT(script_divid_d
);
422 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI
scriptDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
431 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
434 case DISPID_SCRIPT_TESTPROP
:
435 CHECK_EXPECT(script_testprop_i
);
437 ok(lcid
== 0, "lcid = %x\n", lcid
);
438 ok(wFlags
== DISPATCH_PROPERTYGET
, "wFlags = %x\n", wFlags
);
439 ok(pdp
!= NULL
, "pdp == NULL\n");
440 ok(pdp
->cArgs
== 0, "pdp->cArgs = %d\n", pdp
->cArgs
);
441 ok(pdp
->cNamedArgs
== 0, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
442 ok(!pdp
->rgdispidNamedArgs
, "pdp->rgdispidNamedArgs != NULL\n");
443 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
444 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
445 ok(pei
!= NULL
, "pei == NULL\n");
446 ok(!pspCaller
, "pspCaller != NULL\n");
448 V_VT(pvarRes
) = VT_NULL
;
451 ok(0, "unexpected call\n");
458 static IDispatchExVtbl scriptDispVtbl
= {
459 DispatchEx_QueryInterface
,
462 DispatchEx_GetTypeInfoCount
,
463 DispatchEx_GetTypeInfo
,
464 DispatchEx_GetIDsOfNames
,
466 scriptDisp_GetDispID
,
468 DispatchEx_DeleteMemberByName
,
469 DispatchEx_DeleteMemberByDispID
,
470 DispatchEx_GetMemberProperties
,
471 DispatchEx_GetMemberName
,
472 DispatchEx_GetNextDispID
,
473 DispatchEx_GetNameSpaceParent
476 static IDispatchEx scriptDisp
= { &scriptDispVtbl
};
478 static HRESULT WINAPI
externalDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
480 if(!strcmp_wa(bstrName
, "ok")) {
481 *pid
= DISPID_EXTERNAL_OK
;
484 if(!strcmp_wa(bstrName
, "trace")) {
485 *pid
= DISPID_EXTERNAL_TRACE
;
488 if(!strcmp_wa(bstrName
, "reportSuccess")) {
489 *pid
= DISPID_EXTERNAL_REPORTSUCCESS
;
493 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName
));
494 return DISP_E_UNKNOWNNAME
;
497 static HRESULT WINAPI
externalDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
498 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
501 case DISPID_EXTERNAL_OK
:
502 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
503 ok(pdp
!= NULL
, "pdp == NULL\n");
504 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
505 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
506 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
507 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
508 ok(pei
!= NULL
, "pei == NULL\n");
510 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
511 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp
->rgvarg
));
512 ok(V_BOOL(pdp
->rgvarg
+1), "%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
516 case DISPID_EXTERNAL_TRACE
:
517 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
518 ok(pdp
!= NULL
, "pdp == NULL\n");
519 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
520 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
521 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
522 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
523 ok(!pvarRes
, "pvarRes != NULL\n");
524 ok(pei
!= NULL
, "pei == NULL\n");
526 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
527 if(V_VT(pdp
->rgvarg
) == VT_BSTR
)
528 trace("%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
532 case DISPID_EXTERNAL_REPORTSUCCESS
:
533 CHECK_EXPECT(external_success
);
535 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
536 ok(pdp
!= NULL
, "pdp == NULL\n");
537 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
538 ok(pdp
->cArgs
== 0, "cArgs = %d\n", pdp
->cArgs
);
539 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
540 ok(!pvarRes
, "pvarRes != NULL\n");
541 ok(pei
!= NULL
, "pei == NULL\n");
546 ok(0, "unexpected call\n");
553 static IDispatchExVtbl externalDispVtbl
= {
554 DispatchEx_QueryInterface
,
557 DispatchEx_GetTypeInfoCount
,
558 DispatchEx_GetTypeInfo
,
559 DispatchEx_GetIDsOfNames
,
561 externalDisp_GetDispID
,
562 externalDisp_InvokeEx
,
563 DispatchEx_DeleteMemberByName
,
564 DispatchEx_DeleteMemberByDispID
,
565 DispatchEx_GetMemberProperties
,
566 DispatchEx_GetMemberName
,
567 DispatchEx_GetNextDispID
,
568 DispatchEx_GetNameSpaceParent
571 static IDispatchEx externalDisp
= { &externalDispVtbl
};
573 static HRESULT
QueryInterface(REFIID
,void**);
575 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
, REFIID riid
, void **ppv
)
577 return QueryInterface(riid
, ppv
);
580 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
585 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
590 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
, DWORD dwID
, POINT
*ppt
,
591 IUnknown
*pcmdtReserved
, IDispatch
*pdicpReserved
)
596 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
, DOCHOSTUIINFO
*pInfo
)
601 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
602 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
603 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
608 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
613 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
618 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
, BOOL fEnable
)
623 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
628 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
633 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
, LPCRECT prcBorder
,
634 IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
639 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
, LPMSG lpMsg
,
640 const GUID
*pguidCmdGroup
, DWORD nCmdID
)
645 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
646 LPOLESTR
*pchKey
, DWORD dw
)
651 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
652 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
657 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
, IDispatch
**ppDispatch
)
659 *ppDispatch
= (IDispatch
*)&externalDisp
;
663 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
, DWORD dwTranslate
,
664 OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
669 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
, IDataObject
*pDO
,
670 IDataObject
**ppPORet
)
675 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
676 LPOLESTR
*pchKey
, DWORD dw
)
681 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl
= {
682 DocHostUIHandler_QueryInterface
,
683 DocHostUIHandler_AddRef
,
684 DocHostUIHandler_Release
,
685 DocHostUIHandler_ShowContextMenu
,
686 DocHostUIHandler_GetHostInfo
,
687 DocHostUIHandler_ShowUI
,
688 DocHostUIHandler_HideUI
,
689 DocHostUIHandler_UpdateUI
,
690 DocHostUIHandler_EnableModeless
,
691 DocHostUIHandler_OnDocWindowActivate
,
692 DocHostUIHandler_OnFrameWindowActivate
,
693 DocHostUIHandler_ResizeBorder
,
694 DocHostUIHandler_TranslateAccelerator
,
695 DocHostUIHandler_GetOptionKeyPath
,
696 DocHostUIHandler_GetDropTarget
,
697 DocHostUIHandler_GetExternal
,
698 DocHostUIHandler_TranslateUrl
,
699 DocHostUIHandler_FilterDataObject
,
700 DocHostUIHandler_GetOverrideKeyPath
703 static IDocHostUIHandler2 DocHostUIHandler
= { &DocHostUIHandlerVtbl
};
705 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
707 return E_NOINTERFACE
;
710 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
715 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
720 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
725 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
730 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
735 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
736 LPCBORDERWIDTHS pborderwidths
)
741 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
742 LPCBORDERWIDTHS pborderwidths
)
747 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
748 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
753 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
754 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
759 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
760 HOLEMENU holemenu
, HWND hwndActiveObject
)
762 ok(0, "unexpected call\n");
766 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
768 ok(0, "unexpected call\n");
772 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
777 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
782 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
784 ok(0, "unexpected call\n");
788 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
789 InPlaceFrame_QueryInterface
,
791 InPlaceFrame_Release
,
792 InPlaceFrame_GetWindow
,
793 InPlaceFrame_ContextSensitiveHelp
,
794 InPlaceFrame_GetBorder
,
795 InPlaceFrame_RequestBorderSpace
,
796 InPlaceFrame_SetBorderSpace
,
797 InPlaceFrame_SetActiveObject
,
798 InPlaceFrame_InsertMenus
,
799 InPlaceFrame_SetMenu
,
800 InPlaceFrame_RemoveMenus
,
801 InPlaceFrame_SetStatusText
,
802 InPlaceFrame_EnableModeless
,
803 InPlaceFrame_TranslateAccelerator
806 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
808 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
810 return QueryInterface(riid
, ppv
);
813 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
818 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
823 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
825 *phwnd
= container_hwnd
;
829 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
831 ok(0, "unexpected call\n");
835 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
840 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
845 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
850 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
851 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
852 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
854 static const RECT rect
= {0,0,300,300};
856 *ppFrame
= &InPlaceFrame
;
857 *ppDoc
= (IOleInPlaceUIWindow
*)&InPlaceFrame
;
859 *lprcClipRect
= rect
;
861 lpFrameInfo
->cb
= sizeof(*lpFrameInfo
);
862 lpFrameInfo
->fMDIApp
= FALSE
;
863 lpFrameInfo
->hwndFrame
= container_hwnd
;
864 lpFrameInfo
->haccel
= NULL
;
865 lpFrameInfo
->cAccelEntries
= 0;
870 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
875 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
880 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
885 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
890 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
895 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
900 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
901 InPlaceSite_QueryInterface
,
904 InPlaceSite_GetWindow
,
905 InPlaceSite_ContextSensitiveHelp
,
906 InPlaceSite_CanInPlaceActivate
,
907 InPlaceSite_OnInPlaceActivate
,
908 InPlaceSite_OnUIActivate
,
909 InPlaceSite_GetWindowContext
,
911 InPlaceSite_OnUIDeactivate
,
912 InPlaceSite_OnInPlaceDeactivate
,
913 InPlaceSite_DiscardUndoState
,
914 InPlaceSite_DeactivateAndUndo
,
915 InPlaceSite_OnPosRectChange
,
918 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
920 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
922 return QueryInterface(riid
, ppv
);
925 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
930 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
935 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
944 ok(0, "unexpected call\n");
948 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
953 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
955 ok(0, "unexpected call\n");
959 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
961 ok(0, "unexpected call\n");
965 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
967 ok(0, "unexpected call\n");
971 static const IOleClientSiteVtbl ClientSiteVtbl
= {
972 ClientSite_QueryInterface
,
975 ClientSite_SaveObject
,
976 ClientSite_GetMoniker
,
977 ClientSite_GetContainer
,
978 ClientSite_ShowObject
,
979 ClientSite_OnShowWindow
,
980 ClientSite_RequestNewObjectLayout
983 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
985 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
987 return QueryInterface(riid
, ppv
);
990 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
995 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
1000 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
1002 RECT rect
= {0,0,300,300};
1003 IOleDocument
*document
;
1006 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
1007 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
1009 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
1010 IOleDocument_Release(document
);
1011 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
1013 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
1014 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
1016 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
1017 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
1019 hres
= IOleDocumentView_SetRect(view
, &rect
);
1020 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
1022 hres
= IOleDocumentView_Show(view
, TRUE
);
1023 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
1028 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
1029 DocumentSite_QueryInterface
,
1030 DocumentSite_AddRef
,
1031 DocumentSite_Release
,
1032 DocumentSite_ActivateMe
1035 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
1037 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
1041 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
1043 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
1044 *ppv
= &DocumentSite
;
1045 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
1046 *ppv
= &InPlaceSite
;
1047 else if(IsEqualGUID(&IID_IDocHostUIHandler
, riid
) || IsEqualGUID(&IID_IDocHostUIHandler2
, riid
))
1048 *ppv
= &DocHostUIHandler
;
1050 return *ppv
? S_OK
: E_NOINTERFACE
;
1053 static IHTMLDocument2
*create_document(void)
1055 IHTMLDocument2
*doc
;
1056 IHTMLDocument5
*doc5
;
1059 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1060 &IID_IHTMLDocument2
, (void**)&doc
);
1061 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1062 if (hres
!= S_OK
) return NULL
;
1064 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
1066 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
1067 IHTMLDocument2_Release(doc
);
1071 IHTMLDocument5_Release(doc5
);
1075 static void load_string(IHTMLDocument2
*doc
, const char *str
)
1077 IPersistStreamInit
*init
;
1082 doc_complete
= FALSE
;
1084 mem
= GlobalAlloc(0, len
);
1085 memcpy(mem
, str
, len
);
1086 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1088 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1090 IPersistStreamInit_Load(init
, stream
);
1091 IPersistStreamInit_Release(init
);
1092 IStream_Release(stream
);
1095 static void do_advise(IHTMLDocument2
*doc
, REFIID riid
, IUnknown
*unk_advise
)
1097 IConnectionPointContainer
*container
;
1098 IConnectionPoint
*cp
;
1102 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&container
);
1103 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1105 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1106 IConnectionPointContainer_Release(container
);
1107 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1111 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1112 IConnectionPoint_Release(cp
);
1113 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1116 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
1122 IOleDocumentView_Show(view
, FALSE
);
1123 IOleDocumentView_CloseView(view
, 0);
1124 IOleDocumentView_SetInPlaceSite(view
, NULL
);
1125 IOleDocumentView_Release(view
);
1129 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
1130 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
1132 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
1133 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
1136 IHlinkTarget
*hlink
;
1138 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
1139 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
1141 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
1142 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
1144 IHlinkTarget_Release(hlink
);
1147 IOleObject_Release(oleobj
);
1150 typedef void (*domtest_t
)(IHTMLDocument2
*);
1152 static void load_doc(IHTMLDocument2
*doc
, const char *str
)
1154 IHTMLElement
*body
= NULL
;
1157 static const WCHAR ucPtr
[] = {'b','a','c','k','g','r','o','u','n','d',0};
1161 load_string(doc
, str
);
1162 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1164 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
1165 TranslateMessage(&msg
);
1166 DispatchMessage(&msg
);
1169 hres
= IHTMLDocument2_get_body(doc
, &body
);
1170 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1172 /* Check we can query for function on the IHTMLElementBody interface */
1173 name
= (WCHAR
*)ucPtr
;
1174 hres
= IHTMLElement_GetIDsOfNames(body
, &IID_NULL
, &name
, 1, LOCALE_USER_DEFAULT
, &dispID
);
1175 ok(hres
== S_OK
, "GetIDsOfNames(background) failed %08x\n", hres
);
1176 ok(dispID
== DISPID_IHTMLBODYELEMENT_BACKGROUND
, "Incorrect dispID got (%d)\n", dispID
);
1178 IHTMLElement_Release(body
);
1181 static IActiveScriptSite
*site
;
1182 static SCRIPTSTATE state
;
1184 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1187 ok(0, "unexpected call %s\n", debugstr_guid(riid
));
1188 return E_NOINTERFACE
;
1191 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1196 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1201 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1202 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1204 CHECK_EXPECT(GetInterfaceSafetyOptions
);
1206 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1207 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1208 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1210 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1211 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1216 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1217 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1219 CHECK_EXPECT(SetInterfaceSafetyOptions
);
1221 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1223 ok(dwOptionSetMask
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1224 "dwOptionSetMask=%x\n", dwOptionSetMask
);
1225 ok(dwEnabledOptions
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1226 "dwEnabledOptions=%x\n", dwOptionSetMask
);
1231 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1232 ObjectSafety_QueryInterface
,
1233 ObjectSafety_AddRef
,
1234 ObjectSafety_Release
,
1235 ObjectSafety_GetInterfaceSafetyOptions
,
1236 ObjectSafety_SetInterfaceSafetyOptions
1239 static IObjectSafety ObjectSafety
= { &ObjectSafetyVtbl
};
1241 static HRESULT WINAPI
AXObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1245 if(IsEqualGUID(&IID_IActiveScript
, riid
)) {
1246 CHECK_EXPECT(AXQueryInterface_IActiveScript
);
1247 return E_NOINTERFACE
;
1250 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1251 CHECK_EXPECT(AXQueryInterface_IObjectSafety
);
1253 return E_NOINTERFACE
;
1258 ok(0, "unexpected call %s\n", debugstr_guid(riid
));
1259 return E_NOINTERFACE
;
1262 static HRESULT WINAPI
AXObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1263 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1265 CHECK_EXPECT(AXGetInterfaceSafetyOptions
);
1267 ok(IsEqualGUID(&IID_IDispatchEx
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1268 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1269 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1271 if(SUCCEEDED(ax_getopt_hres
)) {
1272 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1273 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1276 return ax_getopt_hres
;
1279 static HRESULT WINAPI
AXObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1280 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1282 if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1283 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1284 ok(dwOptionSetMask
== ax_setopt
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, ax_setopt
);
1285 ok(dwEnabledOptions
== ax_setopt
, "dwEnabledOptions=%x, expected %x\n", dwOptionSetMask
, ax_setopt
);
1286 return ax_setopt_dispex_hres
;
1289 if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1290 DWORD exopt
= ax_setopt
& ~INTERFACE_USES_SECURITY_MANAGER
;
1292 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatch
);
1293 ok(dwOptionSetMask
== exopt
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, exopt
);
1294 ok(dwEnabledOptions
== exopt
, "dwEnabledOptions=%x, expected %x\n", dwOptionSetMask
, exopt
);
1295 return ax_setopt_disp_hres
;
1298 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1299 return E_NOINTERFACE
;
1302 static const IObjectSafetyVtbl AXObjectSafetyVtbl
= {
1303 AXObjectSafety_QueryInterface
,
1304 ObjectSafety_AddRef
,
1305 ObjectSafety_Release
,
1306 AXObjectSafety_GetInterfaceSafetyOptions
,
1307 AXObjectSafety_SetInterfaceSafetyOptions
1310 static IObjectSafety AXObjectSafety
= { &AXObjectSafetyVtbl
};
1312 static BOOL
set_safe_reg(BOOL init
)
1314 return init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
1318 static void test_security(void)
1320 IInternetHostSecurityManager
*sec_mgr
;
1321 IServiceProvider
*sp
;
1322 DWORD policy
, policy_size
;
1323 struct CONFIRMSAFETY cs
;
1327 ax_setopt
= INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACE_USES_SECURITY_MANAGER
;
1329 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IServiceProvider
, (void**)&sp
);
1330 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
1332 hres
= IServiceProvider_QueryService(sp
, &SID_SInternetHostSecurityManager
,
1333 &IID_IInternetHostSecurityManager
, (void**)&sec_mgr
);
1334 IServiceProvider_Release(sp
);
1335 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1337 hres
= IInternetHostSecurityManager_ProcessUrlAction(sec_mgr
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
),
1338 (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
1339 ok(hres
== S_OK
, "ProcessUrlAction failed: %08x\n", hres
);
1340 ok(policy
== URLPOLICY_ALLOW
, "policy = %x\n", policy
);
1342 cs
.clsid
= CLSID_TestActiveX
;
1343 cs
.pUnk
= (IUnknown
*)&AXObjectSafety
;
1347 SET_EXPECT(AXQueryInterface_IActiveScript
);
1348 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1349 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1350 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1351 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1352 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1353 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1354 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1355 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1356 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx
);
1358 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1359 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1360 ok(*(DWORD
*)ppolicy
== URLPOLICY_ALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1361 CoTaskMemFree(ppolicy
);
1364 SET_EXPECT(AXQueryInterface_IActiveScript
);
1365 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1366 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1367 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1368 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1369 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1371 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1372 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1373 ok(*(DWORD
*)ppolicy
== URLPOLICY_DISALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1374 CoTaskMemFree(ppolicy
);
1376 if(set_safe_reg(TRUE
)) {
1378 SET_EXPECT(AXQueryInterface_IActiveScript
);
1379 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1380 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1381 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1382 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1383 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1385 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1386 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1387 ok(*(DWORD
*)ppolicy
== URLPOLICY_ALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1388 CoTaskMemFree(ppolicy
);
1391 SET_EXPECT(AXQueryInterface_IActiveScript
);
1392 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1393 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1394 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1395 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1396 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1397 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1398 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1399 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1400 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx
);
1402 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1403 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1404 ok(*(DWORD
*)ppolicy
== URLPOLICY_ALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1405 CoTaskMemFree(ppolicy
);
1407 set_safe_reg(FALSE
);
1409 skip("Could not set safety registry\n");
1414 ax_setopt_dispex_hres
= E_NOINTERFACE
;
1415 SET_EXPECT(AXQueryInterface_IActiveScript
);
1416 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1417 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1418 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1419 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch
);
1420 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1421 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1422 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1423 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1424 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1425 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx
);
1426 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch
);
1428 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1429 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1430 ok(*(DWORD
*)ppolicy
== URLPOLICY_ALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1431 CoTaskMemFree(ppolicy
);
1433 ax_setopt_dispex_hres
= E_FAIL
;
1434 ax_setopt_disp_hres
= E_NOINTERFACE
;
1435 SET_EXPECT(AXQueryInterface_IActiveScript
);
1436 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1437 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1438 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1439 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch
);
1440 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1441 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1442 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1443 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1444 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1445 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx
);
1446 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch
);
1448 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1449 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1450 ok(*(DWORD
*)ppolicy
== URLPOLICY_DISALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1451 CoTaskMemFree(ppolicy
);
1453 ax_setopt_dispex_hres
= E_FAIL
;
1454 ax_setopt_disp_hres
= S_OK
;
1455 ax_getopt_hres
= E_NOINTERFACE
;
1456 ax_setopt
= INTERFACESAFE_FOR_UNTRUSTED_CALLER
;
1457 SET_EXPECT(AXQueryInterface_IActiveScript
);
1458 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1459 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1460 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx
);
1461 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch
);
1462 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1463 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1464 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1465 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1466 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1467 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx
);
1468 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch
);
1470 ok(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1471 ok(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1472 ok(*(DWORD
*)ppolicy
== URLPOLICY_ALLOW
, "policy = %x\n", *(DWORD
*)ppolicy
);
1473 CoTaskMemFree(ppolicy
);
1475 IInternetHostSecurityManager_Release(sec_mgr
);
1478 static HRESULT WINAPI
ActiveScriptProperty_QueryInterface(IActiveScriptProperty
*iface
, REFIID riid
, void **ppv
)
1481 ok(0, "unexpected call\n");
1482 return E_NOINTERFACE
;
1485 static ULONG WINAPI
ActiveScriptProperty_AddRef(IActiveScriptProperty
*iface
)
1490 static ULONG WINAPI
ActiveScriptProperty_Release(IActiveScriptProperty
*iface
)
1495 static HRESULT WINAPI
ActiveScriptProperty_GetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1496 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1498 ok(0, "unexpected call\n");
1502 static HRESULT WINAPI
ActiveScriptProperty_SetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1503 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1505 switch(dwProperty
) {
1506 case SCRIPTPROP_HACK_TRIDENTEVENTSINK
:
1507 CHECK_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
1508 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1509 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1511 case SCRIPTPROP_INVOKEVERSIONING
:
1512 CHECK_EXPECT(SetProperty_INVOKEVERSIONING
);
1513 ok(V_VT(pvarValue
) == VT_I4
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1514 ok(V_I4(pvarValue
) == 1, "V_I4(pvarValue)=%d\n", V_I4(pvarValue
));
1516 case SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION
:
1517 CHECK_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
);
1518 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1519 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1522 ok(0, "unexpected property %x\n", dwProperty
);
1526 ok(!pvarIndex
, "pvarIndex != NULL\n");
1527 ok(pvarValue
!= NULL
, "pvarValue == NULL\n");
1532 static const IActiveScriptPropertyVtbl ActiveScriptPropertyVtbl
= {
1533 ActiveScriptProperty_QueryInterface
,
1534 ActiveScriptProperty_AddRef
,
1535 ActiveScriptProperty_Release
,
1536 ActiveScriptProperty_GetProperty
,
1537 ActiveScriptProperty_SetProperty
1540 static IActiveScriptProperty ActiveScriptProperty
= { &ActiveScriptPropertyVtbl
};
1542 static HRESULT WINAPI
ActiveScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2
*iface
, REFIID riid
, void **ppv
)
1545 ok(0, "unexpected call\n");
1546 return E_NOINTERFACE
;
1549 static ULONG WINAPI
ActiveScriptParseProcedure_AddRef(IActiveScriptParseProcedure2
*iface
)
1554 static ULONG WINAPI
ActiveScriptParseProcedure_Release(IActiveScriptParseProcedure2
*iface
)
1559 static HRESULT WINAPI
ActiveScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2
*iface
,
1560 LPCOLESTR pstrCode
, LPCOLESTR pstrFormalParams
, LPCOLESTR pstrProcedureName
,
1561 LPCOLESTR pstrItemName
, IUnknown
*punkContext
, LPCOLESTR pstrDelimiter
,
1562 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
, IDispatch
**ppdisp
)
1564 ok(0, "unexpected call\n");
1568 static const IActiveScriptParseProcedure2Vtbl ActiveScriptParseProcedureVtbl
= {
1569 ActiveScriptParseProcedure_QueryInterface
,
1570 ActiveScriptParseProcedure_AddRef
,
1571 ActiveScriptParseProcedure_Release
,
1572 ActiveScriptParseProcedure_ParseProcedureText
1575 static IActiveScriptParseProcedure2 ActiveScriptParseProcedure
= { &ActiveScriptParseProcedureVtbl
};
1577 static HRESULT WINAPI
ActiveScriptParse_QueryInterface(IActiveScriptParse
*iface
, REFIID riid
, void **ppv
)
1580 ok(0, "unexpected call\n");
1581 return E_NOINTERFACE
;
1584 static ULONG WINAPI
ActiveScriptParse_AddRef(IActiveScriptParse
*iface
)
1589 static ULONG WINAPI
ActiveScriptParse_Release(IActiveScriptParse
*iface
)
1594 static HRESULT WINAPI
ActiveScriptParse_InitNew(IActiveScriptParse
*iface
)
1596 CHECK_EXPECT(InitNew
);
1600 static HRESULT WINAPI
ActiveScriptParse_AddScriptlet(IActiveScriptParse
*iface
,
1601 LPCOLESTR pstrDefaultName
, LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
,
1602 LPCOLESTR pstrSubItemName
, LPCOLESTR pstrEventName
, LPCOLESTR pstrDelimiter
,
1603 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
,
1604 BSTR
*pbstrName
, EXCEPINFO
*pexcepinfo
)
1606 ok(0, "unexpected call\n");
1610 static HRESULT
dispex_propput(IDispatchEx
*obj
, DISPID id
, DWORD flags
, VARIANT
*var
)
1612 DISPID propput_arg
= DISPID_PROPERTYPUT
;
1613 DISPPARAMS dp
= {var
, &propput_arg
, 1, 1};
1616 return IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYPUT
|flags
, &dp
, NULL
, &ei
, NULL
);
1619 static void test_func(IDispatchEx
*obj
)
1622 IDispatchEx
*dispex
;
1630 str
= a2bstr("toString");
1631 hres
= IDispatchEx_GetDispID(obj
, str
, fdexNameCaseSensitive
, &id
);
1633 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1634 ok(id
== DISPID_IOMNAVIGATOR_TOSTRING
, "id = %x\n", id
);
1636 memset(&dp
, 0, sizeof(dp
));
1637 memset(&ei
, 0, sizeof(ei
));
1639 hres
= IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1640 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1641 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
1642 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
1643 disp
= V_DISPATCH(&var
);
1645 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
1646 IDispatch_Release(disp
);
1647 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
1649 /* FIXME: Test InvokeEx(DISPATCH_METHOD) */
1651 memset(&dp
, 0, sizeof(dp
));
1652 memset(&ei
, 0, sizeof(ei
));
1654 hres
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, LOCALE_NEUTRAL
, DISPATCH_METHOD
, &dp
, &var
, &ei
, NULL
);
1655 ok(hres
== S_OK
|| broken(E_ACCESSDENIED
), "InvokeEx failed: %08x\n", hres
);
1656 if(SUCCEEDED(hres
)) {
1657 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
1658 ok(!strcmp_wa(V_BSTR(&var
), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
1664 hres
= dispex_propput(obj
, id
, 0, &var
);
1665 ok(hres
== E_NOTIMPL
, "InvokeEx failed: %08x\n", hres
);
1667 IDispatchEx_Release(dispex
);
1670 static void test_nextdispid(IDispatchEx
*dispex
)
1672 DISPID last_id
= DISPID_STARTENUM
, id
, dyn_id
;
1677 name
= a2bstr("dynVal");
1678 hres
= IDispatchEx_GetDispID(dispex
, name
, fdexNameCaseSensitive
|fdexNameEnsure
, &dyn_id
);
1679 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1680 SysFreeString(name
);
1682 V_VT(&var
) = VT_EMPTY
;
1683 hres
= dispex_propput(dispex
, dyn_id
, 0, &var
);
1685 while(last_id
!= dyn_id
) {
1686 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, last_id
, &id
);
1687 ok(hres
== S_OK
, "GetNextDispID returned: %08x\n", hres
);
1688 ok(id
!= DISPID_STARTENUM
, "id == DISPID_STARTENUM\n");
1689 ok(id
!= DISPID_IOMNAVIGATOR_TOSTRING
, "id == DISPID_IOMNAVIGATOR_TOSTRING\n");
1691 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
1692 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
1695 ok(!strcmp_wa(name
, "dynVal"), "name = %s\n", wine_dbgstr_w(name
));
1696 else if(id
== DISPID_IOMNAVIGATOR_PLATFORM
)
1697 ok(!strcmp_wa(name
, "platform"), "name = %s\n", wine_dbgstr_w(name
));
1699 SysFreeString(name
);
1703 hres
= IDispatchEx_GetNextDispID(dispex
, 0, id
, &id
);
1704 ok(hres
== S_FALSE
, "GetNextDispID returned: %08x\n", hres
);
1705 ok(id
== DISPID_STARTENUM
, "id != DISPID_STARTENUM\n");
1708 static void test_global_id(void)
1717 SET_EXPECT(GetScriptDispatch
);
1718 SET_EXPECT(script_divid_d
);
1719 tmp
= a2bstr("divid");
1720 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
1721 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1723 CHECK_CALLED(GetScriptDispatch
);
1724 CHECK_CALLED(script_divid_d
);
1727 memset(&ei
, 0, sizeof(ei
));
1728 memset(&dp
, 0, sizeof(dp
));
1729 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1730 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1731 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var) = %d\n", V_VT(&var
));
1735 static HRESULT WINAPI
ActiveScriptParse_ParseScriptText(IActiveScriptParse
*iface
,
1736 LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
, IUnknown
*punkContext
,
1737 LPCOLESTR pstrDelimiter
, CTXARG_T dwSourceContextCookie
, ULONG ulStartingLine
,
1738 DWORD dwFlags
, VARIANT
*pvarResult
, EXCEPINFO
*pexcepinfo
)
1740 IDispatchEx
*document
, *dispex
;
1741 IHTMLWindow2
*window
;
1742 IOmNavigator
*navigator
;
1751 static const WCHAR documentW
[] = {'d','o','c','u','m','e','n','t',0};
1752 static const WCHAR testW
[] = {'t','e','s','t',0};
1753 static const WCHAR funcW
[] = {'f','u','n','c',0};
1755 CHECK_EXPECT(ParseScriptText
);
1757 SET_EXPECT(GetScriptDispatch
);
1759 tmp
= SysAllocString(documentW
);
1760 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
1762 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
1763 ok(id
== DISPID_IHTMLWINDOW2_DOCUMENT
, "id=%x\n", id
);
1765 CHECK_CALLED(GetScriptDispatch
);
1768 memset(&dp
, 0, sizeof(dp
));
1769 memset(&ei
, 0, sizeof(ei
));
1771 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1772 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1773 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
1774 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(&var) == NULL\n");
1776 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IDispatchEx
, (void**)&document
);
1778 ok(hres
== S_OK
, "Could not get DispatchEx: %08x\n", hres
);
1780 tmp
= SysAllocString(testW
);
1781 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
1782 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
1783 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
| fdexNameImplicit
, &id
);
1784 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
1788 tmp
= SysAllocString(testW
);
1789 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
1791 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
1792 ok(id
, "id == 0\n");
1796 hres
= dispex_propput(document
, id
, 0, &var
);
1797 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1799 tmp
= SysAllocString(testW
);
1800 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
1802 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
1805 memset(&dp
, 0, sizeof(dp
));
1806 memset(&ei
, 0, sizeof(ei
));
1807 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1808 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1809 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
1810 ok(V_I4(&var
) == 100, "V_I4(&var) = %d\n", V_I4(&var
));
1814 hres
= dispex_propput(document
, id
, DISPATCH_PROPERTYPUTREF
, &var
);
1815 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1818 memset(&dp
, 0, sizeof(dp
));
1819 memset(&ei
, 0, sizeof(ei
));
1820 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1821 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1822 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
1823 ok(V_I4(&var
) == 200, "V_I4(&var) = %d\n", V_I4(&var
));
1825 memset(&dp
, 0, sizeof(dp
));
1826 memset(&ei
, 0, sizeof(ei
));
1831 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
1832 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1835 memset(&dp
, 0, sizeof(dp
));
1836 memset(&ei
, 0, sizeof(ei
));
1837 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1838 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1839 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
1840 ok(V_I4(&var
) == 300, "V_I4(&var) = %d\n", V_I4(&var
));
1842 unk
= (void*)0xdeadbeef;
1843 hres
= IDispatchEx_GetNameSpaceParent(window_dispex
, &unk
);
1844 ok(hres
== S_OK
, "GetNameSpaceParent failed: %08x\n", hres
);
1845 ok(!unk
, "unk=%p, expected NULL\n", unk
);
1848 tmp
= SysAllocString(funcW
);
1849 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
1851 ok(hres
== S_OK
, "GetDispID(func) failed: %08x\n", hres
);
1852 ok(id
, "id == 0\n");
1857 dp
.rgdispidNamedArgs
= NULL
;
1858 V_VT(&var
) = VT_DISPATCH
;
1859 V_DISPATCH(&var
) = (IDispatch
*)&funcDisp
;
1860 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
1861 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1864 memset(&dp
, 0, sizeof(dp
));
1865 memset(&ei
, 0, sizeof(ei
));
1866 V_VT(&arg
) = VT_BOOL
;
1867 V_BOOL(&arg
) = VARIANT_TRUE
;
1871 SET_EXPECT(funcDisp
);
1872 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_FUNC
, &dp
, &var
, &ei
, NULL
);
1873 CHECK_CALLED(funcDisp
);
1875 ok(hres
== S_OK
, "InvokeEx(INVOKE_FUNC) failed: %08x\n", hres
);
1876 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
1877 ok(V_I4(&var
) == 100, "V_I4(&var) == NULL\n");
1879 IDispatchEx_Release(document
);
1881 hres
= IDispatchEx_QueryInterface(window_dispex
, &IID_IHTMLWindow2
, (void**)&window
);
1882 ok(hres
== S_OK
, "Could not get IHTMLWindow2 iface: %08x\n", hres
);
1884 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
1885 IHTMLWindow2_Release(window
);
1886 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1888 hres
= IOmNavigator_QueryInterface(navigator
, &IID_IDispatchEx
, (void**)&dispex
);
1889 IOmNavigator_Release(navigator
);
1890 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
1893 test_nextdispid(dispex
);
1895 tmp
= a2bstr("test");
1896 hres
= IDispatchEx_DeleteMemberByName(dispex
, tmp
, fdexNameCaseSensitive
);
1897 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
1899 IDispatchEx_Release(dispex
);
1901 script_disp
= (IDispatch
*)&scriptDisp
;
1903 SET_EXPECT(GetScriptDispatch
);
1904 SET_EXPECT(script_testprop_d
);
1905 tmp
= a2bstr("testProp");
1906 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
1907 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1908 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
1909 CHECK_CALLED(GetScriptDispatch
);
1910 CHECK_CALLED(script_testprop_d
);
1913 tmp
= a2bstr("testProp");
1914 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
1915 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1916 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
1919 SET_EXPECT(GetScriptDispatch
);
1920 SET_EXPECT(script_testprop_i
);
1921 memset(&ei
, 0, sizeof(ei
));
1922 memset(&dp
, 0, sizeof(dp
));
1923 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1924 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1925 ok(V_VT(&var
) == VT_NULL
, "V_VT(var) = %d\n", V_VT(&var
));
1926 CHECK_CALLED(GetScriptDispatch
);
1927 CHECK_CALLED(script_testprop_i
);
1929 SET_EXPECT(GetScriptDispatch
);
1930 SET_EXPECT(script_testprop2_d
);
1931 tmp
= a2bstr("testProp2");
1932 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
1933 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1934 ok(id
!= DISPID_SCRIPT_TESTPROP2
, "id == DISPID_SCRIPT_TESTPROP2\n");
1935 CHECK_CALLED(GetScriptDispatch
);
1936 CHECK_CALLED(script_testprop2_d
);
1939 tmp
= a2bstr("test");
1940 hres
= IDispatchEx_DeleteMemberByName(window_dispex
, tmp
, fdexNameCaseSensitive
);
1941 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
1950 static const IActiveScriptParseVtbl ActiveScriptParseVtbl
= {
1951 ActiveScriptParse_QueryInterface
,
1952 ActiveScriptParse_AddRef
,
1953 ActiveScriptParse_Release
,
1954 ActiveScriptParse_InitNew
,
1955 ActiveScriptParse_AddScriptlet
,
1956 ActiveScriptParse_ParseScriptText
1959 static IActiveScriptParse ActiveScriptParse
= { &ActiveScriptParseVtbl
};
1961 static HRESULT WINAPI
ActiveScript_QueryInterface(IActiveScript
*iface
, REFIID riid
, void **ppv
)
1965 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IActiveScript
, riid
)) {
1970 if(IsEqualGUID(&IID_IActiveScriptParse
, riid
)) {
1971 *ppv
= &ActiveScriptParse
;
1975 if(IsEqualGUID(&IID_IActiveScriptParseProcedure2
, riid
)) {
1976 *ppv
= &ActiveScriptParseProcedure
;
1980 if(IsEqualGUID(&IID_IActiveScriptProperty
, riid
)) {
1981 *ppv
= &ActiveScriptProperty
;
1985 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1986 *ppv
= &ObjectSafety
;
1990 if(IsEqualGUID(&IID_IActiveScriptDebug
, riid
))
1991 return E_NOINTERFACE
;
1993 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1994 return E_NOINTERFACE
;
1997 static ULONG WINAPI
ActiveScript_AddRef(IActiveScript
*iface
)
2002 static ULONG WINAPI
ActiveScript_Release(IActiveScript
*iface
)
2007 static HRESULT WINAPI
ActiveScript_SetScriptSite(IActiveScript
*iface
, IActiveScriptSite
*pass
)
2009 IActiveScriptSiteInterruptPoll
*poll
;
2010 IActiveScriptSiteDebug
*debug
;
2011 IServiceProvider
*service
;
2012 ICanHandleException
*canexpection
;
2016 CHECK_EXPECT(SetScriptSite
);
2018 ok(pass
!= NULL
, "pass == NULL\n");
2020 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteInterruptPoll
, (void**)&poll
);
2021 ok(hres
== S_OK
, "Could not get IActiveScriptSiteInterruptPoll interface: %08x\n", hres
);
2023 IActiveScriptSiteInterruptPoll_Release(poll
);
2025 hres
= IActiveScriptSite_GetLCID(pass
, &lcid
);
2026 ok(hres
== S_OK
, "GetLCID failed: %08x\n", hres
);
2028 hres
= IActiveScriptSite_OnStateChange(pass
, (state
= SCRIPTSTATE_INITIALIZED
));
2029 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2031 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteDebug
, (void**)&debug
);
2032 ok(hres
== S_OK
, "Could not get IActiveScriptSiteDebug interface: %08x\n", hres
);
2034 IActiveScriptSiteDebug32_Release(debug
);
2036 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_ICanHandleException
, (void**)&canexpection
);
2037 ok(hres
== E_NOINTERFACE
, "Could not get IID_ICanHandleException interface: %08x\n", hres
);
2039 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IServiceProvider
, (void**)&service
);
2040 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
2042 IServiceProvider_Release(service
);
2045 IActiveScriptSite_AddRef(site
);
2049 static HRESULT WINAPI
ActiveScript_GetScriptSite(IActiveScript
*iface
, REFIID riid
,
2052 ok(0, "unexpected call\n");
2056 static HRESULT WINAPI
ActiveScript_SetScriptState(IActiveScript
*iface
, SCRIPTSTATE ss
)
2061 case SCRIPTSTATE_STARTED
:
2062 CHECK_EXPECT(SetScriptState_STARTED
);
2064 case SCRIPTSTATE_CONNECTED
:
2065 CHECK_EXPECT(SetScriptState_CONNECTED
);
2067 case SCRIPTSTATE_DISCONNECTED
:
2068 CHECK_EXPECT(SetScriptState_DISCONNECTED
);
2071 ok(0, "unexpected state %d\n", ss
);
2075 hres
= IActiveScriptSite_OnStateChange(site
, (state
= ss
));
2076 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2081 static HRESULT WINAPI
ActiveScript_GetScriptState(IActiveScript
*iface
, SCRIPTSTATE
*pssState
)
2083 CHECK_EXPECT(GetScriptState
);
2089 static HRESULT WINAPI
ActiveScript_Close(IActiveScript
*iface
)
2091 CHECK_EXPECT(Close
);
2095 static HRESULT WINAPI
ActiveScript_AddNamedItem(IActiveScript
*iface
,
2096 LPCOLESTR pstrName
, DWORD dwFlags
)
2099 IUnknown
*unk
= NULL
, *unk2
;
2102 static const WCHAR windowW
[] = {'w','i','n','d','o','w',0};
2104 static const IID unknown_iid
= {0x719C3050,0xF9D3,0x11CF,{0xA4,0x93,0x00,0x40,0x05,0x23,0xA8,0xA0}};
2106 CHECK_EXPECT(AddNamedItem
);
2108 ok(!lstrcmpW(pstrName
, windowW
), "pstrName=%s\n", wine_dbgstr_w(pstrName
));
2109 ok(dwFlags
== (SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
), "dwFlags=%x\n", dwFlags
);
2111 hres
= IActiveScriptSite_GetItemInfo(site
, windowW
, SCRIPTINFO_IUNKNOWN
, &unk
, NULL
);
2112 ok(hres
== S_OK
, "GetItemInfo failed: %08x\n", hres
);
2113 ok(unk
!= NULL
, "unk == NULL\n");
2115 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
2116 ok(hres
== S_OK
, "Could not get IDispatch interface: %08x\n", hres
);
2118 IDispatch_Release(disp
);
2120 hres
= IUnknown_QueryInterface(unk
, &unknown_iid
, (void**)&unk2
);
2121 ok(hres
== E_NOINTERFACE
, "Got ?? interface: %p\n", unk2
);
2123 IUnknown_Release(unk2
);
2125 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&window_dispex
);
2126 ok(hres
== S_OK
, "Could not get IDispatchEx interface: %08x\n", hres
);
2128 IUnknown_Release(unk
);
2132 static HRESULT WINAPI
ActiveScript_AddTypeLib(IActiveScript
*iface
, REFGUID rguidTypeLib
,
2133 DWORD dwMajor
, DWORD dwMinor
, DWORD dwFlags
)
2135 ok(0, "unexpected call\n");
2139 static HRESULT WINAPI
ActiveScript_GetScriptDispatch(IActiveScript
*iface
, LPCOLESTR pstrItemName
,
2142 CHECK_EXPECT(GetScriptDispatch
);
2144 ok(!strcmp_wa(pstrItemName
, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2149 *ppdisp
= script_disp
;
2153 static HRESULT WINAPI
ActiveScript_GetCurrentScriptThreadID(IActiveScript
*iface
,
2154 SCRIPTTHREADID
*pstridThread
)
2156 ok(0, "unexpected call\n");
2160 static HRESULT WINAPI
ActiveScript_GetScriptThreadID(IActiveScript
*iface
,
2161 DWORD dwWin32ThreadId
, SCRIPTTHREADID
*pstidThread
)
2163 ok(0, "unexpected call\n");
2167 static HRESULT WINAPI
ActiveScript_GetScriptThreadState(IActiveScript
*iface
,
2168 SCRIPTTHREADID stidThread
, SCRIPTTHREADSTATE
*pstsState
)
2170 ok(0, "unexpected call\n");
2174 static HRESULT WINAPI
ActiveScript_InterruptScriptThread(IActiveScript
*iface
,
2175 SCRIPTTHREADID stidThread
, const EXCEPINFO
*pexcepinfo
, DWORD dwFlags
)
2177 ok(0, "unexpected call\n");
2181 static HRESULT WINAPI
ActiveScript_Clone(IActiveScript
*iface
, IActiveScript
**ppscript
)
2183 ok(0, "unexpected call\n");
2187 static const IActiveScriptVtbl ActiveScriptVtbl
= {
2188 ActiveScript_QueryInterface
,
2189 ActiveScript_AddRef
,
2190 ActiveScript_Release
,
2191 ActiveScript_SetScriptSite
,
2192 ActiveScript_GetScriptSite
,
2193 ActiveScript_SetScriptState
,
2194 ActiveScript_GetScriptState
,
2196 ActiveScript_AddNamedItem
,
2197 ActiveScript_AddTypeLib
,
2198 ActiveScript_GetScriptDispatch
,
2199 ActiveScript_GetCurrentScriptThreadID
,
2200 ActiveScript_GetScriptThreadID
,
2201 ActiveScript_GetScriptThreadState
,
2202 ActiveScript_InterruptScriptThread
,
2206 static IActiveScript ActiveScript
= { &ActiveScriptVtbl
};
2208 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2212 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
2217 if(IsEqualGUID(&IID_IMarshal
, riid
))
2218 return E_NOINTERFACE
;
2219 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
2220 return E_NOINTERFACE
;
2222 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
2226 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
2231 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
2236 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2238 CHECK_EXPECT(CreateInstance
);
2240 ok(!outer
, "outer = %p\n", outer
);
2241 ok(IsEqualGUID(&IID_IActiveScript
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
2242 *ppv
= &ActiveScript
;
2246 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
2248 ok(0, "unexpected call\n");
2252 static const IClassFactoryVtbl ClassFactoryVtbl
= {
2253 ClassFactory_QueryInterface
,
2254 ClassFactory_AddRef
,
2255 ClassFactory_Release
,
2256 ClassFactory_CreateInstance
,
2257 ClassFactory_LockServer
2260 static IClassFactory script_cf
= { &ClassFactoryVtbl
};
2262 static const char simple_script_str
[] =
2263 "<html><head></head><body>"
2264 "<div id=\"divid\"></div>"
2265 "<script language=\"TestScript\">simple script</script>"
2268 static void test_simple_script(void)
2270 IHTMLDocument2
*doc
;
2272 doc
= create_document();
2276 SET_EXPECT(CreateInstance
);
2277 SET_EXPECT(GetInterfaceSafetyOptions
);
2278 SET_EXPECT(SetInterfaceSafetyOptions
);
2279 SET_EXPECT(SetProperty_INVOKEVERSIONING
); /* IE8 */
2280 SET_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
2281 SET_EXPECT(InitNew
);
2282 SET_EXPECT(SetScriptSite
);
2283 SET_EXPECT(GetScriptState
);
2284 SET_EXPECT(SetScriptState_STARTED
);
2285 SET_EXPECT(AddNamedItem
);
2286 SET_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
2287 SET_EXPECT(ParseScriptText
);
2288 SET_EXPECT(SetScriptState_CONNECTED
);
2290 load_doc(doc
, simple_script_str
);
2292 CHECK_CALLED(CreateInstance
);
2293 CHECK_CALLED(GetInterfaceSafetyOptions
);
2294 CHECK_CALLED(SetInterfaceSafetyOptions
);
2295 CHECK_CALLED_BROKEN(SetProperty_INVOKEVERSIONING
); /* IE8 */
2296 CHECK_CALLED(SetProperty_HACK_TRIDENTEVENTSINK
);
2297 CHECK_CALLED(InitNew
);
2298 CHECK_CALLED(SetScriptSite
);
2299 CHECK_CALLED(GetScriptState
);
2300 CHECK_CALLED(SetScriptState_STARTED
);
2301 CHECK_CALLED(AddNamedItem
);
2302 CHECK_CALLED_BROKEN(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
2303 CHECK_CALLED(ParseScriptText
);
2304 CHECK_CALLED(SetScriptState_CONNECTED
);
2307 IActiveScriptSite_Release(site
);
2309 IDispatchEx_Release(window_dispex
);
2311 SET_EXPECT(SetScriptState_DISCONNECTED
);
2314 IHTMLDocument2_Release(doc
);
2316 CHECK_CALLED(SetScriptState_DISCONNECTED
);
2317 CHECK_CALLED(Close
);
2320 static void run_js_script(const char *test_name
)
2322 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2323 char urlA
[INTERNET_MAX_URL_LENGTH
];
2324 IPersistMoniker
*persist
;
2325 IHTMLDocument2
*doc
;
2330 static const char res
[] = "res://";
2332 trace("running %s...\n", test_name
);
2334 doc
= create_document();
2338 set_client_site(doc
, TRUE
);
2339 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
2341 lstrcpyA(urlA
, res
);
2342 GetModuleFileNameA(NULL
, urlA
+ lstrlenA(res
), sizeof(urlA
) - lstrlenA(res
));
2343 lstrcatA(urlA
, "/");
2344 lstrcatA(urlA
, test_name
);
2345 MultiByteToWideChar(CP_ACP
, 0, urlA
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
2347 hres
= CreateURLMoniker(NULL
, url
, &mon
);
2348 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2350 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistMoniker
, (void**)&persist
);
2351 ok(hres
== S_OK
, "Could not get IPersistMoniker iface: %08x\n", hres
);
2353 hres
= IPersistMoniker_Load(persist
, FALSE
, mon
, NULL
, 0);
2354 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
2356 IMoniker_Release(mon
);
2357 IPersistMoniker_Release(persist
);
2359 SET_EXPECT(external_success
);
2361 while(!called_external_success
&& GetMessage(&msg
, NULL
, 0, 0)) {
2362 TranslateMessage(&msg
);
2363 DispatchMessage(&msg
);
2366 CHECK_CALLED(external_success
);
2368 set_client_site(doc
, FALSE
);
2369 IHTMLDocument2_Release(doc
);
2372 static void run_js_tests(void)
2374 run_js_script("jstest.html");
2377 static BOOL
init_registry(BOOL init
)
2379 return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID
, init
)
2380 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}",
2382 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}",
2386 static BOOL
register_script_engine(void)
2391 if(!init_registry(TRUE
)) {
2392 init_registry(FALSE
);
2396 hres
= CoRegisterClassObject(&CLSID_TestScript
, (IUnknown
*)&script_cf
,
2397 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
2398 ok(hres
== S_OK
, "Could not register screipt engine: %08x\n", hres
);
2403 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2405 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
2408 static HWND
create_container_window(void)
2410 static const CHAR szHTMLDocumentTest
[] = "HTMLDocumentTest";
2411 static WNDCLASSEXA wndclass
= {
2412 sizeof(WNDCLASSEXA
),
2415 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
2420 RegisterClassExA(&wndclass
);
2421 return CreateWindowA(szHTMLDocumentTest
, szHTMLDocumentTest
,
2422 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
,
2423 300, 300, NULL
, NULL
, NULL
, NULL
);
2429 container_hwnd
= create_container_window();
2431 if(winetest_interactive
|| ! is_ie_hardened()) {
2432 if(register_script_engine()) {
2433 test_simple_script();
2435 init_registry(FALSE
);
2437 skip("Could not register TestScript engine\n");
2440 skip("IE running in Enhanced Security Configuration\n");
2443 DestroyWindow(container_hwnd
);