mshtml: Add console object stub implementation.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-07-08 03:34:22 +03:00 committed by Alexandre Julliard
parent fdb304ff14
commit fd892ff10f
6 changed files with 393 additions and 1 deletions

View File

@ -316,6 +316,9 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
if (This->console)
IWineMSHTMLConsole_Release(This->console);
if(is_outer_window(This))
release_outer_window(This->outer_window);
else
@ -3115,6 +3118,21 @@ static HRESULT WINAPI window_private_requestAnimationFrame(IWineHTMLWindowPrivat
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 = {
window_private_QueryInterface,
window_private_AddRef,
@ -3124,6 +3142,7 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = {
window_private_GetIDsOfNames,
window_private_Invoke,
window_private_requestAnimationFrame,
window_private_get_console,
};
static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)

View File

@ -273,7 +273,8 @@ typedef struct EventTarget EventTarget;
XIID(ISVGTextContentElement)
#define PRIVATE_TID_LIST \
XIID(IWineHTMLWindowPrivate)
XIID(IWineHTMLWindowPrivate) \
XIID(IWineMSHTMLConsole)
typedef enum {
#define XIID(iface) iface ## _tid,
@ -492,6 +493,8 @@ struct HTMLWindow {
IProvideMultipleClassInfo IProvideMultipleClassInfo_iface;
IWineHTMLWindowPrivate IWineHTMLWindowPrivate_iface;
IWineMSHTMLConsole *console;
LONG ref;
HTMLInnerWindow *inner_window;
@ -1407,3 +1410,4 @@ void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;
IInternetSecurityManager *get_security_manager(void) DECLSPEC_HIDDEN;
extern HINSTANCE hInst DECLSPEC_HIDDEN;
void create_console(compat_mode_t compat_mode, IWineMSHTMLConsole **ret) DECLSPEC_HIDDEN;

View File

@ -30,6 +30,50 @@ library MSHTML_private
importlib("stdole2.tlb");
[
odl,
oleautomation,
dual,
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,
@ -41,6 +85,8 @@ interface IWineHTMLWindowPrivate : IDispatch
{
[id(1)]
HRESULT requestAnimationFrame([in] VARIANT *expr, [retval, out] VARIANT *timer_id);
[propget, id(2)]
HRESULT console([retval, out] IDispatch **console);
}
} /* library MSHTML_private */

View File

@ -2365,3 +2365,261 @@ HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCol
*ret = &namespaces->IHTMLNamespaceCollection_iface;
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;
}

View File

@ -121,6 +121,7 @@ sync_test("window_props", function() {
test_exposed("Set", v >= 11);
if(v >= 9) /* FIXME: native exposes it in all compat modes */
test_exposed("performance", true);
test_exposed("console", v >= 10);
});
sync_test("xhr_props", function() {

View File

@ -1448,3 +1448,67 @@ sync_test("functions scope", function() {
ok(val == 8, "val != 8");
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");
});