Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f48709cf
Commit
f48709cf
authored
Jul 29, 2022
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Jul 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Handle lack of window in methods for detached documents.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
144b30d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
4 deletions
+75
-4
htmldoc.c
dlls/mshtml/htmldoc.c
+21
-4
dom.c
dlls/mshtml/tests/dom.c
+54
-0
No files found.
dlls/mshtml/htmldoc.c
View file @
f48709cf
...
...
@@ -877,7 +877,7 @@ static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSel
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
p
);
nsres
=
nsIDOM
Window_GetSelection
(
This
->
window
->
nswindow
,
&
nsselection
);
nsres
=
nsIDOM
HTMLDocument_GetSelection
(
This
->
doc_node
->
nsdoc
,
&
nsselection
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"GetSelection failed: %08lx
\n
"
,
nsres
);
return
E_FAIL
;
...
...
@@ -896,7 +896,7 @@ static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p
if
(
!
p
)
return
E_POINTER
;
return
get_readystate_string
(
This
->
window
->
readystate
,
p
);
return
get_readystate_string
(
This
->
window
?
This
->
window
->
readystate
:
0
,
p
);
}
static
HRESULT
WINAPI
HTMLDocument_get_frames
(
IHTMLDocument2
*
iface
,
IHTMLFramesCollection2
**
p
)
...
...
@@ -905,6 +905,10 @@ static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFrames
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
p
);
if
(
!
This
->
window
)
{
/* Not implemented by IE */
return
E_NOTIMPL
;
}
return
IHTMLWindow2_get_frames
(
&
This
->
window
->
base
.
IHTMLWindow2_iface
,
p
);
}
...
...
@@ -1087,7 +1091,7 @@ static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
TRACE
(
"(%p)->(%p)
\n
"
,
iface
,
p
);
*
p
=
SysAllocString
(
This
->
window
->
url
?
This
->
window
->
url
:
L"about:blank"
);
*
p
=
SysAllocString
(
This
->
window
&&
This
->
window
->
url
?
This
->
window
->
url
:
L"about:blank"
);
return
*
p
?
S_OK
:
E_OUTOFMEMORY
;
}
...
...
@@ -1143,6 +1147,9 @@ static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
TRACE
(
"(%p)->(%s)
\n
"
,
This
,
debugstr_w
(
v
));
if
(
!
This
->
window
)
return
S_OK
;
bret
=
InternetSetCookieExW
(
This
->
window
->
url
,
NULL
,
v
,
0
,
0
);
if
(
!
bret
)
{
FIXME
(
"InternetSetCookieExW failed: %lu
\n
"
,
GetLastError
());
...
...
@@ -1160,6 +1167,11 @@ static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
p
);
if
(
!
This
->
window
)
{
*
p
=
NULL
;
return
S_OK
;
}
size
=
0
;
bret
=
InternetGetCookieExW
(
This
->
window
->
url
,
NULL
,
NULL
,
&
size
,
0
,
NULL
);
if
(
!
bret
&&
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
{
...
...
@@ -1380,6 +1392,11 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT
TRACE
(
"(%p)->(%s %s %s %s %p)
\n
"
,
This
,
debugstr_w
(
url
),
debugstr_variant
(
&
name
),
debugstr_variant
(
&
features
),
debugstr_variant
(
&
replace
),
pomWindowResult
);
*
pomWindowResult
=
NULL
;
if
(
!
This
->
window
)
return
E_FAIL
;
if
(
!
This
->
doc_node
->
nsdoc
)
{
ERR
(
"!nsdoc
\n
"
);
return
E_NOTIMPL
;
...
...
@@ -2263,7 +2280,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
p
);
if
(
This
->
window
->
readystate
==
READYSTATE_UNINITIALIZED
)
{
if
(
This
->
window
&&
This
->
window
->
readystate
==
READYSTATE_UNINITIALIZED
)
{
*
p
=
NULL
;
return
S_OK
;
}
...
...
dlls/mshtml/tests/dom.c
View file @
f48709cf
...
...
@@ -7322,10 +7322,14 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
hres
=
IHTMLDOMImplementation_QueryInterface
(
dom_implementation
,
&
IID_IHTMLDOMImplementation2
,
(
void
**
)
&
dom_implementation2
);
if
(
SUCCEEDED
(
hres
))
{
IHTMLSelectionObject
*
selection
;
IHTMLFramesCollection2
*
frames
;
IHTMLDocument2
*
new_document2
;
IHTMLDocument3
*
new_document3
;
IHTMLDocument7
*
new_document
;
IHTMLLocation
*
location
;
IHTMLWindow2
*
window
;
IHTMLElement
*
elem
;
VARIANT
v
;
IDispatch
*
disp
;
...
...
@@ -7334,6 +7338,7 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
str
=
SysAllocString
(
L"test"
);
hres
=
IHTMLDOMImplementation2_createHTMLDocument
(
dom_implementation2
,
str
,
&
new_document
);
ok
(
hres
==
S_OK
,
"createHTMLDocument failed: %08lx
\n
"
,
hres
);
SysFreeString
(
str
);
test_disp
((
IUnknown
*
)
new_document
,
&
DIID_DispHTMLDocument
,
&
CLSID_HTMLDocument
,
L"[object]"
);
test_ifaces
((
IUnknown
*
)
new_document
,
doc_node_iids
);
...
...
@@ -7349,15 +7354,63 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
hres
=
IHTMLDocument7_QueryInterface
(
new_document
,
&
IID_IHTMLDocument2
,
(
void
**
)
&
new_document2
);
ok
(
hres
==
S_OK
,
"Could not get IHTMLDocument2 iface: %08lx
\n
"
,
hres
);
hres
=
IHTMLDocument7_QueryInterface
(
new_document
,
&
IID_IHTMLDocument3
,
(
void
**
)
&
new_document3
);
ok
(
hres
==
S_OK
,
"Could not get IHTMLDocument3 iface: %08lx
\n
"
,
hres
);
hres
=
IHTMLDocument2_get_parentWindow
(
new_document2
,
&
window
);
ok
(
hres
==
E_FAIL
,
"get_parentWindow returned: %08lx
\n
"
,
hres
);
hres
=
IHTMLDocument2_get_readyState
(
new_document2
,
&
str
);
ok
(
hres
==
S_OK
,
"get_readyState returned: %08lx
\n
"
,
hres
);
ok
(
!
lstrcmpW
(
str
,
L"uninitialized"
),
"readyState = %s
\n
"
,
wine_dbgstr_w
(
str
));
SysFreeString
(
str
);
hres
=
IHTMLDocument2_get_Script
(
new_document2
,
&
disp
);
ok
(
hres
==
E_PENDING
,
"get_Script returned: %08lx
\n
"
,
hres
);
str
=
SysAllocString
(
L"test=testval"
);
hres
=
IHTMLDocument2_put_cookie
(
new_document2
,
str
);
ok
(
hres
==
S_OK
,
"put_cookie returned: %08lx
\n
"
,
hres
);
SysFreeString
(
str
);
hres
=
IHTMLDocument2_get_cookie
(
doc
,
&
str
);
ok
(
hres
==
S_OK
,
"get_cookie returned: %08lx
\n
"
,
hres
);
ok
(
str
==
NULL
,
"cookie = %s
\n
"
,
wine_dbgstr_w
(
str
));
SysFreeString
(
str
);
hres
=
IHTMLDocument3_get_documentElement
(
new_document3
,
&
elem
);
ok
(
hres
==
S_OK
,
"get_documentElement returned: %08lx
\n
"
,
hres
);
ok
(
elem
!=
NULL
,
"documentElement = NULL
\n
"
);
IHTMLElement_Release
(
elem
);
hres
=
IHTMLDocument2_get_frames
(
new_document2
,
&
frames
);
ok
(
hres
==
E_NOTIMPL
,
"get_frames returned: %08lx
\n
"
,
hres
);
hres
=
IHTMLDocument2_get_location
(
new_document2
,
&
location
);
ok
(
hres
==
E_UNEXPECTED
,
"get_location returned: %08lx
\n
"
,
hres
);
hres
=
IHTMLDocument2_get_selection
(
new_document2
,
&
selection
);
ok
(
hres
==
S_OK
,
"get_selection returned: %08lx
\n
"
,
hres
);
ok
(
selection
!=
NULL
,
"selection = NULL
\n
"
);
hres
=
IHTMLSelectionObject_get_type
(
selection
,
&
str
);
ok
(
hres
==
S_OK
,
"selection get_type returned: %08lx
\n
"
,
hres
);
ok
(
!
lstrcmpW
(
str
,
L"None"
),
"selection type = %s
\n
"
,
wine_dbgstr_w
(
str
));
IHTMLSelectionObject_Release
(
selection
);
SysFreeString
(
str
);
hres
=
IHTMLDocument2_get_URL
(
new_document2
,
&
str
);
ok
(
hres
==
S_OK
,
"get_URL returned: %08lx
\n
"
,
hres
);
ok
(
!
lstrcmpW
(
str
,
L"about:blank"
),
"URL = %s
\n
"
,
wine_dbgstr_w
(
str
));
SysFreeString
(
str
);
str
=
SysAllocString
(
L"text/html"
);
V_VT
(
&
v
)
=
VT_ERROR
;
disp
=
(
IDispatch
*
)
0xdeadbeef
;
hres
=
IHTMLDocument2_open
(
new_document2
,
str
,
v
,
v
,
v
,
&
disp
);
ok
(
hres
==
E_FAIL
,
"open returned: %08lx
\n
"
,
hres
);
ok
(
disp
==
NULL
,
"disp = %p
\n
"
,
disp
);
SysFreeString
(
str
);
memset
(
&
v
,
0xcc
,
sizeof
(
v
));
hres
=
IHTMLDocument7_get_onmsthumbnailclick
(
new_document
,
&
v
);
ok
(
hres
==
S_OK
,
"get_onmsthumbnailclick returned: %08lx
\n
"
,
hres
);
...
...
@@ -7365,6 +7418,7 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
ok
((
DWORD
)(
DWORD_PTR
)
V_DISPATCH
(
&
v
)
==
0xcccccccc
,
"got %p
\n
"
,
V_DISPATCH
(
&
v
));
IHTMLDocument2_Release
(
new_document2
);
IHTMLDocument3_Release
(
new_document3
);
IHTMLDocument7_Release
(
new_document
);
IHTMLDOMImplementation2_Release
(
dom_implementation2
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment