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
091738ff
Commit
091738ff
authored
Jan 13, 2015
by
Jacek Caban
Committed by
Alexandre Julliard
Jan 14, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Don't allow function execution if script engine is not in started state.
parent
6bad1636
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
10 deletions
+79
-10
function.c
dlls/jscript/function.c
+5
-0
run.c
dlls/jscript/tests/run.c
+74
-10
No files found.
dlls/jscript/function.c
View file @
091738ff
...
...
@@ -205,6 +205,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
scope_chain_t
*
scope
;
HRESULT
hres
;
if
(
ctx
->
state
==
SCRIPTSTATE_UNINITIALIZED
||
ctx
->
state
==
SCRIPTSTATE_CLOSED
)
{
WARN
(
"Script engine state does not allow running code.
\n
"
);
return
E_UNEXPECTED
;
}
if
(
!
function
->
func_code
)
{
FIXME
(
"no source
\n
"
);
return
E_FAIL
;
...
...
dlls/jscript/tests/run.c
View file @
091738ff
...
...
@@ -1908,7 +1908,7 @@ static void test_isvisible(BOOL global_members)
IActiveScriptParse_Release
(
parser
);
}
static
HRESULT
parse_script_expr
(
const
char
*
expr
,
VARIANT
*
res
)
static
HRESULT
parse_script_expr
(
const
char
*
expr
,
VARIANT
*
res
,
IActiveScript
**
engine_ret
)
{
IActiveScriptParse
*
parser
;
IActiveScript
*
engine
;
...
...
@@ -1939,9 +1939,14 @@ static HRESULT parse_script_expr(const char *expr, VARIANT *res)
hres
=
IActiveScriptParse_ParseScriptText
(
parser
,
str
,
NULL
,
NULL
,
NULL
,
0
,
0
,
SCRIPTTEXT_ISEXPRESSION
,
res
,
NULL
);
SysFreeString
(
str
);
IActiveScript_Release
(
engine
);
IActiveScriptParse_Release
(
parser
);
if
(
engine_ret
)
{
*
engine_ret
=
engine
;
}
else
{
IActiveScript_Close
(
engine
);
IActiveScript_Release
(
engine
);
}
return
hres
;
}
...
...
@@ -1952,7 +1957,7 @@ static void test_default_value(void)
VARIANT
v
;
HRESULT
hres
;
hres
=
parse_script_expr
(
"new Date()"
,
&
v
);
hres
=
parse_script_expr
(
"new Date()"
,
&
v
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_DISPATCH
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
disp
=
V_DISPATCH
(
&
v
);
...
...
@@ -1976,38 +1981,38 @@ static void test_script_exprs(void)
testing_expr
=
TRUE
;
hres
=
parse_script_expr
(
"true"
,
&
v
);
hres
=
parse_script_expr
(
"true"
,
&
v
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_BOOL
(
&
v
)
==
VARIANT_TRUE
,
"V_BOOL(v) = %x
\n
"
,
V_BOOL
(
&
v
));
hres
=
parse_script_expr
(
"false, true"
,
&
v
);
hres
=
parse_script_expr
(
"false, true"
,
&
v
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_BOOL
(
&
v
)
==
VARIANT_TRUE
,
"V_BOOL(v) = %x
\n
"
,
V_BOOL
(
&
v
));
SET_EXPECT
(
global_success_d
);
SET_EXPECT
(
global_success_i
);
hres
=
parse_script_expr
(
"reportSuccess(); true"
,
&
v
);
hres
=
parse_script_expr
(
"reportSuccess(); true"
,
&
v
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_BOOL
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_BOOL
(
&
v
)
==
VARIANT_TRUE
,
"V_BOOL(v) = %x
\n
"
,
V_BOOL
(
&
v
));
CHECK_CALLED
(
global_success_d
);
CHECK_CALLED
(
global_success_i
);
hres
=
parse_script_expr
(
"if(false) true"
,
&
v
);
hres
=
parse_script_expr
(
"if(false) true"
,
&
v
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_EMPTY
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
hres
=
parse_script_expr
(
"return testPropGet"
,
&
v
);
hres
=
parse_script_expr
(
"return testPropGet"
,
&
v
,
NULL
);
ok
(
hres
==
0x800a03fa
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
hres
=
parse_script_expr
(
"reportSuccess(); return true"
,
&
v
);
hres
=
parse_script_expr
(
"reportSuccess(); return true"
,
&
v
,
NULL
);
ok
(
hres
==
0x800a03fa
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
SET_EXPECT
(
global_success_d
);
SET_EXPECT
(
global_success_i
);
hres
=
parse_script_expr
(
"reportSuccess(); true"
,
NULL
);
hres
=
parse_script_expr
(
"reportSuccess(); true"
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
CHECK_CALLED
(
global_success_d
);
CHECK_CALLED
(
global_success_i
);
...
...
@@ -2017,6 +2022,64 @@ static void test_script_exprs(void)
testing_expr
=
FALSE
;
}
static
void
test_invokeex
(
void
)
{
DISPID
func_id
,
prop_id
;
DISPPARAMS
dp
=
{
NULL
};
IActiveScript
*
script
;
IDispatchEx
*
dispex
;
VARIANT
v
;
BSTR
str
;
HRESULT
hres
;
hres
=
parse_script_expr
(
"var o = {func: function() {return 3;}, prop: 6}; o"
,
&
v
,
&
script
);
ok
(
hres
==
S_OK
,
"parse_script_expr failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_DISPATCH
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
hres
=
IDispatch_QueryInterface
(
V_DISPATCH
(
&
v
),
&
IID_IDispatchEx
,
(
void
**
)
&
dispex
);
ok
(
hres
==
S_OK
,
"Could not get IDispatchEx iface: %08x
\n
"
,
hres
);
VariantClear
(
&
v
);
str
=
a2bstr
(
"func"
);
hres
=
IDispatchEx_GetDispID
(
dispex
,
str
,
0
,
&
func_id
);
SysFreeString
(
str
);
ok
(
hres
==
S_OK
,
"GetDispID failed: %08x
\n
"
,
hres
);
str
=
a2bstr
(
"prop"
);
hres
=
IDispatchEx_GetDispID
(
dispex
,
str
,
0
,
&
prop_id
);
SysFreeString
(
str
);
ok
(
hres
==
S_OK
,
"GetDispID failed: %08x
\n
"
,
hres
);
hres
=
IDispatchEx_InvokeEx
(
dispex
,
func_id
,
0
,
DISPATCH_METHOD
,
&
dp
,
&
v
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"InvokeEx failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_I4
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_I4
(
&
v
)
==
3
,
"V_I4(v) = %d
\n
"
,
V_I4
(
&
v
));
hres
=
IDispatchEx_InvokeEx
(
dispex
,
prop_id
,
0
,
DISPATCH_PROPERTYGET
,
&
dp
,
&
v
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"InvokeEx failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_I4
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_I4
(
&
v
)
==
6
,
"V_I4(v) = %d
\n
"
,
V_I4
(
&
v
));
hres
=
IActiveScript_SetScriptState
(
script
,
SCRIPTSTATE_UNINITIALIZED
);
ok
(
hres
==
S_OK
,
"SetScriptState(SCRIPTSTATE_STARTED) failed: %08x
\n
"
,
hres
);
str
=
a2bstr
(
"func"
);
hres
=
IDispatchEx_GetDispID
(
dispex
,
str
,
0
,
&
func_id
);
SysFreeString
(
str
);
ok
(
hres
==
S_OK
,
"GetDispID failed: %08x
\n
"
,
hres
);
hres
=
IDispatchEx_InvokeEx
(
dispex
,
func_id
,
0
,
DISPATCH_METHOD
,
&
dp
,
&
v
,
NULL
,
NULL
);
ok
(
hres
==
E_UNEXPECTED
||
broken
(
hres
==
0x800a1393
),
"InvokeEx failed: %08x
\n
"
,
hres
);
hres
=
IDispatchEx_InvokeEx
(
dispex
,
prop_id
,
0
,
DISPATCH_PROPERTYGET
,
&
dp
,
&
v
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"InvokeEx failed: %08x
\n
"
,
hres
);
ok
(
V_VT
(
&
v
)
==
VT_I4
,
"V_VT(v) = %d
\n
"
,
V_VT
(
&
v
));
ok
(
V_I4
(
&
v
)
==
6
,
"V_I4(v) = %d
\n
"
,
V_I4
(
&
v
));
IDispatchEx_Release
(
dispex
);
IActiveScript_Release
(
script
);
}
struct
bom_test
{
WCHAR
str
[
1024
];
...
...
@@ -2335,6 +2398,7 @@ static BOOL run_tests(void)
ok
(
hres
!=
S_OK
,
"ParseScriptText have not failed
\n
"
);
test_script_exprs
();
test_invokeex
();
parse_script_with_error_a
(
"?"
,
...
...
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