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
ae8cb5a1
Commit
ae8cb5a1
authored
Aug 04, 2010
by
Jacek Caban
Committed by
Alexandre Julliard
Aug 04, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Fixed Error.toString implementation for non-Error this.
parent
04819e90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
15 deletions
+61
-15
error.c
dlls/jscript/error.c
+28
-15
api.js
dlls/jscript/tests/api.js
+33
-0
No files found.
dlls/jscript/error.c
View file @
ae8cb5a1
...
...
@@ -47,39 +47,45 @@ static inline ErrorInstance *error_this(vdisp_t *jsthis)
}
/* ECMA-262 3rd Edition 15.11.4.4 */
static
HRESULT
Error_toString
(
script_ctx_t
*
ctx
,
vdisp_t
*
js
this
,
WORD
flags
,
static
HRESULT
Error_toString
(
script_ctx_t
*
ctx
,
vdisp_t
*
v
this
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
caller
)
{
ErrorInstance
*
error
;
BSTR
name
,
msg
=
NULL
,
ret
=
NULL
;
DispatchEx
*
jsthis
;
BSTR
name
=
NULL
,
msg
=
NULL
,
ret
=
NULL
;
VARIANT
v
;
HRESULT
hres
;
static
const
WCHAR
str
[]
=
{
'['
,
'o'
,
'b'
,
'j'
,
'e'
,
'c'
,
't'
,
' '
,
'E'
,
'r'
,
'r'
,
'o'
,
'r'
,
']'
,
0
};
static
const
WCHAR
object_errorW
[]
=
{
'['
,
'o'
,
'b'
,
'j'
,
'e'
,
'c'
,
't'
,
' '
,
'E'
,
'r'
,
'r'
,
'o'
,
'r'
,
']'
,
0
};
TRACE
(
"
\n
"
);
error
=
error_this
(
js
this
);
if
(
ctx
->
version
<
2
||
!
error
)
{
jsthis
=
get_jsdisp
(
v
this
);
if
(
!
jsthis
||
ctx
->
version
<
2
)
{
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
SysAllocString
(
str
);
V_BSTR
(
retv
)
=
SysAllocString
(
object_errorW
);
if
(
!
V_BSTR
(
retv
))
return
E_OUTOFMEMORY
;
}
return
S_OK
;
}
hres
=
jsdisp_propget_name
(
&
error
->
dispex
,
nameW
,
&
v
,
ei
,
caller
);
hres
=
jsdisp_propget_name
(
jsthis
,
nameW
,
&
v
,
ei
,
caller
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
name
);
VariantClear
(
&
v
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
V_VT
(
&
v
)
!=
VT_EMPTY
)
{
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
name
);
VariantClear
(
&
v
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
!*
name
)
{
SysFreeString
(
name
);
name
=
NULL
;
}
}
hres
=
jsdisp_propget_name
(
&
error
->
dispex
,
messageW
,
&
v
,
ei
,
caller
);
hres
=
jsdisp_propget_name
(
jsthis
,
messageW
,
&
v
,
ei
,
caller
);
if
(
SUCCEEDED
(
hres
))
{
if
(
V_VT
(
&
v
)
!=
VT_EMPTY
)
{
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
msg
);
...
...
@@ -92,7 +98,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
}
if
(
SUCCEEDED
(
hres
))
{
if
(
msg
)
{
if
(
name
&&
msg
)
{
DWORD
name_len
,
msg_len
;
name_len
=
SysStringLen
(
name
);
...
...
@@ -105,9 +111,16 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
ret
[
name_len
+
1
]
=
' '
;
memcpy
(
ret
+
name_len
+
2
,
msg
,
msg_len
*
sizeof
(
WCHAR
));
}
}
else
{
}
else
if
(
name
)
{
ret
=
name
;
name
=
NULL
;
}
else
if
(
msg
)
{
ret
=
msg
;
msg
=
NULL
;
}
else
{
ret
=
SysAllocString
(
object_errorW
);
if
(
!
V_BSTR
(
retv
))
hres
=
E_OUTOFMEMORY
;
}
}
...
...
dlls/jscript/tests/api.js
View file @
ae8cb5a1
...
...
@@ -1780,6 +1780,12 @@ ok(err.message === "message", "err.message = " + err.message);
ok
(
err
.
description
===
"message"
,
"err.description = "
+
err
.
description
);
err
=
new
Error
();
ok
(
err
.
number
===
0
,
"err.number = "
+
err
.
number
);
ok
(
err
.
description
===
""
,
"err.description = "
+
err
.
description
);
err
.
description
=
5
;
ok
(
err
.
description
===
5
,
"err.description = "
+
err
.
description
);
ok
(
err
.
message
===
""
,
"err.message = "
+
err
.
message
);
err
.
message
=
4
;
ok
(
err
.
message
===
4
,
"err.message = "
+
err
.
message
);
ok
(
!
(
"number"
in
Error
),
"number is in Error"
);
...
...
@@ -1789,6 +1795,33 @@ tmp.toString = function() { return "test"; };
tmp
=
Error
.
prototype
.
toString
.
call
(
tmp
);
ok
(
tmp
===
"[object Error]"
,
"Error.prototype.toString.call(tmp) = "
+
tmp
);
if
(
invokeVersion
>=
2
)
{
obj
=
new
Object
();
obj
.
name
=
"test"
;
tmp
=
Error
.
prototype
.
toString
.
call
(
obj
);
ok
(
tmp
===
"test"
,
"Error.prototype.toString.call(obj) = "
+
tmp
);
obj
=
new
Object
();
obj
.
name
=
6
;
obj
.
message
=
false
;
tmp
=
Error
.
prototype
.
toString
.
call
(
obj
);
ok
(
tmp
===
"6: false"
,
"Error.prototype.toString.call(obj) = "
+
tmp
);
obj
=
new
Object
();
obj
.
message
=
"test"
;
tmp
=
Error
.
prototype
.
toString
.
call
(
obj
);
ok
(
tmp
===
"test"
,
"Error.prototype.toString.call(obj) = "
+
tmp
);
obj
=
new
Object
();
obj
.
name
=
""
;
obj
.
message
=
"test"
;
tmp
=
Error
.
prototype
.
toString
.
call
(
obj
);
ok
(
tmp
===
"test"
,
"Error.prototype.toString.call(obj) = "
+
tmp
);
}
tmp
=
Error
.
prototype
.
toString
.
call
(
testObj
);
ok
(
tmp
===
"[object Error]"
,
"Error.prototype.toString.call(testObj) = "
+
tmp
);
err
=
new
Error
();
err
.
name
=
null
;
ok
(
err
.
name
===
null
,
"err.name = "
+
err
.
name
+
" expected null"
);
...
...
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