Commit fd892ff1 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

mshtml: Add console object stub implementation.

parent fdb304ff
...@@ -316,6 +316,9 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) ...@@ -316,6 +316,9 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
if(!ref) { if(!ref) {
if (This->console)
IWineMSHTMLConsole_Release(This->console);
if(is_outer_window(This)) if(is_outer_window(This))
release_outer_window(This->outer_window); release_outer_window(This->outer_window);
else else
...@@ -3115,6 +3118,21 @@ static HRESULT WINAPI window_private_requestAnimationFrame(IWineHTMLWindowPrivat ...@@ -3115,6 +3118,21 @@ static HRESULT WINAPI window_private_requestAnimationFrame(IWineHTMLWindowPrivat
return hres; return hres;
} }
static HRESULT WINAPI window_private_get_console(IWineHTMLWindowPrivate *iface, IDispatch **console)
{
HTMLWindow *This = impl_from_IWineHTMLWindowPrivateVtbl(iface);
TRACE("iface %p, console %p.\n", iface, console);
if (!This->console)
create_console(dispex_compat_mode(&This->inner_window->event_target.dispex), &This->console);
*console = (IDispatch *)This->console;
if (This->console)
IWineMSHTMLConsole_AddRef(This->console);
return S_OK;
}
static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = {
window_private_QueryInterface, window_private_QueryInterface,
window_private_AddRef, window_private_AddRef,
...@@ -3124,6 +3142,7 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { ...@@ -3124,6 +3142,7 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = {
window_private_GetIDsOfNames, window_private_GetIDsOfNames,
window_private_Invoke, window_private_Invoke,
window_private_requestAnimationFrame, window_private_requestAnimationFrame,
window_private_get_console,
}; };
static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface) static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
......
...@@ -273,7 +273,8 @@ typedef struct EventTarget EventTarget; ...@@ -273,7 +273,8 @@ typedef struct EventTarget EventTarget;
XIID(ISVGTextContentElement) XIID(ISVGTextContentElement)
#define PRIVATE_TID_LIST \ #define PRIVATE_TID_LIST \
XIID(IWineHTMLWindowPrivate) XIID(IWineHTMLWindowPrivate) \
XIID(IWineMSHTMLConsole)
typedef enum { typedef enum {
#define XIID(iface) iface ## _tid, #define XIID(iface) iface ## _tid,
...@@ -492,6 +493,8 @@ struct HTMLWindow { ...@@ -492,6 +493,8 @@ struct HTMLWindow {
IProvideMultipleClassInfo IProvideMultipleClassInfo_iface; IProvideMultipleClassInfo IProvideMultipleClassInfo_iface;
IWineHTMLWindowPrivate IWineHTMLWindowPrivate_iface; IWineHTMLWindowPrivate IWineHTMLWindowPrivate_iface;
IWineMSHTMLConsole *console;
LONG ref; LONG ref;
HTMLInnerWindow *inner_window; HTMLInnerWindow *inner_window;
...@@ -1407,3 +1410,4 @@ void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN; ...@@ -1407,3 +1410,4 @@ void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;
IInternetSecurityManager *get_security_manager(void) DECLSPEC_HIDDEN; IInternetSecurityManager *get_security_manager(void) DECLSPEC_HIDDEN;
extern HINSTANCE hInst DECLSPEC_HIDDEN; extern HINSTANCE hInst DECLSPEC_HIDDEN;
void create_console(compat_mode_t compat_mode, IWineMSHTMLConsole **ret) DECLSPEC_HIDDEN;
...@@ -35,12 +35,58 @@ importlib("stdole2.tlb"); ...@@ -35,12 +35,58 @@ importlib("stdole2.tlb");
oleautomation, oleautomation,
dual, dual,
hidden, hidden,
uuid(fd55b4b6-2813-4fb4-829d-380099474ab1)
]
interface IWineMSHTMLConsole : IDispatch
{
[id(1)]
HRESULT assert([in] VARIANT_BOOL *assertion,
[in, optional] VARIANT *varargStart);
[id(2)]
HRESULT clear();
[id(3)]
HRESULT count([in, optional] VARIANT *label);
[id(4)]
HRESULT debug([in, optional] VARIANT *varargStart);
[id(5)]
HRESULT dir([in, optional] VARIANT *object);
[id(6)]
HRESULT dirxml([in, optional] VARIANT *object);
[id(7)]
HRESULT error([in, optional] VARIANT *varargStart);
[id(8)]
HRESULT group([in, optional] VARIANT *label);
[id(9)]
HRESULT groupCollapsed([in, optional] VARIANT *label);
[id(10)]
HRESULT groupEnd();
[id(11)]
HRESULT info([in, optional] VARIANT *varargStart);
[id(12)]
HRESULT log([in, optional] VARIANT *varargStart);
[id(13)]
HRESULT time([in, optional] VARIANT *label);
[id(14)]
HRESULT timeEnd([in, optional] VARIANT *label);
[id(15)]
HRESULT trace([in, optional] VARIANT *varargStart);
[id(16)]
HRESULT warn([in, optional] VARIANT *varargStart);
}
[
odl,
oleautomation,
dual,
hidden,
uuid(1b5939fc-8f84-43f3-8d89-f9a92069fad7) uuid(1b5939fc-8f84-43f3-8d89-f9a92069fad7)
] ]
interface IWineHTMLWindowPrivate : IDispatch interface IWineHTMLWindowPrivate : IDispatch
{ {
[id(1)] [id(1)]
HRESULT requestAnimationFrame([in] VARIANT *expr, [retval, out] VARIANT *timer_id); HRESULT requestAnimationFrame([in] VARIANT *expr, [retval, out] VARIANT *timer_id);
[propget, id(2)]
HRESULT console([retval, out] IDispatch **console);
} }
} /* library MSHTML_private */ } /* library MSHTML_private */
...@@ -2365,3 +2365,261 @@ HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCol ...@@ -2365,3 +2365,261 @@ HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCol
*ret = &namespaces->IHTMLNamespaceCollection_iface; *ret = &namespaces->IHTMLNamespaceCollection_iface;
return S_OK; return S_OK;
} }
struct console {
DispatchEx dispex;
IWineMSHTMLConsole IWineMSHTMLConsole_iface;
LONG ref;
};
static inline struct console *impl_from_IWineMSHTMLConsole(IWineMSHTMLConsole *iface)
{
return CONTAINING_RECORD(iface, struct console, IWineMSHTMLConsole_iface);
}
static HRESULT WINAPI console_QueryInterface(IWineMSHTMLConsole *iface, REFIID riid, void **ppv)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
TRACE("(%p)->(%s %p)\n", console, debugstr_mshtml_guid(riid), ppv);
if(IsEqualGUID(&IID_IUnknown, riid)) {
*ppv = &console->IWineMSHTMLConsole_iface;
}else if(IsEqualGUID(&IID_IWineMSHTMLConsole, riid)) {
*ppv = &console->IWineMSHTMLConsole_iface;
}else if(dispex_query_interface(&console->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE;
}else {
WARN("(%p)->(%s %p)\n", console, debugstr_mshtml_guid(riid), ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI console_AddRef(IWineMSHTMLConsole *iface)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
LONG ref = InterlockedIncrement(&console->ref);
TRACE("(%p) ref=%d\n", console, ref);
return ref;
}
static ULONG WINAPI console_Release(IWineMSHTMLConsole *iface)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
LONG ref = InterlockedDecrement(&console->ref);
TRACE("(%p) ref=%d\n", console, ref);
if(!ref) {
release_dispex(&console->dispex);
heap_free(console);
}
return ref;
}
static HRESULT WINAPI console_GetTypeInfoCount(IWineMSHTMLConsole *iface, UINT *pctinfo)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
FIXME("(%p)->(%p)\n", console, pctinfo);
return E_NOTIMPL;
}
static HRESULT WINAPI console_GetTypeInfo(IWineMSHTMLConsole *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
return IDispatchEx_GetTypeInfo(&console->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}
static HRESULT WINAPI console_GetIDsOfNames(IWineMSHTMLConsole *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
return IDispatchEx_GetIDsOfNames(&console->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
lcid, rgDispId);
}
static HRESULT WINAPI console_Invoke(IWineMSHTMLConsole *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
struct console *console = impl_from_IWineMSHTMLConsole(iface);
return IDispatchEx_Invoke(&console->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI console_assert(IWineMSHTMLConsole *iface, VARIANT_BOOL *assertion, VARIANT *vararg_start)
{
FIXME("iface %p, assertion %p, vararg_start %p stub.\n", iface, assertion, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_clear(IWineMSHTMLConsole *iface)
{
FIXME("iface %p stub.\n", iface);
return S_OK;
}
static HRESULT WINAPI console_count(IWineMSHTMLConsole *iface, VARIANT *label)
{
FIXME("iface %p, label %p stub.\n", iface, label);
return S_OK;
}
static HRESULT WINAPI console_debug(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_dir(IWineMSHTMLConsole *iface, VARIANT *object)
{
FIXME("iface %p, object %p stub.\n", iface, object);
return S_OK;
}
static HRESULT WINAPI console_dirxml(IWineMSHTMLConsole *iface, VARIANT *object)
{
FIXME("iface %p, object %p stub.\n", iface, object);
return S_OK;
}
static HRESULT WINAPI console_error(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_group(IWineMSHTMLConsole *iface, VARIANT *label)
{
FIXME("iface %p, label %p stub.\n", iface, label);
return S_OK;
}
static HRESULT WINAPI console_group_collapsed(IWineMSHTMLConsole *iface, VARIANT *label)
{
FIXME("iface %p, label %p stub.\n", iface, label);
return S_OK;
}
static HRESULT WINAPI console_group_end(IWineMSHTMLConsole *iface)
{
FIXME("iface %p, stub.\n", iface);
return S_OK;
}
static HRESULT WINAPI console_info(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_log(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_time(IWineMSHTMLConsole *iface, VARIANT *label)
{
FIXME("iface %p, label %p stub.\n", iface, label);
return S_OK;
}
static HRESULT WINAPI console_time_end(IWineMSHTMLConsole *iface, VARIANT *label)
{
FIXME("iface %p, label %p stub.\n", iface, label);
return S_OK;
}
static HRESULT WINAPI console_trace(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static HRESULT WINAPI console_warn(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
{
FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
return S_OK;
}
static const IWineMSHTMLConsoleVtbl WineMSHTMLConsoleVtbl = {
console_QueryInterface,
console_AddRef,
console_Release,
console_GetTypeInfoCount,
console_GetTypeInfo,
console_GetIDsOfNames,
console_Invoke,
console_assert,
console_clear,
console_count,
console_debug,
console_dir,
console_dirxml,
console_error,
console_group,
console_group_collapsed,
console_group_end,
console_info,
console_log,
console_time,
console_time_end,
console_trace,
console_warn,
};
static const tid_t console_iface_tids[] = {
IWineMSHTMLConsole_tid,
0
};
static dispex_static_data_t console_dispex = {
NULL,
IWineMSHTMLConsole_tid,
console_iface_tids
};
void create_console(compat_mode_t compat_mode, IWineMSHTMLConsole **ret)
{
struct console *obj;
obj = heap_alloc_zero(sizeof(*obj));
if(!obj)
{
ERR("No memory.\n");
return;
}
obj->IWineMSHTMLConsole_iface.lpVtbl = &WineMSHTMLConsoleVtbl;
obj->ref = 1;
init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineMSHTMLConsole_iface, &console_dispex, compat_mode);
*ret = &obj->IWineMSHTMLConsole_iface;
}
...@@ -121,6 +121,7 @@ sync_test("window_props", function() { ...@@ -121,6 +121,7 @@ sync_test("window_props", function() {
test_exposed("Set", v >= 11); test_exposed("Set", v >= 11);
if(v >= 9) /* FIXME: native exposes it in all compat modes */ if(v >= 9) /* FIXME: native exposes it in all compat modes */
test_exposed("performance", true); test_exposed("performance", true);
test_exposed("console", v >= 10);
}); });
sync_test("xhr_props", function() { sync_test("xhr_props", function() {
......
...@@ -1448,3 +1448,67 @@ sync_test("functions scope", function() { ...@@ -1448,3 +1448,67 @@ sync_test("functions scope", function() {
ok(val == 8, "val != 8"); ok(val == 8, "val != 8");
ok(w == 9, "w != 9"); ok(w == 9, "w != 9");
}); });
sync_test("console", function() {
var except
window.console.log('1', '2');
console.info('1', '2', '3');
console.info();
console.log();
console.trace();
console.warn();
console.debug();
console.error();
console.assert(false, '1');
console.assert(true, '1');
console.assert('1');
console.clear();
console.count('1');
console.count(1);
except = false;
try
{
console.countReset('1');
}
catch(e)
{
except = true;
}
ok(except, "console.countReset: expected exception");
console.dir(document);
console.dir();
console.dirxml(document);
console.group('1');
console.groupCollapsed('1');
console.groupEnd();
except = false;
try
{
console.table(['1', '2']);
}
catch(e)
{
except = true;
}
ok(except, "console.table: expected exception");
console.time('1');
console.timeEnd('1');
except = false;
try
{
console.timeLog('1');
}
catch(e)
{
except = true;
}
ok(except, "console.timeLog: expected exception");
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment