From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlwindow.c | 32 +++++++++- dlls/mshtml/mshtml_private.h | 4 ++ dlls/mshtml/mshtml_private_iface.idl | 18 ++++++ dlls/mshtml/omnavigator.c | 94 ++++++++++++++++++++++++++++ dlls/mshtml/tests/documentmode.js | 12 +++- 5 files changed, 158 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index edd0de177bd..716b60b56c0 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3190,6 +3190,24 @@ static HRESULT WINAPI window_private_get_console(IWineHTMLWindowPrivate *iface, return S_OK; }
+static HRESULT WINAPI window_private_get_msCrypto(IWineHTMLWindowPrivate *iface, IDispatch **crypto) +{ + HTMLInnerWindow *This = impl_from_IWineHTMLWindowPrivateVtbl(iface)->inner_window; + + TRACE("iface %p, crypto %p.\n", iface, crypto); + + if(!This->crypto) { + HRESULT hres = create_crypto(This, &This->crypto); + if(FAILED(hres)) + return hres; + } + + *crypto = (IDispatch*)This->crypto; + if(This->crypto) + IWineMSHTMLCrypto_AddRef(This->crypto); + return S_OK; +} + static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { window_private_QueryInterface, window_private_AddRef, @@ -3202,6 +3220,7 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { window_private_cancelAnimationFrame, window_private_get_console, window_private_matchMedia, + window_private_get_msCrypto, };
static inline HTMLWindow *impl_from_IWineHTMLWindowCompatPrivateVtbl(IWineHTMLWindowCompatPrivate *iface) @@ -3717,6 +3736,8 @@ static void HTMLWindow_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCa note_cc_edge((nsISupports*)This->session_storage, "session_storage", cb); if(This->local_storage) note_cc_edge((nsISupports*)This->local_storage, "local_storage", cb); + if(This->crypto) + note_cc_edge((nsISupports*)This->crypto, "crypto", cb); if(This->dom_window) note_cc_edge((nsISupports*)This->dom_window, "dom_window", cb); traverse_variant(&This->performance, "performance", cb); @@ -3762,6 +3783,11 @@ static void HTMLWindow_unlink(DispatchEx *dispex) This->local_storage = NULL; IHTMLStorage_Release(local_storage); } + if(This->crypto) { + IWineMSHTMLCrypto *crypto = This->crypto; + This->crypto = NULL; + IWineMSHTMLCrypto_Release(crypto); + } unlink_variant(&This->performance); unlink_ref(&This->dom_window); } @@ -4238,13 +4264,17 @@ static void HTMLWindow_init_dispex_info(dispex_data_t *info, compat_mode_t compa {DISPID_UNKNOWN} }; const dispex_hook_t *const window6_hooks = window6_ie9_hooks + 1; + static const dispex_hook_t private_ie10_hooks[] = { + {DISPID_IWINEHTMLWINDOWPRIVATE_MSCRYPTO}, + {DISPID_UNKNOWN} + };
if(compat_mode >= COMPAT_MODE_IE9) dispex_info_add_interface(info, IHTMLWindow7_tid, NULL); else dispex_info_add_interface(info, IWineHTMLWindowCompatPrivate_tid, NULL); if(compat_mode >= COMPAT_MODE_IE10) - dispex_info_add_interface(info, IWineHTMLWindowPrivate_tid, NULL); + dispex_info_add_interface(info, IWineHTMLWindowPrivate_tid, compat_mode < COMPAT_MODE_IE11 ? private_ie10_hooks : NULL);
dispex_info_add_interface(info, IHTMLWindow6_tid, compat_mode >= COMPAT_MODE_IE9 ? window6_ie9_hooks : window6_hooks); if(compat_mode < COMPAT_MODE_IE9) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 5c885ae5de4..fa0d2fac30e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -322,6 +322,7 @@ struct constructor; XIID(IWinePageTransitionEvent) \ XIID(IWineXMLHttpRequestPrivate) \ XIID(IWineMSHTMLConsole) \ + XIID(IWineMSHTMLCrypto) \ XIID(IWineMSHTMLMediaQueryList) \ XIID(IWineMSHTMLMutationObserver)
@@ -442,6 +443,7 @@ typedef struct { X(ClientRectList) \ X(Comment) \ X(Console) \ + X(Crypto) \ X(CustomEvent) \ X(DOMImplementation) \ X(DOMParser) \ @@ -807,6 +809,7 @@ struct HTMLInnerWindow { IHTMLStorage *session_storage; IHTMLStorage *local_storage; IWineMSHTMLConsole *console; + IWineMSHTMLCrypto *crypto;
BOOL static_props_filled; BOOL performance_initialized; @@ -1743,4 +1746,5 @@ IInternetSecurityManager *get_security_manager(void);
extern HINSTANCE hInst; void create_console(HTMLInnerWindow *window, IWineMSHTMLConsole **ret); +HRESULT create_crypto(HTMLInnerWindow *window, IWineMSHTMLCrypto **ret); HRESULT create_media_query_list(HTMLInnerWindow *window, BSTR media_query, IDispatch **ret); diff --git a/dlls/mshtml/mshtml_private_iface.idl b/dlls/mshtml/mshtml_private_iface.idl index 14bcae098ee..ff53b4b39d6 100644 --- a/dlls/mshtml/mshtml_private_iface.idl +++ b/dlls/mshtml/mshtml_private_iface.idl @@ -113,6 +113,22 @@ interface IWineMSHTMLMediaQueryList : IDispatch HRESULT removeListener([in] VARIANT *listener); }
+[ + odl, + oleautomation, + dual, + hidden, + uuid(fd55b4b6-2813-4fb4-829d-380099474ab2) +] +interface IWineMSHTMLCrypto : IDispatch +{ + [propget, id(1)] + HRESULT subtle([retval, out] IDispatch **subtle); + [id(2)] + HRESULT getRandomValues([in] VARIANT *typedArray, [retval, out] IDispatch **ret); +} + +const long DISPID_IWINEHTMLWINDOWPRIVATE_MSCRYPTO = 54; [ odl, oleautomation, @@ -130,6 +146,8 @@ interface IWineHTMLWindowPrivate : IDispatch HRESULT console([retval, out] IDispatch **console); [id(53)] HRESULT matchMedia([in] BSTR media_query, [retval, out] IDispatch **media_query_list); + [propget, id(DISPID_IWINEHTMLWINDOWPRIVATE_MSCRYPTO)] + HRESULT msCrypto([retval, out] IDispatch **crypto); }
[ diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 4320836b4f6..5d2b1a7c902 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -2712,3 +2712,97 @@ HRESULT create_media_query_list(HTMLInnerWindow *window, BSTR media_query, IDisp *ret = (IDispatch*)&media_query_list->IWineMSHTMLMediaQueryList_iface; return S_OK; } + +struct crypto { + DispatchEx dispex; + IWineMSHTMLCrypto IWineMSHTMLCrypto_iface; +}; + +static inline struct crypto *impl_from_IWineMSHTMLCrypto(IWineMSHTMLCrypto *iface) +{ + return CONTAINING_RECORD(iface, struct crypto, IWineMSHTMLCrypto_iface); +} + +DISPEX_IDISPATCH_IMPL(crypto, IWineMSHTMLCrypto, impl_from_IWineMSHTMLCrypto(iface)->dispex) + +static HRESULT WINAPI crypto_get_subtle(IWineMSHTMLCrypto *iface, IDispatch **subtle) +{ + struct crypto *crypto = impl_from_IWineMSHTMLCrypto(iface); + + FIXME("(%p)->(%p)\n", crypto, subtle); + + return E_NOTIMPL; +} + +static HRESULT WINAPI crypto_getRandomValues(IWineMSHTMLCrypto *iface, VARIANT *typedArray, IDispatch **ret) +{ + struct crypto *crypto = impl_from_IWineMSHTMLCrypto(iface); + + FIXME("(%p)->(%p %p)\n", crypto, typedArray, ret); + + return E_NOTIMPL; +} + +static const IWineMSHTMLCryptoVtbl WineMSHTMLCryptoVtbl = { + crypto_QueryInterface, + crypto_AddRef, + crypto_Release, + crypto_GetTypeInfoCount, + crypto_GetTypeInfo, + crypto_GetIDsOfNames, + crypto_Invoke, + crypto_get_subtle, + crypto_getRandomValues +}; + +static inline struct crypto *crypto_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, struct crypto, dispex); +} + +static void *crypto_query_interface(DispatchEx *dispex, REFIID riid) +{ + struct crypto *This = crypto_from_DispatchEx(dispex); + + if(IsEqualGUID(&IID_IWineMSHTMLCrypto, riid)) + return &This->IWineMSHTMLCrypto_iface; + + return NULL; +} + +static void crypto_destructor(DispatchEx *dispex) +{ + struct crypto *This = crypto_from_DispatchEx(dispex); + free(This); +} + +static const dispex_static_data_vtbl_t crypto_dispex_vtbl = { + .query_interface = crypto_query_interface, + .destructor = crypto_destructor, +}; + +static const tid_t crypto_iface_tids[] = { + IWineMSHTMLCrypto_tid, + 0 +}; +dispex_static_data_t Crypto_dispex = { + .id = OBJID_Crypto, + .vtbl = &crypto_dispex_vtbl, + .disp_tid = IWineMSHTMLCrypto_tid, + .iface_tids = crypto_iface_tids, + .min_compat_mode = COMPAT_MODE_IE11, +}; + +HRESULT create_crypto(HTMLInnerWindow *window, IWineMSHTMLCrypto **ret) +{ + struct crypto *crypto; + + if(!(crypto = calloc(1, sizeof(*crypto)))) + return E_OUTOFMEMORY; + + crypto->IWineMSHTMLCrypto_iface.lpVtbl = &WineMSHTMLCryptoVtbl; + init_dispatch(&crypto->dispex, &Crypto_dispex, window, dispex_compat_mode(&window->event_target.dispex)); + + *ret = &crypto->IWineMSHTMLCrypto_iface; + return S_OK; +} diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index a930e216b5a..8ad9a141bb5 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -351,6 +351,7 @@ sync_test("builtin_toString", function() { test("mediaQueryList", window.matchMedia("(hover:hover)"), "MediaQueryList"); } if(v >= 11) { + test("crypto", window.msCrypto, "Crypto"); test("MutationObserver", new window.MutationObserver(function() {}), "MutationObserver"); } if(v >= 9) { @@ -983,6 +984,7 @@ sync_test("window_props", function() { test_exposed("performance", true); test_exposed("console", v >= 10); test_exposed("matchMedia", v >= 10); + test_exposed("msCrypto", v >= 11); test_exposed("Document", v >= 9); test_exposed("HTMLDocument", v === 8 || v >= 11, v === 8); test_exposed("XMLDocument", v >= 11); @@ -4111,6 +4113,12 @@ sync_test("prototypes", function() { }else { ok(!("Console" in window), "Console found in window"); } + if(v >= 11) { + check(msCrypto, Crypto.prototype, "crypto"); + check(Crypto.prototype, Object.prototype, "crypto prototype"); + }else { + ok(!("msCrypto" in window), "msCrypto found in window"); + } if(v >= 10) { check(window.matchMedia("(hover:hover)"), MediaQueryList.prototype, "media query"); check(MediaQueryList.prototype, Object.prototype, "media query prototype"); @@ -4169,6 +4177,8 @@ sync_test("prototype props", function() { check(Attr, [ "expando", "name", "ownerElement", "specified", "value" ]); check(CharacterData, [ "appendData", "data", "deleteData", "insertData", "length", "replaceData", "substringData" ]); check(Comment, [ "text" ]); + if(v >= 11) + check(Crypto, [ "getRandomValues", "subtle" ]); check(CSSStyleDeclaration, [ ["alignContent",11], ["alignItems",11], ["alignSelf",11], "alignmentBaseline", ["animation",10], ["animationDelay",10], ["animationDirection",10], ["animationDuration",10], ["animationFillMode",10], ["animationIterationCount",10], ["animationName",10], @@ -4672,7 +4682,7 @@ async_test("window own props", function() { ], [ ["AesGcmEncryptResult",11], ["ANGLE_instanced_arrays",11], ["AnimationEvent",10], ["ApplicationCache",10], "Audio", ["AudioTrack",10], ["AudioTrackList",10], "BeforeUnloadEvent", ["Blob",10], "BookmarkCollection", "CanvasGradient", "CanvasPattern", "CanvasPixelArray", "CanvasRenderingContext2D", "CDATASection", ["CloseEvent",10], - "CompositionEvent", "ControlRangeCollection", "Coordinates", ["Crypto",11], ["CryptoOperation",11], "CSSFontFaceRule", "CSSImportRule", ["CSSKeyframeRule",10], ["CSSKeyframesRule",10], + "CompositionEvent", "ControlRangeCollection", "Coordinates", ["CryptoOperation",11], "CSSFontFaceRule", "CSSImportRule", ["CSSKeyframeRule",10], ["CSSKeyframesRule",10], "CSSMediaRule", "CSSNamespaceRule", "CSSPageRule", "CSSRuleList", "DataTransfer", "Debug", ["DeviceAcceleration",11], ["DeviceMotionEvent",11], ["DeviceOrientationEvent",11], ["DeviceRotationRate",11], ["DOMError",10], "DOMException", ["DOMSettableTokenList",10], ["DOMStringList",10], ["DOMStringMap",11], "DragEvent", ["ErrorEvent",10], "EventException", ["EXT_texture_filter_anisotropic",11], ["File",10], ["FileList",10], ["FileReader",10],