Bug 1450824 [wpt PR 10275] - Add tests for rel, rellist, download, and text on SVGAElement, a=testonly
authorChris Lilley <chris@w3.org>
Fri, 10 Aug 2018 16:07:15 +0000
changeset 431153 5a7e0c138ab4
parent 431152 83db2554a258
child 431154 7dff426db9e5
push id34429
push usercbrindusan@mozilla.com
push date2018-08-12 21:49 +0000
treeherdermozilla-central@83d0673bbca4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1450824, 10275
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1450824 [wpt PR 10275] - Add tests for rel, rellist, download, and text on SVGAElement, a=testonly Automatic update from web-platform-testsMerge pull request #10275 from dstorey/svgaelement-additions Add tests for rel, rellist, download, and text on SVGAElement -- wpt-commits: 60f5bae752dd625ae83a730c635254cdb9f3d970 wpt-pr: 10275
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/svg/linking/scripted/a-download-click.svg
testing/web-platform/tests/svg/linking/scripted/a.rel-getter-01.svg
testing/web-platform/tests/svg/linking/scripted/a.rel-setter-01.svg
testing/web-platform/tests/svg/linking/scripted/a.text-getter-01.svg
testing/web-platform/tests/svg/linking/scripted/a.text-setter-01.svg
testing/web-platform/tests/svg/linking/scripted/rellist-feature-detection.svg
testing/web-platform/tests/svg/linking/scripted/resources/a-download-click.svg
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -300475,16 +300475,21 @@
      {}
     ]
    ],
    "svg/linking/reftests/use-descendant-combinator-ref.html": [
     [
      {}
     ]
    ],
+   "svg/linking/scripted/resources/a-download-click.svg": [
+    [
+     {}
+    ]
+   ],
    "svg/linking/scripted/testScripts/dummyScript.js": [
     [
      {}
     ]
    ],
    "svg/linking/scripted/testScripts/externalScript1.js": [
     [
      {}
@@ -391023,16 +391028,46 @@
     ]
    ],
    "svg/idlharness.window.js": [
     [
      "/svg/idlharness.window.html",
      {}
     ]
    ],
+   "svg/linking/scripted/a-download-click.svg": [
+    [
+     "/svg/linking/scripted/a-download-click.svg",
+     {}
+    ]
+   ],
+   "svg/linking/scripted/a.rel-getter-01.svg": [
+    [
+     "/svg/linking/scripted/a.rel-getter-01.svg",
+     {}
+    ]
+   ],
+   "svg/linking/scripted/a.rel-setter-01.svg": [
+    [
+     "/svg/linking/scripted/a.rel-setter-01.svg",
+     {}
+    ]
+   ],
+   "svg/linking/scripted/a.text-getter-01.svg": [
+    [
+     "/svg/linking/scripted/a.text-getter-01.svg",
+     {}
+    ]
+   ],
+   "svg/linking/scripted/a.text-setter-01.svg": [
+    [
+     "/svg/linking/scripted/a.text-setter-01.svg",
+     {}
+    ]
+   ],
    "svg/linking/scripted/href-animate-element.html": [
     [
      "/svg/linking/scripted/href-animate-element.html",
      {}
     ]
    ],
    "svg/linking/scripted/href-mpath-element.html": [
     [
@@ -391047,16 +391082,22 @@
     ]
    ],
    "svg/linking/scripted/href-script-element.html": [
     [
      "/svg/linking/scripted/href-script-element.html",
      {}
     ]
    ],
+   "svg/linking/scripted/rellist-feature-detection.svg": [
+    [
+     "/svg/linking/scripted/rellist-feature-detection.svg",
+     {}
+    ]
+   ],
    "svg/path/error-handling/bounding.svg": [
     [
      "/svg/path/error-handling/bounding.svg",
      {}
     ]
    ],
    "svg/path/interfaces/SVGAnimatedPathData-removed.svg": [
     [
@@ -634726,32 +634767,60 @@
   "svg/linking/reftests/use-descendant-combinator-003.html": [
    "14bf5bd122f6aec8bed1887acd3c98362249b6a4",
    "reftest"
   ],
   "svg/linking/reftests/use-descendant-combinator-ref.html": [
    "dae3fc1173b9280de8959edff3d5991a8b4c7593",
    "support"
   ],
+  "svg/linking/scripted/a-download-click.svg": [
+   "406d0e6ba56681ea3026c74614fe79a83f3aa61e",
+   "testharness"
+  ],
+  "svg/linking/scripted/a.rel-getter-01.svg": [
+   "f4f1fdb4f3af9233b7121f828e47d2ccaae7a975",
+   "testharness"
+  ],
+  "svg/linking/scripted/a.rel-setter-01.svg": [
+   "55470a81b56973667cf5aae33ef4b4a78e686bab",
+   "testharness"
+  ],
+  "svg/linking/scripted/a.text-getter-01.svg": [
+   "d0b26f2042e4cfdc12ef9211b0408db6b22d91af",
+   "testharness"
+  ],
+  "svg/linking/scripted/a.text-setter-01.svg": [
+   "53ad8fce9a6979ae7c81566958b6732ebe975b87",
+   "testharness"
+  ],
   "svg/linking/scripted/href-animate-element.html": [
    "f0b99209a80193db0ffe994d18fc2c42e6485ea5",
    "testharness"
   ],
   "svg/linking/scripted/href-mpath-element.html": [
    "8fb9f0f1aed6b3f6d7b70ed4cdcd7fdd7a19175f",
    "testharness"
   ],
   "svg/linking/scripted/href-script-element-markup.html": [
    "0c6eb23cb66bc5c3e641c7e53011b030f33c5967",
    "testharness"
   ],
   "svg/linking/scripted/href-script-element.html": [
    "48f49085080de3747edbadacae7ee50ffcc65e39",
    "testharness"
   ],
+  "svg/linking/scripted/rellist-feature-detection.svg": [
+   "c600d64c38696e43fd4970d12ccbf3848fe78d17",
+   "testharness"
+  ],
+  "svg/linking/scripted/resources/a-download-click.svg": [
+   "5d18c3088ad9a62b117f9cfb0aa013e72209699f",
+   "support"
+  ],
   "svg/linking/scripted/testScripts/dummyScript.js": [
    "fbf3c34d61360c49b52b04c8bb31f1d276110751",
    "support"
   ],
   "svg/linking/scripted/testScripts/externalScript1.js": [
    "ba4028ca8013fe748a752617907bf0b92255c720",
    "support"
   ],
new file mode 100644
--- /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.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>
\ No newline at end of file
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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>