summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/linking/scripted
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/svg/linking/scripted')
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/a-download-click.svg33
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/a.rel-getter-01.svg20
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/a.rel-setter-01.svg21
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/a.text-getter-01.svg37
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/a.text-setter-01.svg44
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/href-animate-element.html138
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/href-mpath-element.html103
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/href-script-element-markup.html27
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/href-script-element.html112
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/rellist-feature-detection.svg74
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/resources/a-download-click.svg4
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/testScripts/dummyScript.js3
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript1.js3
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript2.js3
-rw-r--r--testing/web-platform/tests/svg/linking/scripted/testcommon.js42
15 files changed, 664 insertions, 0 deletions
diff --git a/testing/web-platform/tests/svg/linking/scripted/a-download-click.svg b/testing/web-platform/tests/svg/linking/scripted/a-download-click.svg
new file mode 100644
index 0000000000..b728603d54
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/a-download-click.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>Clicking on an &lt;a> element with a download attribute must not throw an exception</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ "use strict";
+ async_test(t => {
+ const frame = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
+ const root = document.querySelector("svg");
+
+ frame.addEventListener("load", t.step_func(function () {
+ frame.contentWindow.addEventListener(
+ "beforeunload", t.unreached_func("Navigated instead of downloading"));
+ const string = "test";
+ const blob = new Blob([string], { type: "text/html" });
+
+ const link = frame.contentDocument.querySelector("#blob-url");
+ link.href.baseVal = URL.createObjectURL(blob);
+
+ link.dispatchEvent(new Event('click'));
+
+ t.step_timeout(() => t.done(), 1000);
+ }));
+ frame.src = "resources/a-download-click.svg";
+ root.appendChild(frame);
+ }, "Clicking on an <a> element with a download attribute must not throw an exception");
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/linking/scripted/a.rel-getter-01.svg b/testing/web-platform/tests/svg/linking/scripted/a.rel-getter-01.svg
new file mode 100644
index 0000000000..f4f1fdb4f3
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/a.rel-getter-01.svg
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>SVGAElement.rel getter</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <a id="test" href="a" rel="noreferrer"></a>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var a = document.getElementById("test");
+
+ test(function() {
+ assert_equals(a.rel, "noreferrer");
+ }, "Test anchor's rel getter");
+ });
+ ]]></script>
+</svg> \ No newline at end of file
diff --git a/testing/web-platform/tests/svg/linking/scripted/a.rel-setter-01.svg b/testing/web-platform/tests/svg/linking/scripted/a.rel-setter-01.svg
new file mode 100644
index 0000000000..55470a81b5
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/a.rel-setter-01.svg
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>SVGAElement.rel setter</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <a id="test" href="a"></a>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var a = document.getElementById("test");
+
+ test(function() {
+ a.rel = "noreferrer"
+ assert_equals(a.rel, "noreferrer");
+ }, "Test anchor's rel setter");
+ });
+ ]]></script>
+</svg> \ No newline at end of file
diff --git a/testing/web-platform/tests/svg/linking/scripted/a.text-getter-01.svg b/testing/web-platform/tests/svg/linking/scripted/a.text-getter-01.svg
new file mode 100644
index 0000000000..d0b26f2042
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/a.text-getter-01.svg
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>SVGAElement.text getting</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <script>var b</script>
+ <g id="test">
+ <a href="a">a b c </a>
+ <a href="b">a <!--b-->b c </a>
+ <a href="c">a <b>b</b> c </a>
+ <a href="d">a <script>b</script> c </a>
+ <script><![CDATA[
+ var e = document.getElementById("test")
+ .appendChild(document.createElementNS("http://www.w3.org/2000/svg","a"));
+ e.href.baseVal = "d";
+ e.appendChild(document.createTextNode("a "));
+ e.appendChild(document.createTextNode("b "));
+ e.appendChild(document.createTextNode("c "));
+ ]]></script>
+ </g>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var list = document.getElementById("test")
+ .getElementsByTagName("a");
+ for (var i = 0, il = list.length; i < il; ++i) {
+ test(function() {
+ assert_equals(list[i].text, list[i].textContent);
+ assert_equals(list[i].text, "a b c ");
+ }, "Test for anchor " + i);
+ }
+ });
+ ]]></script>
+</svg> \ No newline at end of file
diff --git a/testing/web-platform/tests/svg/linking/scripted/a.text-setter-01.svg b/testing/web-platform/tests/svg/linking/scripted/a.text-setter-01.svg
new file mode 100644
index 0000000000..53ad8fce9a
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/a.text-setter-01.svg
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>SVGAElement.text setting</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <g id="test">
+ <a href="a">a b c</a>
+ <a href="b">a <!--b--> c</a>
+ <a href="c">a <b>b</b> c</a>
+ <script><![CDATA[
+ var d = document.getElementById("test")
+ .appendChild(document.createElementNS("http://www.w3.org/2000/svg","a"));
+ d.href.baseVal = "d";
+ d.appendChild(document.createTextNode("a "));
+ d.appendChild(document.createTextNode("b "));
+ d.appendChild(document.createTextNode("c "));
+ ]]></script>
+ </g>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var list = document.getElementById("test")
+ .getElementsByTagName("a");
+ for (var i = 0, il = list.length; i < il; ++i) {
+ test(function() {
+ list[i].text = "x";
+ assert_equals(list[i].text, "x");
+ assert_equals(list[i].textContent, "x");
+ assert_equals(list[i].firstChild.data, "x");
+ assert_equals(list[i].childNodes.length, 1);
+
+ list[i].textContent = "y";
+ assert_equals(list[i].text, "y");
+ assert_equals(list[i].textContent, "y");
+ assert_equals(list[i].firstChild.data, "y");
+ assert_equals(list[i].childNodes.length, 1);
+ }, "Test for anchor " + i);
+ }
+ });
+ ]]></script>
+</svg> \ No newline at end of file
diff --git a/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html b/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html
new file mode 100644
index 0000000000..f0b99209a8
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html
@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Href - animate element tests</title>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='testcommon.js'></script>
+<body>
+<div id='log'></div>
+<svg id='svg' width='100' height='100' viewBox='0 0 100 100'></svg>
+<script>
+'use strict';
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var rect1 = createSVGElement(t, 'rect', svg,
+ { 'width': '10px',
+ 'height': '10px',
+ 'id': 'rect1' });
+ var rect2 = createSVGElement(t, 'rect', svg,
+ { 'width': '10px',
+ 'height': '10px',
+ 'id': 'rect2' });
+ var animate = createSVGElement(t, 'animate', svg,
+ { 'attributeName': 'x',
+ 'from': '0',
+ 'to': '100',
+ 'dur': '10s' });
+ animate.setAttribute('href', '#rect1');
+ animate.setAttributeNS(XLINKNS, 'xlink:href', '#rect2');
+ assert_equals(animate.targetElement, rect1);
+
+ return waitEvent(animate, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ assert_equals(rect1.x.animVal.value, 50);
+ assert_equals(rect2.x.animVal.value, 0);
+ });
+}, 'Test for animate element when setting both href and xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var rect1 = createSVGElement(t, 'rect', svg,
+ { 'width': '10px',
+ 'height': '10px',
+ 'id': 'rect1' });
+ var rect2 = createSVGElement(t, 'rect', svg,
+ { 'width': '10px',
+ 'height': '10px',
+ 'id': 'rect2' });
+ var transform = createSVGElement(t, 'animateTransform', svg,
+ { 'attributeName': 'transform',
+ 'type': 'translate',
+ 'from': '0',
+ 'to': '100',
+ 'dur': '10s' });
+
+ transform.setAttribute('href', '#rect1');
+ transform.setAttributeNS(XLINKNS, 'xlink:href', '#rect2');
+ assert_equals(transform.targetElement, rect1);
+
+ return waitEvent(transform, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ assert_equals(rect1.getCTM().e, 50);
+ assert_equals(rect2.getCTM().e, 0);
+ });
+}, 'Test for animateTransform element when setting both href and xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var circle1 = createSVGElement(t, 'circle', svg,
+ { 'cx': '50',
+ 'cy': '50',
+ 'r': '40',
+ 'id': 'circle1' });
+ var circle2 = createSVGElement(t, 'circle', svg,
+ { 'cx': '50',
+ 'cy': '50',
+ 'r': '40',
+ 'id': 'circle2' });
+ var animate = createSVGElement(t, 'animate', svg,
+ { 'attributeName': 'cx',
+ 'from': '50',
+ 'to': '150',
+ 'dur': '10s' });
+ animate.setAttribute('href', '#circle1');
+ animate.setAttributeNS(XLINKNS, 'xlink:href', '#circle2');
+ assert_equals(animate.targetElement, circle1);
+
+ return waitEvent(animate, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ assert_equals(circle1.cx.animVal.value, 100);
+ assert_equals(circle2.cx.animVal.value, 50);
+
+ animate.removeAttribute('href');
+ assert_equals(animate.targetElement, circle2);
+ assert_equals(circle1.cx.animVal.value, 50);
+ assert_equals(circle2.cx.animVal.value, 100);
+ });
+}, 'Test for animate element when removing href but we still have xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var circle1 = createSVGElement(t, 'circle', svg,
+ { 'cx': '50',
+ 'cy': '50',
+ 'r': '40',
+ 'id': 'circle1' });
+ var circle2 = createSVGElement(t, 'circle', svg,
+ { 'cx': '50',
+ 'cy': '50',
+ 'r': '40',
+ 'id': 'circle2' });
+ var animate = createSVGElement(t, 'animate', svg,
+ { 'attributeName': 'cx',
+ 'from': '50',
+ 'to': '150',
+ 'dur': '10s' });
+ animate.setAttribute('href', '#circle1');
+ animate.setAttributeNS(XLINKNS, 'xlink:href', '#circle2');
+ assert_equals(animate.targetElement, circle1);
+
+ return waitEvent(animate, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ assert_equals(circle1.cx.animVal.value, 100);
+ assert_equals(circle2.cx.animVal.value, 50);
+
+ animate.removeAttributeNS(XLINKNS, 'href');
+ assert_equals(animate.targetElement, circle1);
+ assert_equals(circle1.cx.animVal.value, 100);
+ assert_equals(circle2.cx.animVal.value, 50);
+ });
+}, 'Test for animate element when removing xlink:href but we still have href');
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/svg/linking/scripted/href-mpath-element.html b/testing/web-platform/tests/svg/linking/scripted/href-mpath-element.html
new file mode 100644
index 0000000000..8fb9f0f1ae
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/href-mpath-element.html
@@ -0,0 +1,103 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Href - mpath element tests</title>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='testcommon.js'></script>
+<body>
+<div id='log'></div>
+<svg id='svg' width='100' height='100' viewBox='0 0 100 100'></svg>
+<script>
+'use strict';
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var path1 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath1', 'd': 'M 0,0 L 100,0' });
+ var path2 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath2', 'd': 'M 0,0 L 0,100' });
+ var rect = createSVGElement(t, 'rect', svg,
+ { 'width': '10px', 'height': '10px' });
+ var animateMotion = createSVGElement(t, 'animateMotion', rect,
+ { 'dur': '10s' });
+ var mpath = createSVGElement(t, 'mpath', animateMotion);
+ mpath.setAttribute('href', '#MyPath1');
+ mpath.setAttributeNS(XLINKNS, 'xlink:href', '#MyPath2');
+ assert_equals(mpath.href.baseVal, '#MyPath1');
+
+ return waitEvent(animateMotion, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(1);
+ var ctm = rect.getCTM();
+ assert_equals(ctm.e, 10);
+ assert_equals(ctm.f, 0);
+
+ svg.setCurrentTime(5);
+ ctm = rect.getCTM();
+ assert_equals(ctm.e, 50);
+ assert_equals(ctm.f, 0);
+ });
+}, 'Test for mpath when setting both href and xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var path1 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath1', 'd': 'M 0,0 L 100,0' });
+ var path2 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath2', 'd': 'M 0,0 L 0,100' });
+ var rect = createSVGElement(t, 'rect', svg,
+ { 'width': '10px', 'height': '10px' });
+ var animateMotion = createSVGElement(t, 'animateMotion', rect,
+ { 'dur': '10s' });
+ var mpath = createSVGElement(t, 'mpath', animateMotion);
+ mpath.setAttribute('href', '#MyPath1');
+ mpath.setAttributeNS(XLINKNS, 'xlink:href', '#MyPath2');
+
+ return waitEvent(animateMotion, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ var ctm = rect.getCTM();
+ assert_equals(ctm.e, 50);
+ assert_equals(ctm.f, 0);
+
+ mpath.removeAttribute('href');
+ assert_equals(mpath.href.baseVal, '#MyPath2');
+
+ ctm = rect.getCTM();
+ assert_equals(ctm.e, 0);
+ assert_equals(ctm.f, 50);
+ });
+}, 'Test for mpath when removing href but we still have xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var path1 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath1', 'd': 'M 0,0 L 100,0' });
+ var path2 = createSVGElement(t, 'path', svg,
+ { 'id': 'MyPath2', 'd': 'M 0,0 L 0,100' });
+ var rect = createSVGElement(t, 'rect', svg,
+ { 'width': '10px', 'height': '10px' });
+ var animateMotion = createSVGElement(t, 'animateMotion', rect,
+ { 'dur': '10s' });
+ var mpath = createSVGElement(t, 'mpath', animateMotion);
+ mpath.setAttribute('href', '#MyPath1');
+ mpath.setAttributeNS(XLINKNS, 'xlink:href', '#MyPath2');
+
+ return waitEvent(animateMotion, 'begin').then(function() {
+ svg.pauseAnimations();
+ svg.setCurrentTime(5);
+ var ctm = rect.getCTM();
+ assert_equals(ctm.e, 50);
+ assert_equals(ctm.f, 0);
+
+ mpath.removeAttributeNS(XLINKNS, 'href');
+ assert_equals(mpath.href.baseVal, '#MyPath1');
+
+ ctm = rect.getCTM();
+ assert_equals(ctm.e, 50);
+ assert_equals(ctm.f, 0);
+ });
+}, 'Test for mpath when removing xlink:href but we still have href');
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/svg/linking/scripted/href-script-element-markup.html b/testing/web-platform/tests/svg/linking/scripted/href-script-element-markup.html
new file mode 100644
index 0000000000..0c6eb23cb6
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/href-script-element-markup.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Href - script element tests on markup</title>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='testcommon.js'></script>
+<body>
+<div id='log'></div>
+<svg id='svg' width='100' height='100' viewBox='0 0 100 100'>
+ <script id='script' href='testScripts/externalScript1.js'
+ xlink:href='testScripts/externalScript2.js'></script>
+</svg>
+<script>
+'use strict';
+
+// Use an independent test file for markup testing because it may affect other
+// tests.
+
+test(function(t) {
+ var script = document.getElementById('script');
+ assert_equals(script.href.baseVal, 'testScripts/externalScript1.js');
+ assert_equals(loadedScript(), 'externalScript1');
+}, 'Test for loading external script by markup when setting both href and ' +
+ 'xlink:href');
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/svg/linking/scripted/href-script-element.html b/testing/web-platform/tests/svg/linking/scripted/href-script-element.html
new file mode 100644
index 0000000000..48f4908508
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/href-script-element.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Href - script element tests</title>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='testcommon.js'></script>
+<body>
+<div id='log'></div>
+<svg id='svg' width='100' height='100' viewBox='0 0 100 100'>
+</svg>
+<script>
+'use strict';
+
+// Note:
+// The order of these tests shouldn't be changed because we don't unload
+// the external script file even if we expect the <script> element will be
+// removed by childNode.remove() and Garbage Collection after a test has been
+// finished. Therefore, I intentionally make them load externalScript1 and
+// externalScript2 alternately, and we can check if the results are changed
+// after reloading the other script.
+// Throughout this test, we periodically need to verify that a script
+// *does not load* after we've made a tweak. To do that, we have to
+// wait "long enough for it to have loaded", and then make sure nothing
+// has changed. We estimate "long enough" by adding an extra dummy
+// <script> element and watching for its load event.
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var script = createSVGElement(t, 'script', svg);
+
+ script.setAttribute('type', 'text/javascript');
+ script.setAttribute('href', 'testScripts/externalScript1.js');
+ assert_equals(script.href.baseVal, 'testScripts/externalScript1.js');
+
+ return waitEvent(script, 'load').then(function() {
+ assert_equals(loadedScript(), 'externalScript1',
+ 'Link to correct external script');
+
+ script.setAttributeNS(XLINKNS, 'xlink:href',
+ 'testScripts/externalScript2.js');
+
+ // Load an dummy script to trigger a load event.
+ var dummyScript = createSVGElement(t, 'script', svg);
+ dummyScript.setAttribute('href', 'testScripts/dummyScript.js');
+ return waitEvent(dummyScript, 'load');
+ }).then(function() {
+ assert_equals(script.href.baseVal, 'testScripts/externalScript1.js');
+ assert_equals(loadedScript(), 'externalScript1',
+ 'Still link to the external script from href');
+ });
+}, 'Test for loading external script from href when setting href and ' +
+ 'then xlink:href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var script = createSVGElement(t, 'script', svg);
+
+ script.setAttribute('type', 'text/javascript');
+ script.setAttributeNS(XLINKNS, 'xlink:href',
+ 'testScripts/externalScript2.js');
+ assert_equals(script.href.baseVal, 'testScripts/externalScript2.js');
+
+ return waitEvent(script, 'load').then(function() {
+ assert_equals(loadedScript(), 'externalScript2',
+ 'Link to the external script from xlink:href');
+
+ script.setAttribute('href', 'testScripts/externalScript1.js');
+
+ // Load an dummy script to trigger a load event.
+ var dummyScript = createSVGElement(t, 'script', svg);
+ dummyScript.setAttribute('href', 'testScripts/dummyScript.js');
+ return waitEvent(dummyScript, 'load');
+ }).then(function() {
+ assert_equals(script.href.baseVal, 'testScripts/externalScript1.js',
+ 'href() should prefer href attribute over xlink:href');
+ assert_equals(loadedScript(), 'externalScript2',
+ 'Still link to the external script from xlink:href');
+ });
+}, 'Test for loading external script from xlnk:href by adding xlink:href and ' +
+ 'then href');
+
+promise_test(function(t) {
+ var svg = document.getElementById('svg');
+ var script = createSVGElement(t, 'script', svg);
+
+ script.setAttribute('type', 'text/javascript');
+ script.setAttribute('href', 'testScripts/externalScript1.js');
+ script.setAttributeNS(XLINKNS, 'xlink:href',
+ 'testScripts/externalScript2.js');
+ assert_equals(script.href.baseVal, 'testScripts/externalScript1.js');
+
+ return waitEvent(script, 'load').then(function() {
+ assert_equals(loadedScript(), 'externalScript1',
+ 'Link to the external script by href');
+
+ script.removeAttribute('href');
+ assert_equals(script.href.baseVal, 'testScripts/externalScript2.js',
+ 'href() returns xlink:href attribute because href was unset');
+
+ // Load an dummy script to trigger a load event.
+ var dummyScript = createSVGElement(t, 'script', svg);
+ dummyScript.setAttribute('href', 'testScripts/dummyScript.js');
+ return waitEvent(dummyScript, 'load');
+ }).then(function() {
+ assert_equals(loadedScript(), 'externalScript1',
+ 'The external script loaded from href is still loaded');
+ });
+}, 'Test for loading external script from href by adding href and ' +
+ 'then xlink:href, and then removing href');
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/svg/linking/scripted/rellist-feature-detection.svg b/testing/web-platform/tests/svg/linking/scripted/rellist-feature-detection.svg
new file mode 100644
index 0000000000..c600d64c38
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/rellist-feature-detection.svg
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <title>Test SVGAElement relList attribute</title>
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/linking.html#InterfaceSVGAElement"/>
+ </metadata>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ let link_support_table = {};
+ // https://html.spec.whatwg.org/multipage/links.html#linkTypes
+ link_support_table['a'] = {
+ supported : ['noreferrer', 'noopener'],
+ unsupported : ['author', 'bookmark', 'external', 'help', 'license',
+ 'nofollow', 'pingback', 'prev', 'search', 'tag',
+ 'modulepreload', 'preload', 'preconnect', 'dns-prefetch',
+ 'stylesheet', 'import', 'icon', 'alternate', 'prefetch',
+ 'prerender', 'next', 'manifest', 'apple-touch-icon',
+ 'apple-touch-icon-precomposed', 'canonical']
+ };
+
+ function test_rellist(tag_name, rel_table) {
+ let element = document.createElementNS("http://www.w3.org/2000/svg", tag_name);
+ let tag = element.tagName;
+ // Test that setting rel is also setting relList, for both
+ // valid and invalid values.
+ element.rel = 'whatever';
+ assert_true(element.relList.contains('whatever'), 'tag = ' + tag + ', setting rel must work');
+ element.rel = 'prefetch';
+ assert_true(element.relList.contains('prefetch'), 'tag = ' + tag + ', setting rel must work');
+ // Test that add() works.
+ element.relList.add('preloadwhatever');
+ assert_equals(element.rel, 'prefetch preloadwhatever', 'tag = ' + tag + ', add must work');
+ assert_true(element.relList.contains('preloadwhatever'), 'tag = ' + tag + ', add must work');
+ // Test that remove() works.
+ element.relList.remove('preloadwhatever');
+ assert_equals(element.rel, 'prefetch', 'tag = ' + tag + ', remove must work');
+ assert_false(element.relList.contains('preloadwhatever'), 'tag = ' + tag + ', remove must work');
+ // Test that toggle() works.
+ element.relList.toggle('prefetch', false);
+ assert_equals(element.rel, '', 'tag = ' + tag + ', toggle must work');
+ element.relList.toggle('prefetch', true);
+ assert_equals(element.rel, 'prefetch', 'tag = ' + tag + ', toggle must work');
+ // Test that replace() works.
+ element.relList.replace('prefetch', 'first');
+ assert_equals(element.rel, 'first', 'tag = ' + tag + ', replace must work');
+ // Test that indexed item getter works.
+ element.relList.add('second');
+ assert_equals(element.relList.length, 2, 'tag = ' + tag + ', relList length must be correct');
+ assert_equals(element.relList[0], 'first', 'tag = ' + tag + ', relList indexed item must work');
+ assert_equals(element.relList[1], 'second', 'tag = ' + tag + ', relList indexed item must work');
+ // Test that relList is [SameObject].
+ let savedRelList = element.relList;
+ element.rel = 'something';
+ assert_equals(element.relList, savedRelList, 'tag = ' + tag + ', SameObject must work');
+
+ // Test that supports() is returning true for valid values
+ // and false for invalid ones.
+ let supported = rel_table['supported'];
+ for (let link_type in supported) {
+ assert_true(element.relList.supports(supported[link_type]), 'tag = ' + tag + ', link type = ' + supported[link_type] + ' must be supported');
+ }
+ let unsupported = rel_table['unsupported'];
+ for (let link_type in unsupported) {
+ assert_false(element.relList.supports(unsupported[link_type]), 'tag = ' + tag + ', link type = ' + unsupported[link_type] + ' must be unsupported');
+ }
+ }
+
+ test(function() {
+ test_rellist('a', link_support_table['a']);
+ }, 'Make sure that relList based feature detection is working');
+ ]]></script>
+</svg> \ No newline at end of file
diff --git a/testing/web-platform/tests/svg/linking/scripted/resources/a-download-click.svg b/testing/web-platform/tests/svg/linking/scripted/resources/a-download-click.svg
new file mode 100644
index 0000000000..5d18c3088a
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/resources/a-download-click.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" x="10" y="10">
+ <a id="blob-url" download="foo.html">Click me</a>
+</svg>
diff --git a/testing/web-platform/tests/svg/linking/scripted/testScripts/dummyScript.js b/testing/web-platform/tests/svg/linking/scripted/testScripts/dummyScript.js
new file mode 100644
index 0000000000..fbf3c34d61
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/testScripts/dummyScript.js
@@ -0,0 +1,3 @@
+function dummyScript() {
+ return "This is a dummy script";
+}
diff --git a/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript1.js b/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript1.js
new file mode 100644
index 0000000000..ba4028ca80
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript1.js
@@ -0,0 +1,3 @@
+function loadedScript() {
+ return "externalScript1";
+}
diff --git a/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript2.js b/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript2.js
new file mode 100644
index 0000000000..db3b60a827
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/testScripts/externalScript2.js
@@ -0,0 +1,3 @@
+function loadedScript() {
+ return "externalScript2";
+}
diff --git a/testing/web-platform/tests/svg/linking/scripted/testcommon.js b/testing/web-platform/tests/svg/linking/scripted/testcommon.js
new file mode 100644
index 0000000000..7d87923f59
--- /dev/null
+++ b/testing/web-platform/tests/svg/linking/scripted/testcommon.js
@@ -0,0 +1,42 @@
+/**
+ * The const var for SVG and xlink namespaces
+ */
+const SVGNS = 'http://www.w3.org/2000/svg';
+const XLINKNS = 'http://www.w3.org/1999/xlink';
+
+/**
+ * Appends a svg element to the parent.
+ *
+ * @param test The testharness.js Test object. If provided, this will be used
+ * to register a cleanup callback to remove the div when the test
+ * finishes.
+ * @param tag The element tag name.
+ * @param parent The parent element of this new created svg element.
+ * @param attrs A dictionary object with attribute names and values to set on
+ * the div.
+ */
+function createSVGElement(test, tag, parent, attrs) {
+ var elem = document.createElementNS(SVGNS, tag);
+ if (attrs) {
+ for (var attrName in attrs) {
+ elem.setAttribute(attrName, attrs[attrName]);
+ }
+ }
+ parent.appendChild(elem);
+ test.add_cleanup(function() {
+ elem.remove();
+ });
+ return elem;
+}
+
+/**
+ * Create a Promise object which resolves when a specific event fires.
+ *
+ * @param object The event target.
+ * @param name The event name.
+ */
+function waitEvent(object, name) {
+ return new Promise(function(resolve) {
+ object.addEventListener(name, resolve, { once: true });
+ });
+}