Commit 134dad7e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLScriptElement:get_type implementation.

parent 5ecd33e2
......@@ -39,6 +39,8 @@ typedef struct {
HTMLElement element;
const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl;
nsIDOMHTMLScriptElement *nsscript;
} HTMLScriptElement;
#define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl)
......@@ -203,8 +205,22 @@ static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR
static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
{
HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
const PRUnichar *nstype;
nsAString nstype_str;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&nstype_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
if(NS_FAILED(nsres))
ERR("GetType failed: %08x\n", nsres);
nsAString_GetData(&nstype_str, &nstype);
*p = *nstype ? SysAllocString(nstype) : NULL;
nsAString_Finish(&nstype_str);
return S_OK;
}
static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
......@@ -277,11 +293,16 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem)
{
HTMLScriptElement *ret = heap_alloc(sizeof(HTMLScriptElement));
nsresult nsres;
HTMLElement_Init(&ret->element);
ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
return &ret->element;
}
......@@ -1273,6 +1273,30 @@ interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
[
object,
uuid(a6cf90b1-15b3-11d2-932e-00805f8add32),
local
/* FROZEN */
]
interface nsIDOMHTMLScriptElement : nsIDOMHTMLElement
{
nsresult GetText(nsAString *aText);
nsresult SetText(const nsAString *aText);
nsresult GetHtmlFor(nsAString *aHtmlFor);
nsresult SetHtmlFor(const nsAString *aHtmlFor);
nsresult GetEvent(nsAString *aEvent);
nsresult SetEvent(const nsAString *aEvent);
nsresult GetCharset(nsAString *aCharset);
nsresult SetCharset(const nsAString *aCharset);
nsresult GetDefer(PRBool *aDefer);
nsresult SetDefer(PRBool aDefer);
nsresult GetSrc(nsAString *aSrc);
nsresult SetSrc(const nsAString *aSrc);
nsresult GetType(nsAString *aType);
nsresult SetType(const nsAString *aType);
}
[
object,
uuid(94928ab3-8b63-11d3-989d-001083010e9b),
local
/* FROZEN */
......
......@@ -43,7 +43,7 @@ static const char elem_test_str[] =
"<select id=\"s\"><option id=\"x\">opt1</option><option id=\"y\">opt2</option></select>"
"<textarea id=\"X\">text text</textarea>"
"<table><tbody></tbody></table>"
"<script type=\"text/javascript\"></script>"
"<script id=\"sc\" type=\"text/javascript\"></script>"
"</body></html>";
static const char indent_test_str[] =
"<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
......@@ -54,6 +54,8 @@ static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
static WCHAR wordW[] = {'w','o','r','d',0};
static const WCHAR text_javascriptW[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0};
typedef enum {
ET_NONE,
ET_HTML,
......@@ -1193,6 +1195,7 @@ static void test_elems(IHTMLDocument2 *doc)
static const WCHAR xW[] = {'x',0};
static const WCHAR sW[] = {'s',0};
static const WCHAR scW[] = {'s','c',0};
static const WCHAR xxxW[] = {'x','x','x',0};
static const elem_type_t all_types[] = {
......@@ -1250,6 +1253,20 @@ static void test_elems(IHTMLDocument2 *doc)
IHTMLElement_Release(elem);
}
elem = get_elem_by_id(doc, scW, TRUE);
if(elem) {
IHTMLScriptElement *script;
BSTR type;
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
hres = IHTMLScriptElement_get_type(script, &type);
ok(hres == S_OK, "get_type failed: %08x\n", hres);
ok(!lstrcmpW(type, text_javascriptW), "Unexpected type %s\n", dbgstr_w(type));
SysFreeString(type);
}
test_stylesheets(doc);
test_create_option_elem(doc);
}
......
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