jscript: Better checks for too old jscript.dll versions.

This commit is contained in:
Jacek Caban 2010-09-21 15:58:48 +02:00 committed by Alexandre Julliard
parent a7188842af
commit a8e969236f
3 changed files with 64 additions and 31 deletions

View File

@ -701,7 +701,7 @@ static void _parse_script_a(unsigned line, IActiveScriptParse *parser, const cha
ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
}
static IActiveScriptParse *create_script(void)
static IActiveScriptParse *create_script(BOOL skip_tests)
{
IActiveScriptParse *parser;
IActiveScript *script;
@ -719,10 +719,12 @@ static IActiveScriptParse *create_script(void)
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScript, (void**)&script);
if(!skip_tests)
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
if(FAILED(hres))
return NULL;
if(!skip_tests)
set_safety_options((IUnknown*)script);
hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
@ -743,6 +745,7 @@ static IActiveScriptParse *create_script(void)
IActiveScript_Release(script);
if(!skip_tests) {
parse_script_a(parser,
"function testException(func, type, number) {\n"
" try {\n"
@ -751,9 +754,10 @@ static IActiveScriptParse *create_script(void)
" ok(e.name === type, 'e.name = ' + e.name + ', expected ' + type)\n"
" ok(e.number === number, 'e.number = ' + e.number + ', expected ' + number);\n"
" return;\n"
"}"
" }\n"
" ok(false, 'exception expected');\n"
"}");
}
return parser;
}
@ -800,7 +804,7 @@ static void test_ActiveXObject(void)
IActiveScriptParse *parser;
IDispatchEx *proc;
parser = create_script();
parser = create_script(FALSE);
SET_EXPECT(Host_QS_SecMgr);
SET_EXPECT(ProcessUrlAction);
@ -845,7 +849,7 @@ static void test_ActiveXObject(void)
IDispatchEx_Release(proc);
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
proc = parse_procedure_a(parser, "(new ActiveXObject('Wine.Test')).reportSuccess();");
SET_EXPECT(Host_QS_SecMgr);
@ -867,7 +871,7 @@ static void test_ActiveXObject(void)
IDispatchEx_Release(proc);
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
QS_SecMgr_hres = E_NOINTERFACE;
SET_EXPECT(Host_QS_SecMgr);
@ -876,7 +880,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
ProcessUrlAction_hres = E_FAIL;
SET_EXPECT(Host_QS_SecMgr);
@ -887,7 +891,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
ProcessUrlAction_policy = URLPOLICY_DISALLOW;
SET_EXPECT(Host_QS_SecMgr);
@ -898,7 +902,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
CreateInstance_hres = E_FAIL;
SET_EXPECT(Host_QS_SecMgr);
@ -911,7 +915,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
QueryCustomPolicy_hres = E_FAIL;
SET_EXPECT(Host_QS_SecMgr);
@ -926,7 +930,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
QueryCustomPolicy_psize = 6;
SET_EXPECT(Host_QS_SecMgr);
@ -945,7 +949,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
QueryCustomPolicy_policy = URLPOLICY_DISALLOW;
SET_EXPECT(Host_QS_SecMgr);
@ -981,7 +985,7 @@ static void test_ActiveXObject(void)
IUnknown_Release(parser);
parser = create_script();
parser = create_script(FALSE);
object_with_site = &ObjectWithSite;
SET_EXPECT(Host_QS_SecMgr);
@ -1062,18 +1066,24 @@ static BOOL register_activex(void)
static BOOL check_jscript(void)
{
IActiveScriptProperty *script_prop;
IActiveScriptParse *parser;
BSTR str;
HRESULT hres;
parser = create_script();
parser = create_script(TRUE);
if(!parser)
return FALSE;
str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
SysFreeString(str);
if(hres == S_OK)
hres = IUnknown_QueryInterface(parser, &IID_IActiveScriptProperty, (void**)&script_prop);
IUnknown_Release(parser);
if(hres == S_OK)
IActiveScriptProperty_Release(script_prop);
return hres == S_OK;
}

View File

@ -335,10 +335,9 @@ static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *v
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty,
(void**)&script_prop);
if(FAILED(hres)) {
win_skip("IActiveScriptProperty not supported\n");
return E_NOTIMPL;
}
ok(hres == S_OK, "Could not get IActiveScriptProperty: %08x\n", hres);
if(FAILED(hres))
return hres;
hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val);
IActiveScriptProperty_Release(script_prop);
@ -523,12 +522,29 @@ static void test_jscript2(void)
ok(!ref, "ref = %d\n", ref);
}
static BOOL check_jscript(void)
{
IActiveScriptProperty *script_prop;
HRESULT hres;
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScriptProperty, (void**)&script_prop);
if(SUCCEEDED(hres))
IActiveScriptProperty_Release(script_prop);
return hres == S_OK;
}
START_TEST(jscript)
{
CoInitialize(NULL);
if(check_jscript()) {
test_jscript();
test_jscript2();
}else {
win_skip("Broken engine, probably too old\n");
}
CoUninitialize();
}

View File

@ -1090,9 +1090,16 @@ static void run_tests(void)
static BOOL check_jscript(void)
{
IActiveScriptProperty *script_prop;
BSTR str;
HRESULT hres;
hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScriptProperty, (void**)&script_prop);
if(FAILED(hres))
return FALSE;
IActiveScriptProperty_Release(script_prop);
str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
hres = parse_script(0, str);
SysFreeString(str);