mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
2ddfe368e1
- bug 1215748 - use llvm-dsymutil for mac builds. r=mshal (a217006d89) - warnings (31ea43d0d8) - Bug 1175154 - Unit tests for IAC on 3.0. r=ferjm (12c424bab3) - Bug 1219543 - Part 1: isRunningOnCompositor flag is now a member of AnimationProperty. r=bbirtles (85bc668501) - Bug 1219543 - Part 2: Avoid the period that mIsRunningOnCompositor is false between restyling and building display list. r=bbirtles (597e46d479) - Bug 1219543 - Part 3: MutationObserver should disconnect when the test is finished. r=bbirtles (70c26a266e) - Bug 1214148 - patch 1 - propagation from the nested iframe back to the toplevel iframe, r=alwu (b42002f43a) - Bug 1214148 - patch 2 - from toplevel iframe to the nested iframe, r=alwu (7b07fe5399) - Bug 1214148 - patch 3 - correct window for nested iframes, r=alwu (27ee08caf1) - Bug 1166910 - put referrer attribute behind pref in webidl, r=bz (93e421fa1b) - Bug 1187357 - rename referrer attribute to referrerpolicy. r=hsivonen (70c67f5def) - Bug 1187357 - Generated code for renaming referrer to referrerpolicy in html parser. r=hsivonen (738de3f278) - Bug 1221341. Snap box shadow clip rect to device pixels. r=mstange (b63b783714) - Bug 1228634 - Implement Element.getAttributeNames, r=peterv (4594d9c14c) - Bug 1216193. Implement webkitMatchesSelector. r=khuey (39742b7e0b) - Bug 1134648, handle dynamic changes to rel=dns-prefetch, r=bz (e27638080e) - Bug 1229962 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in parser/html/; r=hsivonen (75de6314f1) - Bug 1226437 - Speculative CSP should set speculative referrer policy instead of actual referrer policy. r=sicking (f7dfd3fd18) - Bug 1227554 - Default to NullPrincipal if doc is not available within expatdriver. r=bz (336a562965) - Bug 1215781 - Use MOZ_UTF16 to generate sTagUnicodeTable. r=mrbkap (eca371a36b) - Bug 1082598 - Part 5: Fix NPAPI for Skia update. r=jrmuizel (25c4d080ab) - Bug 1183828 - Remove 'nsWindow::GetNativeData not implemented for this type' warning. r=roc (0a60404b57) - Bug 1224445 - Add NS_NATIVE_OPENGL_CONTEXT handling to nsWindow::GetNativeData() r=mwu (ee35844be4) - Bug 1179632 part.1 native IME context should not be stored in InputContext but should be able to retrieve with nsIWidget::GetNativeData() r=smaug (5f1804bb72) - Bug 1179632 part.2 WidgetCompositionEvent should store NativeIMEContext which caused the event and PuppetWidget should store it for GetNativeIMEContext() r=smaug, sr=smaug (e00ca78e3f) - Bug 1179632 part.3 TabParent::RecvEndIMEComposition() shouldn't return true with aNoCompositionEvent when there is no widget r=smaug (ee065ed491) - Bug 1179632 part.4 Clean up the code to request IME to commit composition across process boundary r=smaug (9567c4dc57) - Bug 1179632 part.5 WidgetCompositionEvent::mNativeIMEContext should be used at looking for a TextComposition instance for a WidgetCompositionEvent r=smaug (f4e27ec28c) - Bug 1179632 part.6 KeyboardEvent.isComposing shouldn't expose IME state on different document r=smaug (ca8b8a6a02) - Bug 1227544 - Scaling on 720p devices is broken. r=timdream (cb89af839f)
432 lines
18 KiB
HTML
432 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset=utf-8>
|
|
<title>Attributes tests</title>
|
|
<link rel=help href="https://dom.spec.whatwg.org/#attr">
|
|
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattribute">
|
|
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattributens">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="attributes.js"></script>
|
|
<script src="productions.js"></script>
|
|
<div id="log"></div>
|
|
<span id="test1"></span>
|
|
<span class="&<>foo"></span>
|
|
<script>
|
|
var XML = "http://www.w3.org/XML/1998/namespace"
|
|
var XMLNS = "http://www.w3.org/2000/xmlns/"
|
|
|
|
// AttrExodus
|
|
test(function() {
|
|
document.body.setAttribute("abc", "pass")
|
|
var attr = document.body.attributes[0]
|
|
assert_true(attr instanceof Attr)
|
|
assert_false(attr instanceof Node)
|
|
assert_throws(new TypeError(), function() { attr.appendChild(document.createTextNode("fail")) })
|
|
assert_throws(new TypeError(), function() { attr.appendChild(null) })
|
|
assert_equals(attr.value, "pass")
|
|
assert_false("childNodes" in attr, "Should not have childNodes")
|
|
}, "AttrExodus")
|
|
|
|
// setAttribute exhaustive tests
|
|
// Step 1
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
for (var i = 0; i < invalid_names.length; i++) {
|
|
assert_throws("INVALID_CHARACTER_ERR", function() { el.setAttribute(invalid_names[i], "test") })
|
|
}
|
|
}, "When qualifiedName does not match the Name production, an " +
|
|
"INVALID_CHARACTER_ERR exception is to be thrown. (setAttribute)")
|
|
|
|
// Step 2
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttribute("ALIGN", "left")
|
|
assert_equals(el.getAttributeNS("", "ALIGN"), null)
|
|
assert_equals(el.getAttributeNS("", "align"), "left")
|
|
assert_equals(el.getAttribute("align"), "left")
|
|
}, "setAttribute should lowercase its name argument (upper case attribute)")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttribute("CHEEseCaKe", "tasty")
|
|
assert_equals(el.getAttributeNS("", "CHEEseCaKe"), null)
|
|
assert_equals(el.getAttributeNS("", "cheesecake"), "tasty")
|
|
assert_equals(el.getAttribute("cheesecake"), "tasty")
|
|
}, "setAttribute should lowercase its name argument (mixed case attribute)")
|
|
|
|
// Step 3
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
var tests = ["xmlns", "xmlns:a", "xmlnsx", "xmlns0"]
|
|
for (var i = 0; i < tests.length; i++) {
|
|
el.setAttribute(tests[i], "success");
|
|
}
|
|
}, "setAttribute should not throw even when qualifiedName starts with 'xmlns'")
|
|
|
|
// Step 4
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
for (var i = 0; i < valid_names.length; i++) {
|
|
el.setAttribute(valid_names[i], "test")
|
|
assert_equals(el.getAttribute(valid_names[i]), "test")
|
|
}
|
|
}, "Basic functionality should be intact.")
|
|
|
|
// Step 5
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttribute("a", "1")
|
|
el.setAttribute("b", "2")
|
|
el.setAttribute("a", "3")
|
|
el.setAttribute("c", "4")
|
|
attributes_are(el, [["a", "3"],
|
|
["b", "2"],
|
|
["c", "4"]])
|
|
}, "setAttribute should not change the order of previously set attributes.")
|
|
test(function() {
|
|
var el = document.createElement("baz")
|
|
el.setAttributeNS("ab", "attr", "fail")
|
|
el.setAttributeNS("kl", "attr", "pass")
|
|
el.setAttribute("attr", "pass")
|
|
attributes_are(el, [["attr", "pass", "ab"],
|
|
["attr", "pass", "kl"]])
|
|
}, "setAttribute should set the first attribute with the given name")
|
|
test(function() {
|
|
// Based on a test by David Flanagan.
|
|
var el = document.createElement("baz")
|
|
el.setAttributeNS("foo", "foo:bar", "1");
|
|
assert_equals(el.getAttribute("foo:bar"), "1")
|
|
attr_is(el.attributes[0], "1", "bar", "foo", "foo", "foo:bar")
|
|
el.setAttribute("foo:bar", "2");
|
|
assert_equals(el.getAttribute("foo:bar"), "2")
|
|
attr_is(el.attributes[0], "2", "bar", "foo", "foo", "foo:bar")
|
|
}, "setAttribute should set the attribute with the given qualified name")
|
|
|
|
// setAttributeNS exhaustive tests
|
|
// Step 1
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
for (var i = 0, il = invalid_names.length; i < il; ++i) {
|
|
assert_throws("INVALID_CHARACTER_ERR",
|
|
function() { el.setAttributeNS("a", invalid_names[i], "fail") })
|
|
}
|
|
}, "When qualifiedName does not match the Name production, an " +
|
|
"INVALID_CHARACTER_ERR exception is to be thrown. (setAttributeNS)")
|
|
|
|
// Step 2
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
for (var i = 0, il = invalid_qnames.length; i < il; ++i) {
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS("a", invalid_qnames[i], "fail") },
|
|
"Expected exception for " + invalid_qnames[i] + ".")
|
|
}
|
|
}, "When qualifiedName does not match the QName production, an " +
|
|
"NAMESPACE_ERR exception is to be thrown.")
|
|
|
|
// Step 3
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS(null, "aa", "bb")
|
|
el.setAttributeNS("", "xx", "bb")
|
|
attributes_are(el, [["aa", "bb"],
|
|
["xx", "bb"]])
|
|
}, "null and the empty string should result in a null namespace.")
|
|
|
|
// Step 4
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS("", "aa:bb", "fail") })
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS(null, "aa:bb", "fail") })
|
|
}, "A namespace is required to use a prefix.")
|
|
|
|
// Step 5
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS("a", "xml:bb", "fail") })
|
|
}, "The xml prefix should not be allowed for arbitrary namespaces")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS(XML, "a:bb", "pass")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "pass", "bb", XML, "a", "a:bb")
|
|
}, "XML-namespaced attributes don't need an xml prefix")
|
|
|
|
// Step 6
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS("a", "xmlns:bb", "fail") })
|
|
}, "The xmlns prefix should not be allowed for arbitrary namespaces")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS("a", "xmlns", "fail") })
|
|
}, "The xmlns qualified name should not be allowed for arbitrary namespaces")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS("ns", "a:xmlns", "pass")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "pass", "xmlns", "ns", "a", "a:xmlns")
|
|
}, "xmlns should be allowed as local name")
|
|
|
|
// Step 7
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS(XMLNS, "a:xmlns", "fail") })
|
|
assert_throws("NAMESPACE_ERR",
|
|
function() { el.setAttributeNS(XMLNS, "b:foo", "fail") })
|
|
}, "The XMLNS namespace should require xmlns as prefix or qualified name")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS(XMLNS, "xmlns:a", "pass")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "pass", "a", XMLNS, "xmlns", "xmlns:a")
|
|
}, "xmlns should be allowed as prefix in the XMLNS namespace")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS(XMLNS, "xmlns", "pass")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "pass", "xmlns", XMLNS, null, "xmlns")
|
|
}, "xmlns should be allowed as qualified name in the XMLNS namespace")
|
|
|
|
// Step 8-9
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttributeNS("a", "foo:bar", "X")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "X", "bar", "a", "foo", "foo:bar")
|
|
|
|
el.setAttributeNS("a", "quux:bar", "Y")
|
|
assert_equals(el.attributes.length, 1)
|
|
attr_is(el.attributes[0], "Y", "bar", "a", "foo", "foo:bar")
|
|
el.removeAttributeNS("a", "bar")
|
|
}, "Setting the same attribute with another prefix should not change the prefix")
|
|
|
|
// Miscellaneous tests
|
|
test(function() {
|
|
var el = document.createElement("iframe")
|
|
el.setAttribute("src", "file:///home")
|
|
assert_equals(el.getAttribute("src"), "file:///home")
|
|
}, "setAttribute should not throw even if a load is not allowed")
|
|
test(function() {
|
|
var docFragment = document.createDocumentFragment()
|
|
var newOne = document.createElement("newElement")
|
|
newOne.setAttribute("newdomestic", "Yes")
|
|
docFragment.appendChild(newOne)
|
|
var domesticNode = docFragment.firstChild
|
|
var attr = domesticNode.attributes.item(0)
|
|
attr_is(attr, "Yes", "newdomestic", null, null, "newdomestic")
|
|
}, "Attributes should work in document fragments.")
|
|
test(function() {
|
|
var el = document.createElement("foo")
|
|
el.setAttribute("x", "y")
|
|
var attr = el.attributes[0]
|
|
attr.value = "Y<"
|
|
attr_is(attr, "Y<", "x", null, null, "x")
|
|
assert_equals(el.getAttribute("x"), "Y<")
|
|
}, "Attribute values should not be parsed.")
|
|
test(function() {
|
|
var el = document.getElementsByTagName("span")[0]
|
|
attr_is(el.attributes[0], "test1", "id", null, null, "id")
|
|
}, "Specified attributes should be accessible.")
|
|
test(function() {
|
|
var el = document.getElementsByTagName("span")[1]
|
|
attr_is(el.attributes[0], "&<>foo", "class", null, null, "class")
|
|
}, "Entities in attributes should have been expanded while parsing.")
|
|
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
assert_equals(el.hasAttribute("bar"), false)
|
|
assert_equals(el.hasAttributeNS(null, "bar"), false)
|
|
assert_equals(el.hasAttributeNS("", "bar"), false)
|
|
assert_equals(el.getAttribute("bar"), null)
|
|
assert_equals(el.getAttributeNS(null, "bar"), null)
|
|
assert_equals(el.getAttributeNS("", "bar"), null)
|
|
}, "Unset attributes return null")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttributeNS("ab", "attr", "t1")
|
|
el.setAttributeNS("kl", "attr", "t2")
|
|
assert_equals(el.hasAttribute("attr"), true)
|
|
assert_equals(el.hasAttributeNS("ab", "attr"), true)
|
|
assert_equals(el.hasAttributeNS("kl", "attr"), true)
|
|
assert_equals(el.getAttribute("attr"), "t1")
|
|
assert_equals(el.getAttributeNS("ab", "attr"), "t1")
|
|
assert_equals(el.getAttributeNS("kl", "attr"), "t2")
|
|
assert_equals(el.getAttributeNS(null, "attr"), null)
|
|
assert_equals(el.getAttributeNS("", "attr"), null)
|
|
}, "First set attribute is returned by getAttribute")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttribute("style", "color:#fff;")
|
|
assert_equals(el.hasAttribute("style"), true)
|
|
assert_equals(el.hasAttributeNS(null, "style"), true)
|
|
assert_equals(el.hasAttributeNS("", "style"), true)
|
|
assert_equals(el.getAttribute("style"), "color:#fff;")
|
|
assert_equals(el.getAttributeNS(null, "style"), "color:#fff;")
|
|
assert_equals(el.getAttributeNS("", "style"), "color:#fff;")
|
|
}, "Style attributes are not normalized")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttributeNS("", "ALIGN", "left")
|
|
assert_equals(el.hasAttribute("ALIGN"), false)
|
|
assert_equals(el.hasAttribute("align"), false)
|
|
assert_equals(el.hasAttributeNS(null, "ALIGN"), true)
|
|
assert_equals(el.hasAttributeNS(null, "align"), false)
|
|
assert_equals(el.hasAttributeNS("", "ALIGN"), true)
|
|
assert_equals(el.hasAttributeNS("", "align"), false)
|
|
assert_equals(el.getAttribute("ALIGN"), null)
|
|
assert_equals(el.getAttribute("align"), null)
|
|
assert_equals(el.getAttributeNS(null, "ALIGN"), "left")
|
|
assert_equals(el.getAttributeNS("", "ALIGN"), "left")
|
|
assert_equals(el.getAttributeNS(null, "align"), null)
|
|
assert_equals(el.getAttributeNS("", "align"), null)
|
|
el.removeAttributeNS("", "ALIGN")
|
|
}, "Only lowercase attributes are returned on HTML elements (upper case attribute)")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttributeNS("", "CHEEseCaKe", "tasty")
|
|
assert_equals(el.hasAttribute("CHEESECAKE"), false)
|
|
assert_equals(el.hasAttribute("CHEEseCaKe"), false)
|
|
assert_equals(el.hasAttribute("cheesecake"), false)
|
|
assert_equals(el.hasAttributeNS("", "CHEESECAKE"), false)
|
|
assert_equals(el.hasAttributeNS("", "CHEEseCaKe"), true)
|
|
assert_equals(el.hasAttributeNS("", "cheesecake"), false)
|
|
assert_equals(el.hasAttributeNS(null, "CHEESECAKE"), false)
|
|
assert_equals(el.hasAttributeNS(null, "CHEEseCaKe"), true)
|
|
assert_equals(el.hasAttributeNS(null, "cheesecake"), false)
|
|
assert_equals(el.getAttribute("CHEESECAKE"), null)
|
|
assert_equals(el.getAttribute("CHEEseCaKe"), null)
|
|
assert_equals(el.getAttribute("cheesecake"), null)
|
|
assert_equals(el.getAttributeNS(null, "CHEESECAKE"), null)
|
|
assert_equals(el.getAttributeNS("", "CHEESECAKE"), null)
|
|
assert_equals(el.getAttributeNS(null, "CHEEseCaKe"), "tasty")
|
|
assert_equals(el.getAttributeNS("", "CHEEseCaKe"), "tasty")
|
|
assert_equals(el.getAttributeNS(null, "cheesecake"), null)
|
|
assert_equals(el.getAttributeNS("", "cheesecake"), null)
|
|
el.removeAttributeNS("", "CHEEseCaKe")
|
|
}, "Only lowercase attributes are returned on HTML elements (mixed case attribute)")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
document.body.appendChild(el)
|
|
el.setAttributeNS("", "align", "left")
|
|
el.setAttributeNS("xx", "align", "right")
|
|
el.setAttributeNS("", "foo", "left")
|
|
el.setAttributeNS("xx", "foo", "right")
|
|
assert_equals(el.hasAttribute("align"), true)
|
|
assert_equals(el.hasAttribute("foo"), true)
|
|
assert_equals(el.hasAttributeNS("xx", "align"), true)
|
|
assert_equals(el.hasAttributeNS(null, "foo"), true)
|
|
assert_equals(el.getAttribute("align"), "left")
|
|
assert_equals(el.getAttribute("foo"), "left")
|
|
assert_equals(el.getAttributeNS("xx", "align"), "right")
|
|
assert_equals(el.getAttributeNS(null, "foo"), "left")
|
|
assert_equals(el.getAttributeNS("", "foo"), "left")
|
|
el.removeAttributeNS("", "align")
|
|
el.removeAttributeNS("xx", "align")
|
|
el.removeAttributeNS("", "foo")
|
|
el.removeAttributeNS("xx", "foo")
|
|
document.body.removeChild(el)
|
|
}, "First set attribute is returned with mapped attribute set first")
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttributeNS("xx", "align", "right")
|
|
el.setAttributeNS("", "align", "left")
|
|
el.setAttributeNS("xx", "foo", "right")
|
|
el.setAttributeNS("", "foo", "left")
|
|
assert_equals(el.hasAttribute("align"), true)
|
|
assert_equals(el.hasAttribute("foo"), true)
|
|
assert_equals(el.hasAttributeNS("xx", "align"), true)
|
|
assert_equals(el.hasAttributeNS(null, "foo"), true)
|
|
assert_equals(el.getAttribute("align"), "right")
|
|
assert_equals(el.getAttribute("foo"), "right")
|
|
assert_equals(el.getAttributeNS("xx", "align"), "right")
|
|
assert_equals(el.getAttributeNS(null, "foo"), "left")
|
|
assert_equals(el.getAttributeNS("", "foo"), "left")
|
|
el.removeAttributeNS("", "align")
|
|
el.removeAttributeNS("xx", "align")
|
|
el.removeAttributeNS("", "foo")
|
|
el.removeAttributeNS("xx", "foo")
|
|
}, "First set attribute is returned with mapped attribute set later")
|
|
|
|
test(function() {
|
|
var el = document.createElementNS("http://www.example.com", "foo")
|
|
el.setAttribute("A", "test")
|
|
assert_equals(el.hasAttribute("A"), true, "hasAttribute()")
|
|
assert_equals(el.hasAttributeNS("", "A"), true, "el.hasAttributeNS(\"\")")
|
|
assert_equals(el.hasAttributeNS(null, "A"), true, "el.hasAttributeNS(null)")
|
|
assert_equals(el.hasAttributeNS(undefined, "A"), true, "el.hasAttributeNS(undefined)")
|
|
assert_equals(el.hasAttributeNS("foo", "A"), false, "el.hasAttributeNS(\"foo\")")
|
|
|
|
assert_equals(el.getAttribute("A"), "test", "getAttribute()")
|
|
assert_equals(el.getAttributeNS("", "A"), "test", "el.getAttributeNS(\"\")")
|
|
assert_equals(el.getAttributeNS(null, "A"), "test", "el.getAttributeNS(null)")
|
|
assert_equals(el.getAttributeNS(undefined, "A"), "test", "el.getAttributeNS(undefined)")
|
|
assert_equals(el.getAttributeNS("foo", "A"), null, "el.getAttributeNS(\"foo\")")
|
|
}, "Non-HTML element with upper-case attribute")
|
|
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttribute("pre:fix", "value 1")
|
|
el.setAttribute("fix", "value 2")
|
|
|
|
var prefixed = el.attributes[0]
|
|
assert_equals(prefixed.localName, "pre:fix", "prefixed local name")
|
|
assert_equals(prefixed.namespaceURI, null, "prefixed namespace")
|
|
|
|
var unprefixed = el.attributes[1]
|
|
assert_equals(unprefixed.localName, "fix", "unprefixed local name")
|
|
assert_equals(unprefixed.namespaceURI, null, "unprefixed namespace")
|
|
|
|
el.removeAttributeNS(null, "pre:fix")
|
|
assert_equals(el.attributes[0], unprefixed)
|
|
}, "Attribute with prefix in local name")
|
|
|
|
test(function() {
|
|
var el = document.createElement("div")
|
|
el.setAttribute("foo", "bar")
|
|
var attr = el.attributes[0]
|
|
assert_equals(attr.ownerElement, el)
|
|
el.removeAttribute("foo")
|
|
assert_equals(attr.ownerElement, null)
|
|
}, "Attribute loses its owner when removed")
|
|
|
|
test(function() {
|
|
var el = document.createElement("div");
|
|
el.setAttribute("foo", "bar");
|
|
assert_equals(el.getAttributeNames().length, 1);
|
|
assert_equals(el.getAttributeNames()[0], el.attributes[0].name);
|
|
assert_equals(el.getAttributeNames()[0], "foo");
|
|
|
|
el.removeAttribute("foo");
|
|
assert_equals(el.getAttributeNames().length, 0);
|
|
|
|
el.setAttribute("foo", "bar");
|
|
el.setAttributeNS("", "FOO", "bar");
|
|
el.setAttributeNS("dummy1", "foo", "bar");
|
|
el.setAttributeNS("dummy2", "dummy:foo", "bar");
|
|
assert_equals(el.getAttributeNames().length, 4);
|
|
assert_equals(el.getAttributeNames()[0], "foo");
|
|
assert_equals(el.getAttributeNames()[1], "FOO");
|
|
assert_equals(el.getAttributeNames()[2], "foo");
|
|
assert_equals(el.getAttributeNames()[3], "dummy:foo");
|
|
assert_equals(el.getAttributeNames()[0], el.attributes[0].name);
|
|
assert_equals(el.getAttributeNames()[1], el.attributes[1].name);
|
|
assert_equals(el.getAttributeNames()[2], el.attributes[2].name);
|
|
assert_equals(el.getAttributeNames()[3], el.attributes[3].name);
|
|
|
|
el.removeAttributeNS("", "FOO");
|
|
assert_equals(el.getAttributeNames().length, 3);
|
|
assert_equals(el.getAttributeNames()[0], "foo");
|
|
assert_equals(el.getAttributeNames()[1], "foo");
|
|
assert_equals(el.getAttributeNames()[2], "dummy:foo");
|
|
assert_equals(el.getAttributeNames()[0], el.attributes[0].name);
|
|
assert_equals(el.getAttributeNames()[1], el.attributes[1].name);
|
|
assert_equals(el.getAttributeNames()[2], el.attributes[2].name);
|
|
}, "getAttributeNames tests");
|
|
</script>
|