OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>SVGURIReference.href IDL semantics</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 const svgNs = 'http://www.w3.org/2000/svg'; |
| 7 const xlinkNs = 'http://www.w3.org/1999/xlink'; |
| 8 |
| 9 test(function() { |
| 10 var element = document.createElementNS(svgNs, 'a'); |
| 11 element.setAttributeNS(null, 'href', 'foo'); |
| 12 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 13 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not
exist'); |
| 14 assert_equals(element.href.baseVal, 'foo'); |
| 15 |
| 16 element.href.baseVal = 'bar'; |
| 17 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still do
es not exist'); |
| 18 assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists'); |
| 19 assert_equals(element.getAttributeNS(null, 'href'), 'bar'); |
| 20 }, document.title+', IDL href backed by "href" after setAttribute(href).'); |
| 21 |
| 22 test(function() { |
| 23 var element = document.createElementNS(svgNs, 'a'); |
| 24 element.setAttributeNS(xlinkNs, 'href', 'foo'); |
| 25 assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); |
| 26 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 27 assert_equals(element.href.baseVal, 'foo'); |
| 28 |
| 29 element.href.baseVal = 'bar'; |
| 30 assert_false(element.hasAttributeNS(null, 'href'), '"href" still does not ex
ist'); |
| 31 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exi
sts'); |
| 32 assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar'); |
| 33 }, document.title+', IDL href backed by "xlink:href" after setAttribute(xlink:hr
ef).'); |
| 34 |
| 35 test(function() { |
| 36 var element = document.createElementNS(svgNs, 'a'); |
| 37 element.href.baseVal = 'foo'; |
| 38 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not
exist'); |
| 39 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 40 assert_equals(element.href.baseVal, 'foo'); |
| 41 }, document.title+', IDL href backed by "href" after baseVal setter.'); |
| 42 |
| 43 test(function() { |
| 44 var element = document.createElementNS(svgNs, 'a'); |
| 45 element.href.baseVal = 'foo'; |
| 46 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not
exist'); |
| 47 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 48 assert_equals(element.href.baseVal, 'foo'); |
| 49 |
| 50 element.setAttributeNS(xlinkNs, 'href', 'bar'); |
| 51 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 52 assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists'); |
| 53 assert_equals(element.href.baseVal, 'foo', 'baseVal still reflects "href"'); |
| 54 assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar'); |
| 55 }, document.title+', IDL href reflects "href"; setAttribute(xlink:href) does not
override baseVal setter.'); |
| 56 |
| 57 test(function() { |
| 58 var element = document.createElementNS(svgNs, 'a'); |
| 59 element.setAttributeNS(xlinkNs, 'href', 'baz'); |
| 60 element.href.baseVal = 'foo'; |
| 61 assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); |
| 62 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 63 assert_equals(element.href.baseVal, 'foo'); |
| 64 assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); |
| 65 |
| 66 element.setAttributeNS(null, 'href', 'bar'); |
| 67 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exi
sts'); |
| 68 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 69 assert_equals(element.href.baseVal, 'bar', 'baseVal prefers "href" to "xlink
:href"'); |
| 70 assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); |
| 71 assert_equals(element.getAttributeNS(null, 'href'), 'bar'); |
| 72 }, document.title+', IDL href prefers "href" over "xlink:href" after setAttribut
e(href) overrides.'); |
| 73 |
| 74 test(function() { |
| 75 var element = document.createElementNS(svgNs, 'a'); |
| 76 element.setAttributeNS(xlinkNs, 'href', 'foo'); |
| 77 assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); |
| 78 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 79 assert_equals(element.href.baseVal, 'foo'); |
| 80 assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); |
| 81 |
| 82 element.setAttributeNS(xlinkNs, 'xlink:href', 'bar'); |
| 83 assert_equals(element.href.baseVal, 'bar'); |
| 84 }, document.title+', IDL href reflects "xlink:href"; setAttribute(xlink:href) w/
NS-prefix.'); |
| 85 |
| 86 test(function() { |
| 87 var element = document.createElementNS(svgNs, 'a'); |
| 88 element.setAttributeNS(null, 'href', 'foo'); |
| 89 element.setAttributeNS(xlinkNs, 'href', 'bar'); |
| 90 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 91 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 92 assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); |
| 93 |
| 94 element.removeAttributeNS(null, 'href'); |
| 95 assert_false(element.hasAttributeNS(null, 'href'), '"href" no longer exist')
; |
| 96 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exi
st'); |
| 97 assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); |
| 98 }, document.title+', IDL href reflects "xlink:href" after removeAttribute(href).
'); |
| 99 |
| 100 test(function() { |
| 101 var element = document.createElementNS(svgNs, 'a'); |
| 102 element.setAttributeNS(null, 'href', 'foo'); |
| 103 element.setAttributeNS(xlinkNs, 'href', 'bar'); |
| 104 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 105 assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); |
| 106 assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); |
| 107 |
| 108 element.removeAttributeNS(xlinkNs, 'href'); |
| 109 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longe
r exist'); |
| 110 assert_true(element.hasAttributeNS(null, 'href'), '"href" still exist'); |
| 111 assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); |
| 112 }, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href)
has no effect.'); |
| 113 |
| 114 test(function() { |
| 115 var element = document.createElementNS(svgNs, 'a'); |
| 116 element.setAttributeNS(xlinkNs, 'href', 'bar'); |
| 117 assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); |
| 118 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 119 assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); |
| 120 |
| 121 element.removeAttributeNS(xlinkNs, 'href'); |
| 122 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longe
r exist'); |
| 123 assert_equals(element.href.baseVal, ''); |
| 124 }, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href)
resets to default.'); |
| 125 |
| 126 test(function() { |
| 127 var element = document.createElementNS(svgNs, 'a'); |
| 128 element.setAttributeNS(xlinkNs, 'xlink:href', 'bar'); |
| 129 assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); |
| 130 assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); |
| 131 assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); |
| 132 |
| 133 element.removeAttributeNS(xlinkNs, 'href'); |
| 134 assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longe
r exist'); |
| 135 assert_equals(element.href.baseVal, ''); |
| 136 }, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href)
w/o NS-prefix resets to default.'); |
| 137 </script> |
OLD | NEW |