[PATCH 2/2] mshtml v2: non-HTML resources accessed through the res:// protocol have resource type 2110
Damjan Jovanovic
damjan.jov at gmail.com
Fri Apr 10 06:30:31 CDT 2020
Try 2 adds tests.
On https://docs.microsoft.com/en-us/previous-versions//aa767740(v=vs.85)
they only mention resource types RT_HTML and the completely undocumented
RT_FILE, so by a process of elimination, the 2110 magic number
is probably RT_FILE.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47999
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
dlls/mshtml/protocol.c | 5 ++++
dlls/mshtml/tests/image.gif | Bin 0 -> 1144 bytes
dlls/mshtml/tests/protocol.c | 55 +++++++++++++++++++++++++++++++++--
dlls/mshtml/tests/rsrc.rc | 12 ++++++++
4 files changed, 69 insertions(+), 3 deletions(-)
create mode 100644 dlls/mshtml/tests/image.gif
-------------- next part --------------
diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index 0f06896c49..8612e05bf1 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -608,11 +608,16 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
TRACE("trying to find resource type %s, name %s\n", debugstr_w(res_type), debugstr_w(url_file));
src = FindResourceW(hdll, url_file, res_type);
+ /* Non-HTML resources accessed through the res:// protocol have resource type 2110: */
+ if(!src)
+ src = FindResourceW(hdll, url_file, MAKEINTRESOURCEW(2110));
if(!src) {
LPWSTR endpoint = NULL;
DWORD file_id = wcstol(url_file, &endpoint, 10);
if(endpoint == url_file+lstrlenW(url_file))
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), res_type);
+ if(!src)
+ src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), MAKEINTRESOURCEW(2110));
if(!src) {
WARN("Could not find resource\n");
diff --git a/dlls/mshtml/tests/image.gif b/dlls/mshtml/tests/image.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2f185027c30b7b2329572c5314bf362da1798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
zFDI}p^zf_wZk|!HlTY)9jx+T=?}5U3#5^sexcZ;@%Vg=JlVaY=4k$~{aH72ujRmYe
zFU25zz+8X+DOuu~8m at g&bc{&}cq3MtZbH7bqz&80;>x>iGM`xNN|*PgvcQ-;d05C5
z3yX&|9sZKf``Xx%R62U`MohBH$^oMF?PT<ZKRgr)f1U6Pmn<Hp-aTdduC^jq^N0AG
zc#q&3jGP-Yo)}*e_Jvzwiw8N?n#-`hIy4_O{HVb7<k(zjHlI~!n)NA+jeGq(i3IQb
E3#BK$LI3~&
literal 0
HcmV?d00001
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c
index ba767d21c6..5f9f1bf0db 100644
--- a/dlls/mshtml/tests/protocol.c
+++ b/dlls/mshtml/tests/protocol.c
@@ -68,6 +68,7 @@ DEFINE_EXPECT(outer_QI_test);
static HRESULT expect_hrResult;
static BOOL expect_hr_win32err = FALSE;
+static const WCHAR *expect_mime_type = NULL;
static DWORD bindf;
static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
@@ -109,14 +110,13 @@ static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOL
static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
LPCWSTR szStatusText)
{
- static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
-
CHECK_EXPECT(ReportProgress);
ok(ulStatusCode == BINDSTATUS_MIMETYPEAVAILABLE
|| ulStatusCode == BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
"ulStatusCode=%d\n", ulStatusCode);
- ok(!lstrcmpW(szStatusText, text_html), "szStatusText != text/html\n");
+ ok(!lstrcmpW(szStatusText, expect_mime_type), "szStatusText: expected %s, got %s\n",
+ wine_dbgstr_w(expect_mime_type), wine_dbgstr_w(szStatusText));
return S_OK;
}
@@ -224,6 +224,7 @@ static IInternetBindInfo bind_info = {
static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres,
BOOL expect_win32err)
{
+ static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
HRESULT hres;
SET_EXPECT(GetBindInfo);
@@ -231,6 +232,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT
expect_hrResult = expected_hres;
expect_hr_win32err = expect_win32err;
+ expect_mime_type = text_html;
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
if(expect_win32err)
ok((hres&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || hres == expect_hrResult,
@@ -244,6 +246,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT
static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
{
+ static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
HRESULT hres;
SET_EXPECT(GetBindInfo);
@@ -252,6 +255,7 @@ static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
SET_EXPECT(ReportData);
expect_hrResult = S_OK;
expect_hr_win32err = FALSE;
+ expect_mime_type = text_html;
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
ok(hres == S_OK, "Start failed: %08x\n", hres);
@@ -262,6 +266,45 @@ static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
CHECK_CALLED(ReportResult);
}
+static void test_res_url_fail(const char *url_suffix, HRESULT expected_hres,
+ BOOL expect_win32err, LPCWSTR expected_mime_type)
+{
+ WCHAR url[INTERNET_MAX_URL_LENGTH];
+ IInternetProtocol *protocol;
+ HRESULT hres;
+
+ memcpy(url, res_url_base, res_url_base_len*sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, url_suffix, -1, url+res_url_base_len, ARRAY_SIZE(url)-res_url_base_len);
+
+ hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol);
+ ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres);
+
+ SET_EXPECT(GetBindInfo);
+ SET_EXPECT(ReportResult);
+ if (SUCCEEDED(expected_hres)) {
+ SET_EXPECT(ReportProgress);
+ SET_EXPECT(ReportData);
+ }
+ expect_hrResult = expected_hres;
+ expect_hr_win32err = expect_win32err;
+ expect_mime_type = expected_mime_type;
+ hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
+ if (expect_win32err)
+ ok((hres&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || hres == expected_hres,
+ "expected win32 err or %08x got: %08x\n", expected_hres, hres);
+ else
+ ok(hres == expected_hres, "expected: %08x got: %08x\n", expected_hres, hres);
+
+
+ CHECK_CALLED(GetBindInfo);
+ if (SUCCEEDED(expected_hres)) {
+ CHECK_CALLED(ReportProgress);
+ CHECK_CALLED(ReportData);
+ }
+ CHECK_CALLED(ReportResult);
+ IInternetProtocol_Release(protocol);
+}
+
static void test_res_url(const char *url_suffix)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
@@ -323,6 +366,7 @@ static void test_res_protocol(void)
IClassFactory *factory;
HRESULT hres;
+ static const WCHAR image_gif[] = {'i','m','a','g','e','/','g','i','f',0};
static const WCHAR blank_url[] =
{'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR test_part_url[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0};
@@ -600,6 +644,11 @@ static void test_res_protocol(void)
test_res_url("/Test/res.html");
test_res_url("/test/dir/dir2/res.html");
+ test_res_url_fail("/image-bitmap.gif", HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), TRUE, image_gif);
+ test_res_url_fail("/image-data.gif", HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), TRUE, image_gif);
+ test_res_url_fail("/image-html.gif", S_OK, FALSE, image_gif);
+ test_res_url_fail("/image-2110.gif", S_OK, FALSE, image_gif);
+
if(GetProcAddress(GetModuleHandleA("urlmon.dll"), "CreateUri")) {
test_res_url("/test/dir/dir2/res.html?query_part");
test_res_url("/test/dir/dir2/res.html#hash_part");
diff --git a/dlls/mshtml/tests/rsrc.rc b/dlls/mshtml/tests/rsrc.rc
index 05bc836ac6..928791f515 100644
--- a/dlls/mshtml/tests/rsrc.rc
+++ b/dlls/mshtml/tests/rsrc.rc
@@ -80,3 +80,15 @@ res.html test "jstest.html"
/* @makedep: jstest.html */
dir/dir2/res.html test "jstest.html"
+
+/* @makedep: image.gif */
+image-bitmap.gif RCDATA "image.gif"
+
+/* @makedep: image.gif */
+image-data.gif RCDATA "image.gif"
+
+/* @makedep: image.gif */
+image-html.gif HTML "image.gif"
+
+/* @makedep: image.gif */
+image-2110.gif 2110 "image.gif"
More information about the wine-devel
mailing list