Files
sousa-gecko/testing/web-platform/tests/svg/linking/scripted/xlink-href-compat.html
T
Karl Dubost 34126bd0d4 Bug 2031535 [wpt PR 59066] - Fix #59047 - fix SVG fresh specs links, a=testonly
Automatic update from web-platform-tests
Fix #59047 - fix SVG fresh specs links

--

wpt-commits: bc058f342f2aed8c63fdb6f0f35249952d076eb7
wpt-pr: 59066
2026-04-23 10:10:37 +00:00

158 lines
8.4 KiB
HTML

<!DOCTYPE html>
<title>XLink 'href' backwards compatibility</title>
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/linking.html#XLinkRefAttrs">
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/linking.html#linkRefAttrs">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const svgNs = 'http://www.w3.org/2000/svg';
const xlinkNs = 'http://www.w3.org/1999/xlink';
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(null, 'href', 'foo');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
assert_equals(element.href.baseVal, 'foo');
element.href.baseVal = 'bar';
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still does not exist');
assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists');
assert_equals(element.getAttributeNS(null, 'href'), 'bar');
}, document.title+', IDL href backed by "href" after setAttribute(href).');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'href', 'foo');
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'foo');
element.href.baseVal = 'bar';
assert_false(element.hasAttributeNS(null, 'href'), '"href" still does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists');
assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar');
}, document.title+', IDL href backed by "xlink:href" after setAttribute(xlink:href).');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.href.baseVal = 'foo';
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_equals(element.href.baseVal, 'foo');
}, document.title+', IDL href backed by "href" after baseVal setter.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.href.baseVal = 'foo';
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_equals(element.href.baseVal, 'foo');
element.setAttributeNS(xlinkNs, 'href', 'bar');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists');
assert_equals(element.href.baseVal, 'foo', 'baseVal still reflects "href"');
assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar');
}, document.title+', IDL href reflects "href"; setAttribute(xlink:href) does not override baseVal setter.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'href', 'baz');
element.href.baseVal = 'foo';
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'foo');
assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
element.setAttributeNS(null, 'href', 'bar');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_equals(element.href.baseVal, 'bar', 'baseVal prefers "href" to "xlink:href"');
assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
assert_equals(element.getAttributeNS(null, 'href'), 'bar');
}, document.title+', IDL href prefers "href" over "xlink:href" after setAttribute(href) overrides.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'href', 'foo');
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'foo');
assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
element.setAttributeNS(xlinkNs, 'xlink:href', 'bar');
assert_equals(element.href.baseVal, 'bar');
}, document.title+', IDL href reflects "xlink:href"; setAttribute(xlink:href) w/ NS-prefix.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(null, 'href', 'foo');
element.setAttributeNS(xlinkNs, 'href', 'bar');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
element.removeAttributeNS(null, 'href');
assert_false(element.hasAttributeNS(null, 'href'), '"href" no longer exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exist');
assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
}, document.title+', IDL href reflects "xlink:href" after removeAttribute(href).');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(null, 'href', 'foo');
element.setAttributeNS(xlinkNs, 'href', 'bar');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
element.removeAttributeNS(xlinkNs, 'href');
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
assert_true(element.hasAttributeNS(null, 'href'), '"href" still exist');
assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) has no effect.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'href', 'bar');
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
element.removeAttributeNS(xlinkNs, 'href');
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
assert_equals(element.href.baseVal, '');
}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) resets to default.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'xlink:href', 'bar');
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
element.removeAttributeNS(xlinkNs, 'href');
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
assert_equals(element.href.baseVal, '');
}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) w/o NS-prefix resets to default.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(xlinkNs, 'xlink:href', 'bar');
assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
assert_equals(element.href.animVal, 'bar', 'animVal reflects "xlink:href"');
}, document.title+', href.animVal reflects "xlink:href" when it is set.');
test(function() {
const element = document.createElementNS(svgNs, 'a');
element.setAttributeNS(null, 'href', 'bar');
assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "href"');
assert_equals(element.href.animVal, 'bar', 'animVal reflects "href"');
}, document.title+', href.animVal reflects "href" when it is set.');
</script>