diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/svg/struct/scripted | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/svg/struct/scripted')
8 files changed, 304 insertions, 0 deletions
diff --git a/testing/web-platform/tests/svg/struct/scripted/autofocus-attribute.svg b/testing/web-platform/tests/svg/struct/scripted/autofocus-attribute.svg new file mode 100644 index 0000000000..edf200c4c7 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/autofocus-attribute.svg @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:h="http://www.w3.org/1999/xhtml"> + <title>Autofocus attribute</title> + <metadata> + <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#autofocusattribute"/> + </metadata> + <h:script src="/resources/testharness.js"/> + <h:script src="/resources/testharnessreport.js"/> + <h:script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"/> + <script><![CDATA[ +const SVG_NS = 'http://www.w3.org/2000/svg'; + +promise_test(async t => { + let w = window.open('blank.svg'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + const svgA = w.document.createElementNS(SVG_NS, 'a'); + svgA.setAttribute('href', '#'); + svgA.setAttribute('autofocus', 'autofocus'); + w.document.documentElement.appendChild(svgA); + await waitUntilStableAutofocusState(w); + assert_equals(w.document.activeElement, svgA); +}, '<a> should support autofocus'); + +promise_test(async t => { + let w = window.open('blank.svg'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + const path = w.document.createElementNS(SVG_NS, 'path'); + path.setAttribute('d', 'M0,0h8v8z'); + path.setAttribute('tabindex', '0'); + path.setAttribute('autofocus', 'autofocus'); + w.document.documentElement.appendChild(path); + await waitUntilStableAutofocusState(w); + assert_equals(w.document.activeElement, path); +}, 'Renderable element with tabindex should support autofocus'); + +promise_test(async t => { + let w = window.open('blank.svg'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + let element = w.document.createElementNS(SVG_NS, 'metadata'); + element.setAttribute('tabindex', '0'); + element.setAttribute('autofocus', 'autofocus'); + w.document.documentElement.appendChild(element); + await waitUntilStableAutofocusState(w); + // https://html.spec.whatwg.org/C/#dom-documentorshadowroot-activeelement + // 6. If candidate's document element is non-null, then return that document + // element. + assert_equals(w.document.activeElement.tagName, 'svg'); +}, 'Never-rendered element with tabindex should not support autofocus'); +]]></script> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/blank.svg b/testing/web-platform/tests/svg/struct/scripted/blank.svg new file mode 100644 index 0000000000..9e560bdc5f --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/blank.svg @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg"></svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-001.svg b/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-001.svg new file mode 100644 index 0000000000..059cdef2a6 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/svg-checkIntersection-001.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml"> + <h:script src="/resources/testharness.js"/> + <h:script src="/resources/testharnessreport.js"/> + <script> + const test = async_test('checkIntersection() / checkEnclosure() with null ref. element'); + window.onload = test.step_func_done(() => { + const root = document.documentElement; + assert_throws_js(TypeError, () => root.checkIntersection(null, root.createSVGRect())); + assert_throws_js(TypeError, () => root.checkEnclosure(null, root.createSVGRect())); + }); + </script> + <!-- This test passes if it does not crash. --> + <text>PASS</text> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-001.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-001.svg new file mode 100644 index 0000000000..a360bad3d3 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-001.svg @@ -0,0 +1,31 @@ +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:html="http://www.w3.org/1999/xhtml"> +<html:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__getIntersectionList"/> +<html:script src="/resources/testharness.js"/> +<html:script src="/resources/testharnessreport.js"/> +<html:link rel="stylesheet" href="/fonts/ahem.css"/> +<style> +text { + font-family: Ahem; + font-size: 100px; +} +</style> +<text x="0" y="80">Text0</text> +<text x="0" y="80" style="display:none">Text1</text> +<text x="0" y="80" pointer-events="none">Text2</text> +<text x="0" y="80">Text3</text> + +<script> +test(t => { + const svg = document.documentElement; + const rect = svg.createSVGRect(); + rect.x = 10; + rect.y = 70; + rect.width = 20; + rect.height = 20; + const texts = document.querySelectorAll('text'); + const list = svg.getIntersectionList(rect, null); + assert_array_equals(list, [texts[0], texts[3]]); +}, 'SVGSVGElement.getIntersectionList()'); +</script> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg new file mode 100644 index 0000000000..c2c1f8e425 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-002.svg @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg id="root" xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml"> + <h:script src="/resources/testharness.js"/> + <h:script src="/resources/testharnessreport.js"/> + <script> + const test = async_test('getIntersectionList() on clipped element'); + window.onload = test.step_func_done(() => { + const testSVG = document.getElementById('root'); + const r = testSVG.createSVGRect(); + r.x = 0; + r.y = 0; + r.width = 100; + r.height = 100; + + assert_equals(testSVG.getIntersectionList(r, testSVG).length, 1); + }); + </script> + <rect x="0" y="0" width="200" height="200"/> + <clipPath id="MyClip"> + <rect y="100" width="200" height="100"/> + </clipPath> + <rect x="0" y="0" width="200" height="200" clip-path="url(#MyClip)" fill="green"/> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-003.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-003.svg new file mode 100644 index 0000000000..b08ea71b36 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-003.svg @@ -0,0 +1,26 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml" + id="askedForIntersection"> +<h:script src="/resources/testharness.js"/> +<h:script src="/resources/testharnessreport.js"/> +<style> +.c1:nth-last-of-type(1n) { } +</style> +<script> + const test = async_test('getIntersectionList() crash test'); + window.onload = test.step_func_done(() => { + docElement = document.documentElement; + textarea = document.createElementNS("http://www.w3.org/1999/xhtml", "textarea"); + textarea.setAttribute("class", "c1"); + docElement.appendChild(textarea); + object = document.createElementNS("http://www.w3.org/1999/xhtml", "object"); + object.setAttribute("usemap", "#DivLogo-map"); + iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); + docElement.appendChild(iframe); + var svg = document.getElementById('askedForIntersection'); + var rect = svg.createSVGRect(); + svg.getIntersectionList(rect, svg); + }); +</script> +<rect style='content: counters(c, ".", decimal)'></rect> +<text x="10" y="50">PASS (didn't crash)</text> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-004.svg b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-004.svg new file mode 100644 index 0000000000..c029a3b070 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-004.svg @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml"> + <h:script src="/resources/testharness.js"/> + <h:script src="/resources/testharnessreport.js"/> + <script> + const test = async_test('getIntersectionList() with nested <svg>'); + window.onload = test.step_func_done(() => { + const testSVG = document.getElementById('askedForIntersection'); + const r = testSVG.createSVGRect(); + r.x = 0; + r.y = 0; + r.width = 100; + r.height = 100; + + assert_equals(testSVG.getIntersectionList(r, testSVG).length, 2); + }); + </script> + <rect x="0" y="0" width="100" height="100" id="r1"/> + <svg id="askedForIntersection"> + <rect x="0" y="0" width="100" height="100" id="r2"/> + <svg id="nestedSVG"> + <rect x="0" y="0" width="100" height="100" id="r3"/> + </svg> + </svg> +</svg> diff --git a/testing/web-platform/tests/svg/struct/scripted/use-load-error-events.tentative.html b/testing/web-platform/tests/svg/struct/scripted/use-load-error-events.tentative.html new file mode 100644 index 0000000000..2c52072e16 --- /dev/null +++ b/testing/web-platform/tests/svg/struct/scripted/use-load-error-events.tentative.html @@ -0,0 +1,128 @@ +<!doctype html> +<title>'load' and 'error' events for SVG <use></title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/rendering-utils.js"></script> +<svg> + <defs> + <rect id="local" width="100" height="100" fill="blue"/> + </defs> +</svg> +<script> + function newUseElement() { + return document.createElementNS('http://www.w3.org/2000/svg', 'use'); + } + function makeWatcher(root, eventType, url) { + return new Promise(resolve => { + const watcher = newUseElement(); + watcher.addEventListener(eventType, resolve); + watcher.setAttribute('href', url); + root.appendChild(watcher); + }); + } + function expectEvents(t, element, event) { + return new EventWatcher(t, element, ['load', 'error']).wait_for(event); + } + const DATA_URL_PAYLOAD = + '<svg xmlns="http://www.w3.org/2000/svg"><rect id="green" fill="lime" width="100" height="50"/></svg>'; + const cookie = Date.now(); + let counter = 0; + function makeCookie(index) { + return `${cookie}-${index}`; + } + function getUrl(type) { + const cookie = makeCookie(counter++); + switch (type) { + case 'existing': + return `/images/colors.svg?${cookie}#green`; + case 'existing-data': + return `data:image/svg+xml,${DATA_URL_PAYLOAD}#green`; + case 'non-existing': + return `/images/this-file-should-not-exist.svg?${cookie}#green`; + case 'broken': + return `/images/fail.gif?${cookie}#green`; + } + } + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + expectEvents(t, use, []); + svg.appendChild(use).setAttribute('href', '#local'); + return waitForAtLeastOneFrame(); + }, document.title + ', local reference, existing'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + expectEvents(t, use, []); + svg.appendChild(use).setAttribute('href', '#local_not_there'); + return waitForAtLeastOneFrame(); + }, document.title + ', local reference, non-existing'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + const watcher = expectEvents(t, use, ['load']); + const url = getUrl('existing'); + svg.appendChild(use).setAttribute('href', url); + return watcher; + }, document.title + ', external reference, existing'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + const watcher = expectEvents(t, use, ['error']); + const url = getUrl('existing-data'); + svg.appendChild(use).setAttribute('href', url); + return watcher; + }, document.title + ', external data: URL reference, existing'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + const watcher = expectEvents(t, use, ['error']); + const url = getUrl('non-existing'); + svg.appendChild(use).setAttribute('href', url); + return watcher; + }, document.title + ', external reference, non-existing'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + const watcher = expectEvents(t, use, ['error']); + const url = getUrl('broken'); + svg.appendChild(use).setAttribute('href', url); + return watcher; + }, document.title + ', external reference, existing, parse error'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + expectEvents(t, use, []); + const url = getUrl('existing'); + svg.appendChild(use).setAttribute('href', url); + t.step_timeout(() => use.setAttribute('href', '#local')); + return makeWatcher(svg, 'load', url); + }, document.title + ', external reference, existing, changed to local reference while loading'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + expectEvents(t, use, []); + const url = getUrl('existing-data'); + svg.appendChild(use).setAttribute('href', url); + t.step_timeout(() => use.setAttribute('href', '#local')); + return makeWatcher(svg, 'error', url); + }, document.title + ', external data: URL reference, existing, changed to local reference while loading'); + + promise_test(t => { + const svg = document.querySelector('svg'); + const use = newUseElement(); + expectEvents(t, use, []); + const url = getUrl('non-existing'); + svg.appendChild(use).setAttribute('href', url); + t.step_timeout(() => use.setAttribute('href', '#local')); + return makeWatcher(svg, 'error', url); + }, document.title + ', external reference, non-existing, changed to local reference while loading'); +</script> |