Alistair Leslie-Hughes : mshtml: Implement IHTMLScriptElement get/put Defer .

Alexandre Julliard julliard at winehq.org
Fri Dec 12 07:04:29 CST 2008


Module: wine
Branch: master
Commit: de5bbbc2ff13e4b4a99bc14ebf228cbd4362351c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=de5bbbc2ff13e4b4a99bc14ebf228cbd4362351c

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri Dec 12 20:14:17 2008 +1100

mshtml: Implement IHTMLScriptElement get/put Defer.

---

 dlls/mshtml/htmlscript.c |   33 +++++++++++++++++++++++++++++----
 dlls/mshtml/tests/dom.c  |   24 ++++++++++++++++++++----
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c
index 965619e..8953b09 100644
--- a/dlls/mshtml/htmlscript.c
+++ b/dlls/mshtml/htmlscript.c
@@ -154,15 +154,40 @@ static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR
 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
 {
     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
-    FIXME("(%p)->(%x)\n", This, v);
-    return E_NOTIMPL;
+    HRESULT hr = S_OK;
+    nsresult nsres;
+
+    TRACE("(%p)->(%x)\n", This, v);
+
+    nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
+    if(NS_FAILED(nsres))
+    {
+        hr = E_FAIL;
+    }
+
+    return hr;
 }
 
 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
 {
     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    PRBool defer = FALSE;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(!p)
+        return E_INVALIDARG;
+
+    nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
+    if(NS_FAILED(nsres)) {
+        ERR("GetSrc failed: %08x\n", nsres);
+    }
+
+    *p = defer ? VARIANT_TRUE : VARIANT_FALSE;
+
+    TRACE("*p = %d\n", *p);
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 4378be1..7ba6e86 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -3433,10 +3433,26 @@ static void test_elems(IHTMLDocument2 *doc)
         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);
+        if(hres == S_OK)
+        {
+            VARIANT_BOOL vb;
+
+            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 defer */
+            hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
+            ok(hres == S_OK, "get_type failed: %08x\n", hres);
+
+            hres = IHTMLScriptElement_get_defer(script, &vb);
+            ok(hres == S_OK, "get_type failed: %08x\n", hres);
+            ok(vb == VARIANT_TRUE, "get_type failed: %08x\n", hres);
+
+            hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
+            ok(hres == S_OK, "get_type failed: %08x\n", hres);
+        }
 
         IHTMLScriptElement_Release(script);
     }




More information about the wine-cvs mailing list