jscript: Added html comments tests.

This commit is contained in:
Piotr Caban 2009-04-09 23:34:56 +02:00 committed by Alexandre Julliard
parent 84ef7eced2
commit 2dc78e555b
1 changed files with 66 additions and 0 deletions

View File

@ -600,6 +600,47 @@ static void parse_script(BSTR script_str)
IUnknown_Release(parser);
}
static HRESULT parse_htmlscript(BSTR script_str)
{
IActiveScriptParse *parser;
IActiveScript *engine;
HRESULT hres;
BSTR tmp = a2bstr("</SCRIPT>");
engine = create_script();
if(!engine)
return E_FAIL;
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
if (FAILED(hres))
{
IActiveScript_Release(engine);
return E_FAIL;
}
hres = IActiveScriptParse64_InitNew(parser);
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
hres = IActiveScript_AddNamedItem(engine, testW,
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, tmp, 0, 0, 0, NULL, NULL);
IActiveScript_Release(engine);
IUnknown_Release(parser);
SysFreeString(tmp);
return hres;
}
static void parse_script_a(const char *src)
{
BSTR tmp = a2bstr(src);
@ -607,6 +648,16 @@ static void parse_script_a(const char *src)
SysFreeString(tmp);
}
static HRESULT parse_htmlscript_a(const char *src)
{
HRESULT hres;
BSTR tmp = a2bstr(src);
hres = parse_htmlscript(tmp);
SysFreeString(tmp);
return hres;
}
static BSTR get_script_from_file(const char *filename)
{
DWORD size, len;
@ -741,6 +792,8 @@ static void test_isvisible(BOOL global_members)
static void run_tests(void)
{
HRESULT hres;
strict_dispid_check = TRUE;
parse_script_a("");
@ -776,6 +829,19 @@ static void run_tests(void)
test_isvisible(FALSE);
test_isvisible(TRUE);
hres = parse_htmlscript_a("<!--");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("-->");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("<!--\nvar a=1;\n-->\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("<!--\n<!-- ignore this\n-->\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("var a=1;\nif(a-->0) a=5;\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("var a=1;\nif(a\n-->0) a=5;\n");
ok(hres != S_OK, "ParseScriptText have not failed\n");
}
START_TEST(run)