static IHTMLDocument2 *create_and_load_doc(const char *str) { IHTMLDocument2 *doc; IHTMLElement *body = NULL; ULONG ref; MSG msg; HRESULT hres; doc = create_doc_with_string(str); do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink); while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } hres = IHTMLDocument2_get_body(doc, &body); ok(hres == S_OK, "get_body failed: %08x\n", hres); if(!body) { skip("Could not get document body. Assuming no Gecko installed.\n"); ref = IHTMLDocument2_Release(doc); ok(!ref, "ref = %d\n", ref); return NULL; } IHTMLElement_Release(body); return doc; }
static IHTMLDocument2 *create_doc_from_url(const char *start_url) { BSTR url; IBindCtx *bc; IMoniker *url_mon; IPersistMoniker *persist_mon; IHTMLDocument2 *doc; HRESULT hres; hres = CreateBindCtx(0, &bc); ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres); url = a2bstr(start_url); hres = CreateURLMoniker(NULL, url, &url_mon); ok(hres == S_OK, "CreateURLMoniker failed: 0x%08x\n", hres); hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IHTMLDocument2, (void**)&doc); ok(hres == S_OK, "CoCreateInstance failed: 0x%08x\n", hres); hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon); ok(hres == S_OK, "IHTMLDocument2_QueryInterface failed: 0x%08x\n", hres); hres = IPersistMoniker_Load(persist_mon, FALSE, url_mon, bc, STGM_SHARE_EXCLUSIVE | STGM_READWRITE); ok(hres == S_OK, "IPersistMoniker_Load failed: 0x%08x\n", hres); IPersistMoniker_Release(persist_mon); IMoniker_Release(url_mon); IBindCtx_Release(bc); SysFreeString(url); doc_complete = FALSE; notif_doc = doc; do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink); pump_msgs(&doc_complete); return doc; }