Commit 4a588d39 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

msscript.ocx: Implement IScriptError::get_Text.

parent 7bc6740a
......@@ -125,12 +125,14 @@ typedef struct {
LONG ref;
HRESULT number;
BSTR text;
BSTR source;
BSTR desc;
BSTR help_file;
DWORD help_context;
BOOLEAN info_filled;
BOOLEAN text_filled;
} ScriptError;
struct ScriptHost {
......@@ -2140,6 +2142,15 @@ static void fill_error_info(ScriptError *error)
error->help_context = info.dwHelpContext;
}
static void fill_error_text(ScriptError *error)
{
if (error->text_filled) return;
error->text_filled = TRUE;
if (error->object)
IActiveScriptError_GetSourceLineText(error->object, &error->text);
}
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv)
{
ScriptError *This = impl_from_IScriptError(iface);
......@@ -2306,9 +2317,11 @@ static HRESULT WINAPI ScriptError_get_Text(IScriptError *iface, BSTR *pbstrText)
{
ScriptError *This = impl_from_IScriptError(iface);
FIXME("(%p)->(%p)\n", This, pbstrText);
TRACE("(%p)->(%p)\n", This, pbstrText);
return E_NOTIMPL;
fill_error_text(This);
*pbstrText = SysAllocString(This->text);
return S_OK;
}
static HRESULT WINAPI ScriptError_get_Line(IScriptError *iface, LONG *plLine)
......@@ -2340,17 +2353,20 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface)
IActiveScriptError_Release(This->object);
This->object = NULL;
}
SysFreeString(This->text);
SysFreeString(This->source);
SysFreeString(This->desc);
SysFreeString(This->help_file);
This->number = 0;
This->text = NULL;
This->source = NULL;
This->desc = NULL;
This->help_file = NULL;
This->help_context = 0;
This->info_filled = FALSE;
This->text_filled = FALSE;
return S_OK;
}
......
......@@ -3348,6 +3348,9 @@ static void test_IScriptControl_get_Error(void)
hr = IScriptError_get_HelpContext(error, &x);
ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr);
ok(x == 0, "Error HelpContext is not 0, got %d.\n", x);
hr = IScriptError_get_Text(error, &str);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str));
str = SysAllocString(L"jscript");
hr = IScriptControl_put_Language(sc, str);
......@@ -3374,6 +3377,10 @@ static void test_IScriptControl_get_Error(void)
ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr);
ok(str != NULL, "Error Description is (null).\n");
SysFreeString(str);
hr = IScriptError_get_Text(error, &str);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(!lstrcmpW(str, L"this is an invalid line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
hr = IScriptError_Clear(error);
ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr);
......@@ -3393,6 +3400,9 @@ static void test_IScriptControl_get_Error(void)
hr = IScriptError_get_HelpContext(error, &x);
ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr);
ok(x == 0, "Error HelpContext is not 0, got %d.\n", x);
hr = IScriptError_get_Text(error, &str);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str));
hr = IScriptControl_get_Error(sc, &error2);
ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr);
......@@ -3458,9 +3468,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText);
hr = IScriptError_get_Text(error, &str);
todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
if (SUCCEEDED(hr)) SysFreeString(str);
todo_wine CHECK_CALLED(GetSourceLineText);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition);
hr = IScriptError_get_Line(error, &x);
......@@ -3493,9 +3504,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText);
hr = IScriptError_get_Text(error, &str);
todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
if (SUCCEEDED(hr)) SysFreeString(str);
todo_wine CHECK_CALLED(GetSourceLineText);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition);
hr = IScriptError_get_Line(error, &x);
......@@ -3527,9 +3539,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText);
hr = IScriptError_get_Text(error, &str);
todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
if (SUCCEEDED(hr)) SysFreeString(str);
todo_wine CHECK_CALLED(GetSourceLineText);
ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr);
ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition);
hr = IScriptError_get_Line(error, &x);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment