Commit 3388fecd authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard
Browse files

mshtml: Implement hasAttributeNS for Elements.


Signed-off-by: Gabriel Ivăncescu's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent e3b9db5a
......@@ -4925,8 +4925,28 @@ static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTM
static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
{
HTMLElement *This = impl_from_IHTMLElement6(iface);
FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
return E_NOTIMPL;
nsAString ns_str, name_str;
nsresult nsres;
HRESULT hres;
cpp_bool r;
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
if(!This->dom_element) {
FIXME("No dom_element\n");
return E_NOTIMPL;
}
hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
if(FAILED(hres))
return hres;
nsAString_InitDepend(&name_str, name);
nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
nsAString_Finish(&ns_str);
nsAString_Finish(&name_str);
*pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
return S_OK;
}
static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
......@@ -6868,6 +6888,35 @@ static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEve
return default_set_current_event(This->node.doc->window, event);
}
static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
VARIANT args[2];
HRESULT hres;
DISPPARAMS new_dp = { args, NULL, 2, 0 };
if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
return S_FALSE;
switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
case VT_EMPTY:
case VT_BSTR:
case VT_NULL:
return S_FALSE;
default:
break;
}
hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
if(FAILED(hres))
return hres;
args[0] = dp->rgvarg[dp->cArgs - 2];
hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
VariantClear(&args[1]);
return hres;
}
static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
......@@ -7017,6 +7066,7 @@ void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
{DISPID_UNKNOWN}
};
static const dispex_hook_t elem6_ie10_hooks[] = {
{DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
{DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
{DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
{DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
......
......@@ -1418,20 +1418,36 @@ sync_test("elem_attrNS", function() {
var elem = document.createElement("div"), r;
elem.setAttributeNS(specialspace_ns, "spec:align", "left");
r = elem.hasAttribute("spec:align");
ok(r === true, "spec:align does not exist");
r = elem.getAttribute("spec:align");
ok(r === "left", "spec:align = " + r);
r = elem.hasAttribute("align");
ok(r === false, "align exists");
r = elem.getAttribute("align");
ok(r === null, "align = " + r);
r = elem.hasAttributeNS(null, "spec:align");
ok(r === false, "null spec:align exists");
r = elem.getAttributeNS(null, "spec:align");
ok(r === "", "null spec:align = " + r);
r = elem.hasAttributeNS(null, "spec:align");
ok(r === false, "null align exists");
r = elem.getAttributeNS(null, "align");
ok(r === "", "null align = " + r);
r = elem.hasAttributeNS(svg_ns, "spec:align");
ok(r === false, "svg spec:align exists");
r = elem.getAttributeNS(svg_ns, "spec:align");
ok(r === "", "svg spec:align = " + r);
r = elem.hasAttributeNS(svg_ns, "align");
ok(r === false, "svg align exists");
r = elem.getAttributeNS(svg_ns, "align");
ok(r === "", "svg align = " + r);
r = elem.hasAttributeNS(specialspace_ns, "spec:align");
ok(r === false, "specialspace spec:align exists");
r = elem.getAttributeNS(specialspace_ns, "spec:align");
ok(r === "", "specialspace spec:align = " + r);
r = elem.hasAttributeNS(specialspace_ns, "align");
ok(r === true, "specialspace align does not exist");
r = elem.getAttributeNS(specialspace_ns, "align");
ok(r === "left", "specialspace align = " + r);
......@@ -1452,56 +1468,98 @@ sync_test("elem_attrNS", function() {
elem.setAttributeNS(null, "align", "right");
r = elem.getAttribute("spec:align");
ok(r === "left", "spec:align (null) = " + r);
r = elem.hasAttribute("align");
ok(r === true, "align (null) does not exist");
r = elem.getAttribute("align");
ok(r === "right", "align (null) = " + r);
r = elem.hasAttributeNS(null, "spec:align");
ok(r === false, "null spec:align exists");
r = elem.getAttributeNS(null, "spec:align");
ok(r === "", "null spec:align (null) = " + r);
r = elem.hasAttributeNS(null, "align");
ok(r === true, "null align does not exist");
r = elem.getAttributeNS(null, "align");
ok(r === "right", "null align (null) = " + r);
r = elem.hasAttributeNS(svg_ns, "spec:align");
ok(r === false, "svg spec:align (null) exists");
r = elem.getAttributeNS(svg_ns, "spec:align");
ok(r === "", "svg spec:align (null) = " + r);
r = elem.hasAttributeNS(svg_ns, "align");
ok(r === false, "svg align (null) exists");
r = elem.getAttributeNS(svg_ns, "align");
ok(r === "", "svg align (null) = " + r);
r = elem.hasAttributeNS(specialspace_ns, "spec:align");
ok(r === false, "specialspace_ns spec:align (null) exists");
r = elem.getAttributeNS(specialspace_ns, "spec:align");
ok(r === "", "specialspace spec:align (null) = " + r);
r = elem.hasAttributeNS(specialspace_ns, "align");
ok(r === true, "specialspace align (null) does not exist");
r = elem.getAttributeNS(specialspace_ns, "align");
ok(r === "left", "specialspace align (null) = " + r);
elem.setAttribute("align", "center");
r = elem.hasAttributeNS(null, "spec:align");
ok(r === false, "null spec:align (non-NS) exists");
r = elem.getAttributeNS(null, "spec:align");
ok(r === "", "null spec:align (non-NS) = " + r);
r = elem.hasAttributeNS(null, "align");
ok(r === true, "null align (non-NS) does not exist");
r = elem.getAttributeNS(null, "align");
ok(r === "center", "null align (non-NS) = " + r);
r = elem.hasAttributeNS(svg_ns, "spec:align");
ok(r === false, "svg spec:align (non-NS) exists");
r = elem.getAttributeNS(svg_ns, "spec:align");
ok(r === "", "svg spec:align (non-NS) = " + r);
r = elem.hasAttributeNS(svg_ns, "align");
ok(r === false, "svg align (non-NS) exists");
r = elem.getAttributeNS(svg_ns, "align");
ok(r === "", "svg align (non-NS) = " + r);
r = elem.hasAttributeNS(specialspace_ns, "spec:align");
ok(r === false, "specialspace spec:align (non-NS) exists");
r = elem.getAttributeNS(specialspace_ns, "spec:align");
ok(r === "", "specialspace spec:align (non-NS) = " + r);
r = elem.hasAttributeNS(specialspace_ns, "align");
ok(r === true, "specialspace align (non-NS) does not exist");
r = elem.getAttributeNS(specialspace_ns, "align");
ok(r === "left", "specialspace align (non-NS) = " + r);
elem.removeAttributeNS(null, "spec:align");
elem.setAttribute("emptynsattr", "none");
elem.setAttributeNS("", "emptynsattr", "test");
r = elem.hasAttribute("emptynsattr");
ok(r === true, "emptynsattr without NS does not exist");
r = elem.getAttribute("emptynsattr");
ok(r === "test", "emptynsattr without NS = " + r);
elem.setAttributeNS(null, "emptynsattr", "wine");
r = elem.hasAttribute("emptynsattr");
ok(r === true, "emptynsattr without NS does not exist");
r = elem.getAttribute("emptynsattr");
ok(r === "wine", "emptynsattr without NS = " + r);
elem.setAttributeNS(specialspace_ns, "emptynsattr", "ns");
r = elem.hasAttribute("emptynsattr");
ok(r === true, "emptynsattr without NS does not exist");
r = elem.getAttribute("emptynsattr");
ok(r === "wine", "emptynsattr without NS = " + r);
r = elem.hasAttributeNS("", "emptynsattr");
ok(r === true, "emptynsattr empty ns does not exist");
r = elem.getAttributeNS("", "emptynsattr");
ok(r === "wine", "emptynsattr empty ns = " + r);
r = elem.hasAttributeNS(null, "emptynsattr");
ok(r === true, "emptynsattr null ns does not exist");
r = elem.getAttributeNS(null, "emptynsattr");
ok(r === "wine", "emptynsattr null ns = " + r);
r = elem.hasAttributeNS(specialspace_ns, "emptynsattr");
ok(r === true, "emptynsattr specialspace ns does not exist");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns = " + r);
elem.removeAttributeNS("", "emptynsattr");
r = elem.hasAttribute("emptynsattr");
ok(r === true, "emptynsattr without NS after remove does not exist");
r = elem.getAttribute("emptynsattr");
ok(r === "ns", "emptynsattr without NS after remove = " + r);
r = elem.hasAttributeNS(specialspace_ns, "emptynsattr");
ok(r === true, "emptynsattr specialspace ns after empty remove does not exist");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after empty remove = " + r);
elem.setAttribute("emptynsattr", "test");
......@@ -1511,15 +1569,23 @@ sync_test("elem_attrNS", function() {
ok(r === "test", "emptynsattr specialspace ns after empty re-set = " + r);
elem.removeAttribute("emptynsattr");
r = elem.hasAttribute("emptynsattr");
ok(r === false, "emptynsattr without NS after non-NS remove exists");
r = elem.getAttribute("emptynsattr");
ok(r === null, "emptynsattr without NS after non-NS remove = " + r);
r = elem.hasAttributeNS(specialspace_ns, "emptynsattr");
ok(r === false, "emptynsattr specialspace ns after non-NS remove exists");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "", "emptynsattr specialspace ns after non-NS remove = " + r);
elem.setAttributeNS(specialspace_ns, "emptynsattr", "ns");
elem.removeAttributeNS(svg_ns, "emptynsattr");
r = elem.hasAttributeNS(specialspace_ns, "emptynsattr");
ok(r === true, "emptynsattr specialspace ns after wrong NS remove does not exist");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after wrong NS remove = " + r);
r = elem.hasAttributeNS(specialspace_ns, "emptynsattr");
ok(r === true, "emptynsattr specialspace ns after remove does not exist");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after remove = " + r);
......@@ -1527,12 +1593,20 @@ sync_test("elem_attrNS", function() {
ns.toString = function() { return "toString namespace"; }
ns.valueOf = function() { return "valueOf namespace"; }
elem.setAttributeNS(ns, "foobar", "test");
r = elem.hasAttribute("foobar");
ok(r === true, "foobar without NS does not exist");
r = elem.getAttribute("foobar");
ok(r === "test", "foobar without NS = " + r);
r = elem.hasAttributeNS(ns, "foobar");
ok(r === true, "foobar does not exist");
r = elem.getAttributeNS(ns, "foobar");
ok(r === "test", "foobar = " + r);
r = elem.hasAttributeNS("toString namespace", "foobar");
ok(r === (v < 10 ? false : true), "foobar (toString namespace) " + (v < 10 ? "exists" : "does not exist"));
r = elem.getAttributeNS("toString namespace", "foobar");
ok(r === (v < 10 ? "" : "test"), "foobar (toString namespace) = " + r);
r = elem.hasAttributeNS("valueOf namespace", "foobar");
ok(r === (v < 10 ? true : false), "foobar (valueOf namespace) = " + (v < 10 ? "does not exist" : "exists"));
r = elem.getAttributeNS("valueOf namespace", "foobar");
ok(r === (v < 10 ? "test" : ""), "foobar (valueOf namespace) = " + r);
......
Supports Markdown
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