Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
6537c36d
Commit
6537c36d
authored
Jul 28, 2022
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Jul 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Implement responseType prop for XMLHttpRequest.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
fab55e22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
5 deletions
+110
-5
xhr.js
dlls/mshtml/tests/xhr.js
+56
-1
xmlhttprequest.c
dlls/mshtml/xmlhttprequest.c
+54
-4
No files found.
dlls/mshtml/tests/xhr.js
View file @
6537c36d
...
...
@@ -191,9 +191,64 @@ function test_timeout() {
xhr
.
send
(
"Timeout Test"
);
}
function
test_responseType
()
{
var
i
,
xhr
=
new
XMLHttpRequest
();
if
(
!
(
"responseType"
in
xhr
))
{
next_test
();
return
;
}
ok
(
xhr
.
responseType
===
""
,
"default responseType = "
+
xhr
.
responseType
);
try
{
xhr
.
responseType
=
""
;
ok
(
false
,
"setting responseType before open() did not throw exception"
);
}
catch
(
ex
)
{
todo_wine
.
ok
(
ex
.
name
===
"InvalidStateError"
,
"setting responseType before open() threw "
+
ex
.
name
);
}
try
{
xhr
.
responseType
=
"invalid response type"
;
ok
(
false
,
"setting invalid responseType before open() did not throw exception"
);
}
catch
(
ex
)
{
todo_wine
.
ok
(
ex
.
name
===
"InvalidStateError"
,
"setting invalid responseType before open() threw "
+
ex
.
name
);
}
xhr
.
open
(
"POST"
,
"echo.php"
,
true
);
xhr
.
setRequestHeader
(
"X-Test"
,
"True"
);
ok
(
xhr
.
responseType
===
""
,
"default responseType after open() = "
+
xhr
.
responseType
);
var
types
=
[
"text"
,
""
,
"document"
,
"arraybuffer"
,
"blob"
,
"ms-stream"
];
for
(
i
=
0
;
i
<
types
.
length
;
i
++
)
{
xhr
.
responseType
=
types
[
i
];
ok
(
xhr
.
responseType
===
types
[
i
],
"responseType = "
+
xhr
.
responseType
+
", expected "
+
types
[
i
]);
}
types
=
[
"json"
,
"teXt"
,
"Document"
,
"moz-chunked-text"
,
"moz-blob"
,
null
];
for
(
i
=
0
;
i
<
types
.
length
;
i
++
)
{
xhr
.
responseType
=
types
[
i
];
ok
(
xhr
.
responseType
===
"ms-stream"
,
"responseType (after set to "
+
types
[
i
]
+
") = "
+
xhr
.
responseType
);
}
xhr
.
responseType
=
""
;
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
<
3
)
{
xhr
.
responseType
=
""
;
return
;
}
try
{
xhr
.
responseType
=
""
;
ok
(
false
,
"setting responseType with state "
+
xhr
.
readyState
+
" did not throw exception"
);
}
catch
(
ex
)
{
todo_wine
.
ok
(
ex
.
name
===
"InvalidStateError"
,
"setting responseType with state "
+
xhr
.
readyState
+
" threw "
+
ex
.
name
);
}
}
xhr
.
onloadend
=
function
()
{
next_test
();
}
xhr
.
send
(
"responseType test"
);
}
var
tests
=
[
test_xhr
,
test_content_types
,
test_abort
,
test_timeout
test_timeout
,
test_responseType
];
dlls/mshtml/xmlhttprequest.c
View file @
6537c36d
...
...
@@ -103,6 +103,27 @@ static const eventid_t events[] = {
EVENTID_TIMEOUT
,
};
typedef
enum
{
response_type_empty
,
response_type_text
,
response_type_doc
,
response_type_arraybuf
,
response_type_blob
,
response_type_stream
}
response_type_t
;
static
const
struct
{
const
WCHAR
*
str
;
const
WCHAR
*
nsxhr_str
;
}
response_type_desc
[]
=
{
[
response_type_empty
]
=
{
L""
,
L""
},
[
response_type_text
]
=
{
L"text"
,
L""
},
[
response_type_doc
]
=
{
L"document"
,
L""
},
/* FIXME */
[
response_type_arraybuf
]
=
{
L"arraybuffer"
,
L"arraybuffer"
},
[
response_type_blob
]
=
{
L"blob"
,
L"arraybuffer"
},
[
response_type_stream
]
=
{
L"ms-stream"
,
L"arraybuffer"
}
/* FIXME */
};
typedef
struct
{
nsIDOMEventListener
nsIDOMEventListener_iface
;
LONG
ref
;
...
...
@@ -117,6 +138,7 @@ struct HTMLXMLHttpRequest {
IWineXMLHttpRequestPrivate
IWineXMLHttpRequestPrivate_iface
;
IProvideClassInfo2
IProvideClassInfo2_iface
;
LONG
ref
;
response_type_t
response_type
;
nsIXMLHttpRequest
*
nsxhr
;
XMLHttpReqEventListener
*
event_listener
;
};
...
...
@@ -925,19 +947,47 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_get_response(IWineXMLHttpReques
static
HRESULT
WINAPI
HTMLXMLHttpRequest_private_put_responseType
(
IWineXMLHttpRequestPrivate
*
iface
,
BSTR
v
)
{
HTMLXMLHttpRequest
*
This
=
impl_from_IWineXMLHttpRequestPrivate
(
iface
);
nsAString
nsstr
;
nsresult
nsres
;
HRESULT
hres
;
unsigned
i
;
LONG
state
;
FIXM
E
(
"(%p)->(%s)
\n
"
,
This
,
debugstr_w
(
v
));
TRAC
E
(
"(%p)->(%s)
\n
"
,
This
,
debugstr_w
(
v
));
return
E_NOTIMPL
;
hres
=
IHTMLXMLHttpRequest_get_readyState
(
&
This
->
IHTMLXMLHttpRequest_iface
,
&
state
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
state
<
1
||
state
>
2
)
{
/* FIXME: Return InvalidStateError */
return
E_FAIL
;
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
response_type_desc
);
i
++
)
if
(
!
wcscmp
(
v
,
response_type_desc
[
i
].
str
))
break
;
if
(
i
>=
ARRAY_SIZE
(
response_type_desc
))
return
S_OK
;
nsAString_InitDepend
(
&
nsstr
,
response_type_desc
[
i
].
nsxhr_str
);
nsres
=
nsIXMLHttpRequest_SetResponseType
(
This
->
nsxhr
,
&
nsstr
);
nsAString_Finish
(
&
nsstr
);
if
(
NS_FAILED
(
nsres
))
return
map_nsresult
(
nsres
);
This
->
response_type
=
i
;
return
S_OK
;
}
static
HRESULT
WINAPI
HTMLXMLHttpRequest_private_get_responseType
(
IWineXMLHttpRequestPrivate
*
iface
,
BSTR
*
p
)
{
HTMLXMLHttpRequest
*
This
=
impl_from_IWineXMLHttpRequestPrivate
(
iface
);
FIXM
E
(
"(%p)->(%p)
\n
"
,
This
,
p
);
TRAC
E
(
"(%p)->(%p)
\n
"
,
This
,
p
);
return
E_NOTIMPL
;
*
p
=
SysAllocString
(
response_type_desc
[
This
->
response_type
].
str
);
return
*
p
?
S_OK
:
E_OUTOFMEMORY
;
}
static
HRESULT
WINAPI
HTMLXMLHttpRequest_private_get_upload
(
IWineXMLHttpRequestPrivate
*
iface
,
IDispatch
**
p
)
...
...
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