aboutsummaryrefslogtreecommitdiffstats
path: root/tests/content/test_element_attribute.html
diff options
context:
space:
mode:
Diffstat (limited to 'tests/content/test_element_attribute.html')
-rw-r--r--tests/content/test_element_attribute.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/content/test_element_attribute.html b/tests/content/test_element_attribute.html
new file mode 100644
index 00000000000..d7ee6a23640
--- /dev/null
+++ b/tests/content/test_element_attribute.html
@@ -0,0 +1,66 @@
+<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");
+ });
+
+ finish();
+ </script>
+</body>
+</html>