>From b2447f0d0b0939e0d5ee9dbeb8e1a4e39f2ecbd6 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Thu, 19 Jan 2012 00:43:14 +0300
Subject: [PATCH 1/2] Respond to SID_SContainerDispatch service id

---
 dlls/mshtml/service.c       |    5 +++++
 dlls/mshtml/tests/htmldoc.c |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dlls/mshtml/service.c b/dlls/mshtml/service.c
index ed95f49..9cafbf0 100644
--- a/dlls/mshtml/service.c
+++ b/dlls/mshtml/service.c
@@ -249,6 +249,11 @@ static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFG
         return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
     }
 
+    if(IsEqualGUID(&SID_SContainerDispatch, guidService)) {
+        TRACE("SID_SContainerDispatch\n");
+        return IHTMLDocument2_QueryInterface(&This->IHTMLDocument2_iface, riid, ppv);
+    }
+
     TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
 
     if(This->doc_obj->client) {
diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c
index 736e60f..a1a31ea 100644
--- a/dlls/mshtml/tests/htmldoc.c
+++ b/dlls/mshtml/tests/htmldoc.c
@@ -47,6 +47,7 @@
 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
+DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0x00,0xaa,0x00,0x40,0x47,0x70);
 
 #define DEFINE_EXPECT(func) \
     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
@@ -7067,6 +7068,40 @@ static BOOL check_ie(void)
     return SUCCEEDED(hres);
 }
 
+static void test_ServiceProvider(void)
+{
+    IServiceProvider *provider;
+    IHTMLDocument2 *doc, *doc2;
+    IUnknown *unk;
+    HRESULT hres;
+
+    doc = create_document();
+    if(!doc)
+        return;
+
+    hres = IHTMLDocument2_QueryInterface(doc, &IID_IServiceProvider, (void**)&provider);
+    ok(hres == S_OK, "got 0x%08x\n", hres);
+
+    hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc2);
+    ok(hres == S_OK, "got 0x%08x\n", hres);
+    ok(doc == doc2, "got %p, expected %p\n", doc2, doc);
+    IHTMLDocument2_Release(doc2);
+
+    hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IUnknown, (void**)&unk);
+    ok(hres == S_OK, "got 0x%08x\n", hres);
+todo_wine
+    ok(doc != (void*)unk, "got %p, expected %p\n", unk, doc);
+
+    hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc2);
+    ok(hres == S_OK, "got 0x%08x\n", hres);
+    IHTMLDocument2_Release(doc2);
+    IUnknown_Release(unk);
+
+    IServiceProvider_Release(provider);
+
+    release_document(doc);
+}
+
 START_TEST(htmldoc)
 {
     CoInitialize(NULL);
@@ -7101,6 +7136,7 @@ START_TEST(htmldoc)
     test_UIActivate(TRUE, TRUE, TRUE);
     test_HTMLDoc_ISupportErrorInfo();
     test_IPersistHistory();
+    test_ServiceProvider();
 
     DestroyWindow(container_hwnd);
     CoUninitialize();
-- 
1.5.6.5


