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
497e9d61
Commit
497e9d61
authored
Feb 05, 2024
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Feb 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Implement `origin` prop for MessageEvents.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
266ac9a8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
6 deletions
+63
-6
htmlevent.c
dlls/mshtml/htmlevent.c
+47
-6
documentmode.js
dlls/mshtml/tests/documentmode.js
+1
-0
events.c
dlls/mshtml/tests/events.c
+13
-0
events.js
dlls/mshtml/tests/events.js
+2
-0
No files found.
dlls/mshtml/htmlevent.c
View file @
497e9d61
...
...
@@ -25,6 +25,7 @@
#include "winuser.h"
#include "ole2.h"
#include "mshtmdid.h"
#include "wininet.h"
#include "mshtml_private.h"
#include "htmlevent.h"
...
...
@@ -1876,11 +1877,19 @@ static HRESULT WINAPI HTMLEventObj5_put_origin(IHTMLEventObj5 *iface, BSTR v)
static
HRESULT
WINAPI
HTMLEventObj5_get_origin
(
IHTMLEventObj5
*
iface
,
BSTR
*
p
)
{
HTMLEventObj
*
This
=
impl_from_IHTMLEventObj5
(
iface
);
IDOMMessageEvent
*
message_event
;
HRESULT
hres
;
FIXM
E
(
"(%p)->(%p)
\n
"
,
This
,
p
);
TRAC
E
(
"(%p)->(%p)
\n
"
,
This
,
p
);
*
p
=
NULL
;
return
S_OK
;
if
(
!
This
->
event
||
FAILED
(
IDOMEvent_QueryInterface
(
&
This
->
event
->
IDOMEvent_iface
,
&
IID_IDOMMessageEvent
,
(
void
**
)
&
message_event
)))
{
*
p
=
NULL
;
return
S_OK
;
}
hres
=
IDOMMessageEvent_get_origin
(
message_event
,
p
);
IDOMMessageEvent_Release
(
message_event
);
return
hres
;
}
static
HRESULT
WINAPI
HTMLEventObj5_put_issession
(
IHTMLEventObj5
*
iface
,
VARIANT_BOOL
v
)
...
...
@@ -3669,6 +3678,7 @@ typedef struct {
DOMEvent
event
;
IDOMMessageEvent
IDOMMessageEvent_iface
;
IHTMLWindow2
*
source
;
BSTR
origin
;
VARIANT
data
;
}
DOMMessageEvent
;
...
...
@@ -3756,8 +3766,14 @@ static HRESULT DOMMessageEvent_get_data_hook(DispatchEx *dispex, WORD flags, DIS
static
HRESULT
WINAPI
DOMMessageEvent_get_origin
(
IDOMMessageEvent
*
iface
,
BSTR
*
p
)
{
DOMMessageEvent
*
This
=
impl_from_IDOMMessageEvent
(
iface
);
FIXME
(
"(%p)->(%p)
\n
"
,
This
,
p
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
p
);
if
(
This
->
origin
)
return
(
*
p
=
SysAllocStringLen
(
This
->
origin
,
SysStringLen
(
This
->
origin
)))
?
S_OK
:
E_OUTOFMEMORY
;
*
p
=
NULL
;
return
S_OK
;
}
static
HRESULT
WINAPI
DOMMessageEvent_get_source
(
IDOMMessageEvent
*
iface
,
IHTMLWindow2
**
p
)
...
...
@@ -3829,6 +3845,7 @@ static void DOMMessageEvent_unlink(DispatchEx *dispex)
static
void
DOMMessageEvent_destructor
(
DispatchEx
*
dispex
)
{
DOMMessageEvent
*
message_event
=
DOMMessageEvent_from_DOMEvent
(
DOMEvent_from_DispatchEx
(
dispex
));
SysFreeString
(
message_event
->
origin
);
VariantClear
(
&
message_event
->
data
);
DOMEvent_destructor
(
dispex
);
}
...
...
@@ -4601,14 +4618,38 @@ HRESULT create_document_event(HTMLDocumentNode *doc, eventid_t event_id, DOMEven
HRESULT
create_message_event
(
HTMLDocumentNode
*
doc
,
IHTMLWindow2
*
source
,
VARIANT
*
data
,
DOMEvent
**
ret
)
{
URL_COMPONENTSW
url
=
{
sizeof
(
url
)
};
DOMMessageEvent
*
message_event
;
IHTMLLocation
*
location
;
DOMEvent
*
event
;
HRESULT
hres
;
BSTR
origin
;
hres
=
create_document_event
(
doc
,
EVENTID_MESSAGE
,
&
event
);
hres
=
IHTMLWindow2_get_location
(
source
,
&
location
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
IHTMLLocation_get_href
(
location
,
&
origin
);
IHTMLLocation_Release
(
location
);
if
(
FAILED
(
hres
))
return
hres
;
url
.
dwUrlPathLength
=
1
;
if
(
origin
&&
InternetCrackUrlW
(
origin
,
0
,
0
,
&
url
))
{
BSTR
tmp
=
SysAllocStringLen
(
origin
,
url
.
lpszUrlPath
-
origin
);
SysFreeString
(
origin
);
if
(
!
tmp
)
return
E_OUTOFMEMORY
;
origin
=
tmp
;
}
hres
=
create_document_event
(
doc
,
EVENTID_MESSAGE
,
&
event
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
origin
);
return
hres
;
}
message_event
=
DOMMessageEvent_from_DOMEvent
(
event
);
message_event
->
origin
=
origin
;
V_VT
(
&
message_event
->
data
)
=
VT_EMPTY
;
hres
=
VariantCopy
(
&
message_event
->
data
,
data
);
...
...
dlls/mshtml/tests/documentmode.js
View file @
497e9d61
...
...
@@ -2929,6 +2929,7 @@ async_test("postMessage", function() {
else
{
ok
(
e
.
data
===
(
v
<
10
?
"10"
:
10
),
"e.data = "
+
e
.
data
);
ok
(
e
.
source
===
window
,
"e.source = "
+
e
.
source
);
ok
(
e
.
origin
===
"http://winetest.example.org"
,
"e.origin = "
+
e
.
origin
);
next_test
();
}
}
...
...
dlls/mshtml/tests/events.c
View file @
497e9d61
...
...
@@ -1542,6 +1542,11 @@ static HRESULT WINAPI onmessage(IDispatchEx *iface, DISPID id, LCID lcid, WORD w
ok
(
!
wcscmp
(
bstr
,
L"foobar"
),
"data = %s
\n
"
,
wine_dbgstr_w
(
bstr
));
SysFreeString
(
bstr
);
hres
=
IHTMLEventObj5_get_origin
(
event_obj5
,
&
bstr
);
ok
(
hres
==
S_OK
,
"get_origin failed: %08lx
\n
"
,
hres
);
ok
(
!
wcscmp
(
bstr
,
L"about:"
),
"origin = %s
\n
"
,
wine_dbgstr_w
(
bstr
));
SysFreeString
(
bstr
);
hres
=
IHTMLEventObj5_get_source
(
event_obj5
,
&
disp
);
ok
(
hres
==
S_OK
,
"get_source failed: %08lx
\n
"
,
hres
);
...
...
@@ -1558,6 +1563,9 @@ static HRESULT WINAPI onmessage(IDispatchEx *iface, DISPID id, LCID lcid, WORD w
bstr
=
SysAllocString
(
L"foobar"
);
hres
=
IHTMLEventObj5_put_url
(
event_obj5
,
bstr
);
ok
(
hres
==
DISP_E_MEMBERNOTFOUND
,
"put_url returned: %08lx
\n
"
,
hres
);
hres
=
IHTMLEventObj5_put_origin
(
event_obj5
,
bstr
);
ok
(
hres
==
DISP_E_MEMBERNOTFOUND
,
"put_origin returned: %08lx
\n
"
,
hres
);
SysFreeString
(
bstr
);
IHTMLEventObj5_Release
(
event_obj5
);
...
...
@@ -1572,6 +1580,11 @@ static HRESULT WINAPI onmessage(IDispatchEx *iface, DISPID id, LCID lcid, WORD w
ok
(
!
wcscmp
(
bstr
,
L"foobar"
),
"data = %s
\n
"
,
wine_dbgstr_w
(
bstr
));
SysFreeString
(
bstr
);
hres
=
IDOMMessageEvent_get_origin
(
msg
,
&
bstr
);
ok
(
hres
==
S_OK
,
"get_origin failed: %08lx
\n
"
,
hres
);
ok
(
!
wcscmp
(
bstr
,
L"about:"
),
"origin = %s
\n
"
,
wine_dbgstr_w
(
bstr
));
SysFreeString
(
bstr
);
hres
=
IDOMMessageEvent_get_source
(
msg
,
&
source
);
ok
(
hres
==
S_OK
,
"get_source failed: %08lx
\n
"
,
hres
);
ok
(
source
==
onmessage_source
,
"source != onmessage_source
\n
"
);
...
...
dlls/mshtml/tests/events.js
View file @
497e9d61
...
...
@@ -830,6 +830,7 @@ async_test("message event", function() {
if
(
listener_called
)
{
ok
(
e
.
data
===
"echo"
,
"e.data (diff origin) = "
+
e
.
data
);
ok
(
e
.
source
===
iframe
.
contentWindow
,
"e.source (diff origin) not iframe.contentWindow"
);
ok
(
e
.
origin
===
"http://winetest.different.org:1234"
,
"e.origin (diff origin) = "
+
e
.
origin
);
next_test
();
return
;
}
...
...
@@ -838,6 +839,7 @@ async_test("message event", function() {
ok
(
e
.
bubbles
===
false
,
"bubbles = "
+
e
.
bubbles
);
ok
(
e
.
cancelable
===
false
,
"cancelable = "
+
e
.
cancelable
);
ok
(
e
.
source
===
window
,
"e.source = "
+
e
.
source
);
ok
(
e
.
origin
===
"http://winetest.example.org"
,
"e.origin = "
+
e
.
origin
);
iframe
.
onload
=
function
()
{
iframe
.
contentWindow
.
postMessage
(
"echo"
,
"hTtP://WinEtesT.difFerent.ORG:1234"
);
}
iframe
.
src
=
"http://winetest.different.org:1234/xhr_iframe.html"
;
...
...
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