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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
11 deletions
+57
-11
error.c
dlls/jscript/error.c
+24
-11
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)
...
@@ -47,39 +47,45 @@ static inline ErrorInstance *error_this(vdisp_t *jsthis)
}
}
/* ECMA-262 3rd Edition 15.11.4.4 */
/* 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
)
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
caller
)
{
{
ErrorInstance
*
error
;
DispatchEx
*
jsthis
;
BSTR
name
,
msg
=
NULL
,
ret
=
NULL
;
BSTR
name
=
NULL
,
msg
=
NULL
,
ret
=
NULL
;
VARIANT
v
;
VARIANT
v
;
HRESULT
hres
;
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
"
);
TRACE
(
"
\n
"
);
error
=
error_this
(
js
this
);
jsthis
=
get_jsdisp
(
v
this
);
if
(
ctx
->
version
<
2
||
!
error
)
{
if
(
!
jsthis
||
ctx
->
version
<
2
)
{
if
(
retv
)
{
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BSTR
;
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
SysAllocString
(
str
);
V_BSTR
(
retv
)
=
SysAllocString
(
object_errorW
);
if
(
!
V_BSTR
(
retv
))
if
(
!
V_BSTR
(
retv
))
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
}
}
return
S_OK
;
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
))
if
(
FAILED
(
hres
))
return
hres
;
return
hres
;
if
(
V_VT
(
&
v
)
!=
VT_EMPTY
)
{
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
name
);
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
name
);
VariantClear
(
&
v
);
VariantClear
(
&
v
);
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
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
(
SUCCEEDED
(
hres
))
{
if
(
V_VT
(
&
v
)
!=
VT_EMPTY
)
{
if
(
V_VT
(
&
v
)
!=
VT_EMPTY
)
{
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
msg
);
hres
=
to_string
(
ctx
,
&
v
,
ei
,
&
msg
);
...
@@ -92,7 +98,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
...
@@ -92,7 +98,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
}
}
if
(
SUCCEEDED
(
hres
))
{
if
(
SUCCEEDED
(
hres
))
{
if
(
msg
)
{
if
(
name
&&
msg
)
{
DWORD
name_len
,
msg_len
;
DWORD
name_len
,
msg_len
;
name_len
=
SysStringLen
(
name
);
name_len
=
SysStringLen
(
name
);
...
@@ -105,9 +111,16 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
...
@@ -105,9 +111,16 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
ret
[
name_len
+
1
]
=
' '
;
ret
[
name_len
+
1
]
=
' '
;
memcpy
(
ret
+
name_len
+
2
,
msg
,
msg_len
*
sizeof
(
WCHAR
));
memcpy
(
ret
+
name_len
+
2
,
msg
,
msg_len
*
sizeof
(
WCHAR
));
}
}
}
else
{
}
else
if
(
name
)
{
ret
=
name
;
ret
=
name
;
name
=
NULL
;
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);
...
@@ -1780,6 +1780,12 @@ ok(err.message === "message", "err.message = " + err.message);
ok
(
err
.
description
===
"message"
,
"err.description = "
+
err
.
description
);
ok
(
err
.
description
===
"message"
,
"err.description = "
+
err
.
description
);
err
=
new
Error
();
err
=
new
Error
();
ok
(
err
.
number
===
0
,
"err.number = "
+
err
.
number
);
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"
);
ok
(
!
(
"number"
in
Error
),
"number is in Error"
);
...
@@ -1789,6 +1795,33 @@ tmp.toString = function() { return "test"; };
...
@@ -1789,6 +1795,33 @@ tmp.toString = function() { return "test"; };
tmp
=
Error
.
prototype
.
toString
.
call
(
tmp
);
tmp
=
Error
.
prototype
.
toString
.
call
(
tmp
);
ok
(
tmp
===
"[object Error]"
,
"Error.prototype.toString.call(tmp) = "
+
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
=
new
Error
();
err
.
name
=
null
;
err
.
name
=
null
;
ok
(
err
.
name
===
null
,
"err.name = "
+
err
.
name
+
" expected 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