mirror of
https://github.com/servo/servo.git
synced 2025-06-13 10:54:29 +00:00
64 lines
1.7 KiB
HTML
64 lines
1.7 KiB
HTML
<html>
|
|
<head id="foo">
|
|
<title></title>
|
|
<script src="harness.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="test" foo="bar"></div>
|
|
<script>
|
|
let test = document.getElementById("test");
|
|
|
|
{
|
|
let r1 = test.getAttribute("id");
|
|
is(r1, "test", "test1-0, Element.getAttribute().");
|
|
let r2 = test.getAttribute("foo");
|
|
is(r2, "bar", "test1-1, Element.getAttribute().");
|
|
}
|
|
|
|
{
|
|
let NAME = "hoge";
|
|
let VALUE = "fuga";
|
|
test.setAttribute(NAME, VALUE);
|
|
let r = test.getAttribute(NAME);
|
|
is(r, VALUE, "test2. Element.setAttribute().");
|
|
}
|
|
|
|
{
|
|
let NAME = "foo";
|
|
let VALUE = "mozilla";
|
|
test.setAttribute(NAME, VALUE);
|
|
let r = test.getAttribute(NAME);
|
|
is(r, VALUE, "test3, attribute update by Element.setAttribute().")
|
|
}
|
|
|
|
{
|
|
test.setAttribute("id", "bar");
|
|
test.removeAttribute("id");
|
|
|
|
let r1 = test.hasAttribute("id");
|
|
is(r1, false, "test4-0, Element.removeAttribute().");
|
|
let r2 = test.getAttribute("id");
|
|
is(r2, null, "test4-1, Element.removeAttribute().");
|
|
}
|
|
|
|
{
|
|
test.setAttribute("xml:lang", "en");
|
|
|
|
let r1 = test.hasAttribute("xml:lang");
|
|
is(r1, true, "test5-0, Element.setAttribute('xml:lang').");
|
|
let r2 = test.getAttribute("xml:lang");
|
|
is_not(r2, null, "test5-1, Element.setAttribute('xml:lang').");
|
|
}
|
|
|
|
should_throw(function () {
|
|
test.setAttributeNS("http://example.com", "xmlns", "foo");
|
|
});
|
|
should_throw(function () {
|
|
test.setAttributeNS("http://www.w3.org/2000/xmlns/", "attr", "value");
|
|
});
|
|
should_throw(function () {
|
|
test.setAttributeNS("http://www.w3.org/2000/xmlns/", "prefix:attr", "value");
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|