mirror of
https://github.com/reactos/wine.git
synced 2024-12-14 07:08:41 +00:00
mshtml/tests: Added MHTML document tests.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ebee2a8346
commit
7219c7cf5d
@ -224,6 +224,7 @@ static BOOL support_wbapp, allow_new_window, no_travellog;
|
||||
static BOOL report_mime;
|
||||
static BOOL testing_submit;
|
||||
static BOOL resetting_document;
|
||||
static BOOL is_mhtml;
|
||||
static int stream_read, protocol_read;
|
||||
static IStream *history_stream;
|
||||
static enum load_state_t {
|
||||
@ -244,6 +245,22 @@ static const char html_page[] =
|
||||
"<body><div>test</div></body>"
|
||||
"</html>";
|
||||
|
||||
static const char mhtml_page[] =
|
||||
"MIME-Version: 1.0\r\n"
|
||||
"Content-Type: multipart/related; type:=\"text/html\"; boundary=\"----=_NextPart_000_00\"\r\n"
|
||||
"\r\n"
|
||||
"------=_NextPart_000_00\r\n"
|
||||
"Content-Type: text/html; charset=\"Windows-1252\"\r\n"
|
||||
"Content-Transfer-Encoding: quoted-printable\r\n"
|
||||
"\r\n"
|
||||
"<HTML></HTML>\r\n"
|
||||
"------=_NextPart_000_00\r\n"
|
||||
"Content-Type: Image/Jpeg\r\n"
|
||||
"Content-Transfer-Encoding: base64\r\n"
|
||||
"Content-Location: http://winehq.org/mhtmltest.html\r\n"
|
||||
"\r\n\t\t\t\tVGVzdA==\r\n\r\n"
|
||||
"------=_NextPart_000_00--";
|
||||
|
||||
static const char css_data[] = "body {color: red; margin: 0}";
|
||||
|
||||
static const WCHAR http_urlW[] =
|
||||
@ -578,12 +595,15 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
||||
ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
|
||||
ok(!grfPI, "grfPI = %x\n", grfPI);
|
||||
ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
|
||||
if(is_mhtml)
|
||||
ok(!strcmp_wa(szUrl, "winetest:doc"), "unexpected URL %s\n", wine_dbgstr_w(szUrl));
|
||||
|
||||
memset(&bindinfo, 0, sizeof(bindinfo));
|
||||
bindinfo.cbSize = sizeof(bindinfo);
|
||||
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
|
||||
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
|
||||
if(!testing_submit)
|
||||
todo_wine_if(is_mhtml)
|
||||
ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
|
||||
"bindf = %x\n", bindf);
|
||||
else
|
||||
@ -606,9 +626,11 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
||||
ok(!memcmp(U(bindinfo.stgmedData).hGlobal, "cmd=TEST", 8), "unexpected hGlobal\n");
|
||||
}
|
||||
ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
|
||||
ok(bindinfo.dwOptions == 0x80000 ||
|
||||
bindinfo.dwOptions == 0x4080000, /* win2k3 */
|
||||
"bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
|
||||
if(is_mhtml)
|
||||
ok(!bindinfo.dwOptions, "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
|
||||
else
|
||||
ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000, /* win2k3 */
|
||||
"bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
|
||||
ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
|
||||
/* TODO: test dwCodePage */
|
||||
/* TODO: test securityAttributes */
|
||||
@ -672,18 +694,23 @@ static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
|
||||
static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
|
||||
ULONG cb, ULONG *pcbRead)
|
||||
{
|
||||
const char *data = is_mhtml ? mhtml_page : css_data;
|
||||
unsigned data_len = strlen(data);
|
||||
|
||||
CHECK_EXPECT2(Protocol_Read);
|
||||
|
||||
ok(pv != NULL, "pv == NULL\n");
|
||||
ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
|
||||
ok(cb > data_len, "cb < data_len\n");
|
||||
ok(pcbRead != NULL, "pcbRead == NULL\n");
|
||||
ok(!*pcbRead || *pcbRead==sizeof(css_data)-1, "*pcbRead=%d\n", *pcbRead);
|
||||
ok(!*pcbRead || *pcbRead == data_len, "*pcbRead=%d\n", *pcbRead);
|
||||
|
||||
if(protocol_read)
|
||||
if(protocol_read) {
|
||||
*pcbRead = 0;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
protocol_read += *pcbRead = sizeof(css_data)-1;
|
||||
memcpy(pv, css_data, sizeof(css_data)-1);
|
||||
protocol_read += *pcbRead = data_len;
|
||||
memcpy(pv, data, data_len);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@ -5589,7 +5616,7 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon)
|
||||
SET_EXPECT(OnChanged_READYSTATE);
|
||||
SET_EXPECT(Invoke_OnReadyStateChange_Loading);
|
||||
SET_EXPECT(IsSystemMoniker);
|
||||
if(mon == &Moniker)
|
||||
if(!is_mhtml && mon == &Moniker)
|
||||
SET_EXPECT(BindToStorage);
|
||||
SET_EXPECT(SetActiveObject);
|
||||
if(set_clientsite) {
|
||||
@ -5602,6 +5629,14 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon)
|
||||
}
|
||||
SET_EXPECT(Exec_ShellDocView_84);
|
||||
SET_EXPECT(GetPendingUrl);
|
||||
if(is_mhtml) {
|
||||
SET_EXPECT(CreateInstance);
|
||||
SET_EXPECT(Start);
|
||||
SET_EXPECT(Protocol_Read);
|
||||
SET_EXPECT(LockRequest);
|
||||
SET_EXPECT(Terminate);
|
||||
SET_EXPECT(UnlockRequest);
|
||||
}
|
||||
load_state = LD_DOLOAD;
|
||||
expect_LockContainer_fLock = TRUE;
|
||||
readystate_set_loading = TRUE;
|
||||
@ -5636,7 +5671,7 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon)
|
||||
CHECK_CALLED(OnChanged_READYSTATE);
|
||||
CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
|
||||
CLEAR_CALLED(IsSystemMoniker); /* IE7 */
|
||||
if(mon == &Moniker)
|
||||
if(!is_mhtml && mon == &Moniker)
|
||||
CHECK_CALLED(BindToStorage);
|
||||
CLEAR_CALLED(SetActiveObject); /* FIXME */
|
||||
if(set_clientsite) {
|
||||
@ -5649,10 +5684,21 @@ static void test_Load(IPersistMoniker *persist, IMoniker *mon)
|
||||
}
|
||||
CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
|
||||
todo_wine CHECK_CALLED(GetPendingUrl);
|
||||
if(is_mhtml) {
|
||||
CHECK_CALLED(CreateInstance);
|
||||
CHECK_CALLED(Start);
|
||||
CHECK_CALLED(Protocol_Read);
|
||||
CHECK_CALLED(LockRequest);
|
||||
CHECK_CALLED(Terminate);
|
||||
CHECK_CALLED(UnlockRequest);
|
||||
}
|
||||
|
||||
set_clientsite = container_locked = TRUE;
|
||||
|
||||
test_GetCurMoniker((IUnknown*)persist, mon, NULL, FALSE);
|
||||
if(!is_mhtml)
|
||||
test_GetCurMoniker((IUnknown*)persist, mon, NULL, FALSE);
|
||||
else
|
||||
test_GetCurMoniker((IUnknown*)persist, NULL, "mhtml:winetest:doc", FALSE);
|
||||
|
||||
IBindCtx_Release(bind);
|
||||
|
||||
@ -5697,7 +5743,7 @@ static void test_download(DWORD flags)
|
||||
SET_EXPECT(Invoke_AMBIENT_SILENT);
|
||||
SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
|
||||
}
|
||||
if(flags & (DWL_VERBDONE|DWL_HTTP))
|
||||
if(is_mhtml || (flags & (DWL_VERBDONE|DWL_HTTP)))
|
||||
SET_EXPECT(Exec_SETPROGRESSMAX);
|
||||
if(flags & DWL_EX_GETHOSTINFO)
|
||||
SET_EXPECT(GetHostInfo);
|
||||
@ -5762,7 +5808,7 @@ static void test_download(DWORD flags)
|
||||
}
|
||||
if(!is_js && !is_extern) {
|
||||
if(!editmode && !(flags & DWL_REFRESH)) {
|
||||
if(!(flags & DWL_EMPTY))
|
||||
if(!is_mhtml && !(flags & DWL_EMPTY))
|
||||
SET_EXPECT(FireNavigateComplete2);
|
||||
SET_EXPECT(FireDocumentComplete);
|
||||
}
|
||||
@ -5788,7 +5834,7 @@ static void test_download(DWORD flags)
|
||||
CHECK_CALLED(Invoke_AMBIENT_SILENT);
|
||||
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
|
||||
}
|
||||
if(flags & DWL_VERBDONE)
|
||||
if(is_mhtml || (flags & DWL_VERBDONE))
|
||||
CHECK_CALLED(Exec_SETPROGRESSMAX);
|
||||
if(flags & DWL_HTTP)
|
||||
SET_CALLED(Exec_SETPROGRESSMAX);
|
||||
@ -5874,7 +5920,7 @@ static void test_download(DWORD flags)
|
||||
}
|
||||
if(!is_js && !is_extern) {
|
||||
if(!editmode && !(flags & DWL_REFRESH)) {
|
||||
if(!(flags & DWL_EMPTY)) {
|
||||
if(!is_mhtml && !(flags & DWL_EMPTY)) {
|
||||
todo_wine_if(!support_wbapp)
|
||||
CHECK_CALLED(FireNavigateComplete2);
|
||||
}
|
||||
@ -7484,6 +7530,7 @@ static void init_test(enum load_state_t ls) {
|
||||
complete = FALSE;
|
||||
testing_submit = FALSE;
|
||||
expect_uihandler_iface = &DocHostUIHandler;
|
||||
is_mhtml = FALSE;
|
||||
}
|
||||
|
||||
static void test_HTMLDocument(BOOL do_load, BOOL mime)
|
||||
@ -7590,6 +7637,60 @@ static void test_HTMLDocument(BOOL do_load, BOOL mime)
|
||||
ok(!IsWindow(doc_hwnd), "hwnd is not destroyed\n");
|
||||
}
|
||||
|
||||
static void test_MHTMLDocument(void)
|
||||
{
|
||||
IHTMLDocument2 *doc;
|
||||
IOleObject *oleobj;
|
||||
HRESULT hres;
|
||||
|
||||
if(!is_ie9plus) {
|
||||
win_skip("Skipping MHTML document tests on too old IE.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trace("Testing MHTMLDocument...\n");
|
||||
|
||||
init_test(LD_DOLOAD);
|
||||
is_mhtml = TRUE;
|
||||
nav_url = nav_serv_url = "mhtml:winetest:doc";
|
||||
|
||||
hres = CoCreateInstance(&CLSID_MHTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||
&IID_IHTMLDocument2, (void**)&doc);
|
||||
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
|
||||
|
||||
doc_unk = (IUnknown*)doc;
|
||||
|
||||
test_QueryInterface(doc);
|
||||
test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
|
||||
test_ViewAdviseSink(doc);
|
||||
test_ConnectionPointContainer(doc);
|
||||
|
||||
hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
|
||||
ok(hres == S_OK, "Could not get IOleObject iface: %08x\n", hres);
|
||||
test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
|
||||
test_DoVerb(oleobj);
|
||||
IOleObject_Release(oleobj);
|
||||
|
||||
test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
|
||||
test_Persist(doc, &Moniker);
|
||||
set_custom_uihandler(doc, &CustomDocHostUIHandler);
|
||||
test_GetCurMoniker((IUnknown*)doc, NULL, "mhtml:winetest:doc", FALSE);
|
||||
test_download(0);
|
||||
|
||||
test_exec_onunload(doc);
|
||||
test_UIDeactivate();
|
||||
test_InPlaceDeactivate(doc, TRUE);
|
||||
test_InPlaceDeactivate(doc, FALSE);
|
||||
test_CloseView();
|
||||
test_Close(doc, TRUE);
|
||||
|
||||
if(view)
|
||||
IOleDocumentView_Release(view);
|
||||
view = NULL;
|
||||
|
||||
release_document(doc);
|
||||
}
|
||||
|
||||
static void test_HTMLDocument_hlink(DWORD status)
|
||||
{
|
||||
IHTMLDocument2 *doc;
|
||||
@ -8634,6 +8735,7 @@ START_TEST(htmldoc)
|
||||
test_HTMLDocument(TRUE, TRUE);
|
||||
test_HTMLDocument_StreamLoad();
|
||||
test_HTMLDocument_StreamInitNew();
|
||||
test_MHTMLDocument();
|
||||
test_editing_mode(FALSE, FALSE);
|
||||
test_editing_mode(TRUE, FALSE);
|
||||
test_editing_mode(TRUE, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user