diff options
Diffstat (limited to 'layout/svg/tests')
24 files changed, 631 insertions, 0 deletions
diff --git a/layout/svg/tests/chrome.ini b/layout/svg/tests/chrome.ini new file mode 100644 index 0000000000..cc1b542a66 --- /dev/null +++ b/layout/svg/tests/chrome.ini @@ -0,0 +1,8 @@ +[test_disabled_chrome.html] +support-files = + svg_example_test.html + svg_example_script.svg + +[test_context_properties_allowed_domains.html] +support-files = + file_context_fill_fallback_red.html diff --git a/layout/svg/tests/file_black_yellow.svg b/layout/svg/tests/file_black_yellow.svg new file mode 100644 index 0000000000..58c5689838 --- /dev/null +++ b/layout/svg/tests/file_black_yellow.svg @@ -0,0 +1,9 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + xmlns:xlink="http://www.w3.org/1999/xlink"> + <rect height="100%" width="100%" fill="yellow" /> + <rect height="50px" width="100px" fill="black" /> +</svg> diff --git a/layout/svg/tests/file_context_fill_fallback_red.html b/layout/svg/tests/file_context_fill_fallback_red.html new file mode 100644 index 0000000000..ac8b5b4203 --- /dev/null +++ b/layout/svg/tests/file_context_fill_fallback_red.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<style> + img { + -moz-context-properties: fill; + fill: green; + } +</style> +<img style="width: 100px; height: 100px;"> +<script> + let domain = location.search.substring(1); + let img = document.querySelector("img"); + img.src = img.alt = `http://${domain}/tests/layout/svg/tests/file_context_fill_fallback_red.svg`; +</script> diff --git a/layout/svg/tests/file_context_fill_fallback_red.svg b/layout/svg/tests/file_context_fill_fallback_red.svg new file mode 100644 index 0000000000..9088555b53 --- /dev/null +++ b/layout/svg/tests/file_context_fill_fallback_red.svg @@ -0,0 +1,8 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + xmlns:xlink="http://www.w3.org/1999/xlink"> + <rect height="100%" width="100%" fill="context-fill red" /> +</svg> diff --git a/layout/svg/tests/file_disabled_iframe.html b/layout/svg/tests/file_disabled_iframe.html new file mode 100644 index 0000000000..55eda75fde --- /dev/null +++ b/layout/svg/tests/file_disabled_iframe.html @@ -0,0 +1,81 @@ +<!doctype html> +<script> + window.is = window.parent.is; + window.SimpleTest = window.parent.SimpleTest; +</script> +<div id="testnodes"><span>hi</span> there <!-- mon ami --></div> +<script> + let t = document.getElementById('testnodes'); + t.innerHTML = null; + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")); + t.firstChild.textContent = "<foo>"; + is(t.innerHTML, "<svg:svg><foo></svg:svg>"); + + // This test crashes if the style tags are not handled correctly + t.innerHTML = `<svg version="1.1"> + <style> + circle { + fill: currentColor; + } + </style> + <g><circle cx="25.8" cy="9.3" r="1.5"/></g> + </svg> + `; + is(t.firstChild.tagName.toLowerCase(), 'svg'); + + // This test crashes if the script tags are not handled correctly + t.innerHTML = `<svg version="1.1"> + <scri` + `pt> + throw "badment, should never fire."; + </scri` + `pt> + <g><circle cx="25.8" cy="9.3" r="1.5"/></g> + </svg>`; + is(t.firstChild.tagName.toLowerCase(), 'svg'); + + t.innerHTML = null; + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); + is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "script")); + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; + is(t.innerHTML, '<svg><script>1&2<3>4 \u003C/script></svg>'); + + t.innerHTML = null; + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); + is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "style")); + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; + is(t.innerHTML, '<svg><style>1&2<3>4 \u003C/style></svg>'); + + // + // Tests for Bug 1673237 + // + + // This test fails if about:blank renders SVGs + t.innerHTML = null; + var iframe = document.createElement("iframe"); + iframe.setAttribute("src", "about:blank") + t.appendChild(iframe); + iframe.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")); + iframe.firstChild.textContent = "<foo>"; + is(iframe.innerHTML, "<svg:svg><foo></svg:svg>"); + + // This test fails if about:blank renders SVGs + var win = window.open("about:blank"); + win.document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")) + win.document.body.firstChild.textContent = "<foo>"; + is(win.document.body.innerHTML, "<svg:svg><foo></svg:svg>"); + win.close(); + + // This test fails if about:srcdoc renders SVGs + t.innerHTML = null; + iframe = document.createElement("iframe"); + iframe.srcdoc = "<svg:svg></svg:svg>"; + iframe.onload = function() { + iframe.contentDocument.body.firstChild.textContent = "<foo>"; + is(iframe.contentDocument.body.innerHTML, "<svg:svg><foo></svg:svg>"); + SimpleTest.finish(); + } + t.appendChild(iframe); +</script> diff --git a/layout/svg/tests/file_embed_sizing_both.svg b/layout/svg/tests/file_embed_sizing_both.svg new file mode 100644 index 0000000000..8bc39b7d02 --- /dev/null +++ b/layout/svg/tests/file_embed_sizing_both.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="400" viewBox="0 0 1 5"></svg> diff --git a/layout/svg/tests/file_embed_sizing_none.svg b/layout/svg/tests/file_embed_sizing_none.svg new file mode 100644 index 0000000000..714efc7ef0 --- /dev/null +++ b/layout/svg/tests/file_embed_sizing_none.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg"></svg> diff --git a/layout/svg/tests/file_embed_sizing_ratio.svg b/layout/svg/tests/file_embed_sizing_ratio.svg new file mode 100644 index 0000000000..b590bb7da6 --- /dev/null +++ b/layout/svg/tests/file_embed_sizing_ratio.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 5"></svg> diff --git a/layout/svg/tests/file_embed_sizing_size.svg b/layout/svg/tests/file_embed_sizing_size.svg new file mode 100644 index 0000000000..76f50b5f08 --- /dev/null +++ b/layout/svg/tests/file_embed_sizing_size.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="900"></svg> diff --git a/layout/svg/tests/file_filter_crossorigin.svg b/layout/svg/tests/file_filter_crossorigin.svg new file mode 100644 index 0000000000..a1b9ad0cab --- /dev/null +++ b/layout/svg/tests/file_filter_crossorigin.svg @@ -0,0 +1,25 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + xmlns:xlink="http://www.w3.org/1999/xlink"> + + <!-- We include these <use> elements simply to be sure the SVG resource URLs + get a chance to block 'onload', if they can be loaded. --> + <use xlink:href="http://mochi.test:8888/tests/layout/svg/tests/filters.svg#empty" /> + <use xlink:href="http://example.org/tests/layout/svg/tests/filters.svg#empty" /> + + <!-- giant yellow rect in the background, just so you can visually tell + that this SVG file has loaded/rendered. --> + <rect height="100%" width="100%" fill="yellow" /> + + <!-- For both rects below: if it's black, its filter resolved successfully. + If it's yellow, it means we failed to load the resource + (e.g. because it was blocked as a cross-origin resource). --> + <rect height="50px" width="100px" fill="yellow" + filter="url(http://mochi.test:8888/tests/layout/svg/tests/filters.svg#NonWhiteToBlack)"/> + <rect y="50px" + height="50px" width="100px" fill="yellow" + filter="url(http://example.org/tests/layout/svg/tests/filters.svg#NonWhiteToBlack)"/> +</svg> diff --git a/layout/svg/tests/file_yellow_black.svg b/layout/svg/tests/file_yellow_black.svg new file mode 100644 index 0000000000..77c14c9af8 --- /dev/null +++ b/layout/svg/tests/file_yellow_black.svg @@ -0,0 +1,9 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + xmlns:xlink="http://www.w3.org/1999/xlink"> + <rect height="100%" width="100%" fill="yellow" /> + <rect y="50px" height="50px" width="100px" fill="black" /> +</svg> diff --git a/layout/svg/tests/filters.svg b/layout/svg/tests/filters.svg new file mode 100644 index 0000000000..213df7fc93 --- /dev/null +++ b/layout/svg/tests/filters.svg @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> + <defs> + + <!-- so that other documents can svg:use this one and force it to + load before onload --> + <g id="empty" /> + + <!-- Keep all white pixels white, and change any others to black. --> + <!-- NOTE: alpha is preserved, so it will not adjust alpha edges --> + <filter id="NonWhiteToBlack" x="0%" y="0%" width="100%" height="100%"> + <feComponentTransfer> + <feFuncR type="linear" slope="-1" intercept="1" /> + <feFuncG type="linear" slope="-1" intercept="1" /> + <feFuncB type="linear" slope="-1" intercept="1" /> + </feComponentTransfer> + <feColorMatrix type="matrix" values="255 255 255 0 0 + 255 255 255 0 0 + 255 255 255 0 0 + 0 0 0 1 0" /> + <feComponentTransfer> + <feFuncR type="linear" slope="-1" intercept="1" /> + <feFuncG type="linear" slope="-1" intercept="1" /> + <feFuncB type="linear" slope="-1" intercept="1" /> + </feComponentTransfer> + </filter> + </defs> +</svg> diff --git a/layout/svg/tests/mochitest.ini b/layout/svg/tests/mochitest.ini new file mode 100644 index 0000000000..3397e849b5 --- /dev/null +++ b/layout/svg/tests/mochitest.ini @@ -0,0 +1,30 @@ +[DEFAULT] +support-files = + file_disabled_iframe.html + file_context_fill_fallback_red.svg + +[test_disabled.html] +[test_embed_sizing.html] +support-files = + file_embed_sizing_none.svg + file_embed_sizing_size.svg + file_embed_sizing_ratio.svg + file_embed_sizing_both.svg +skip-if = + http3 + +[test_filter_crossorigin.html] +support-files = + filters.svg + file_filter_crossorigin.svg + file_black_yellow.svg + file_yellow_black.svg +# Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default" +skip-if = + xorigin + os == "linux" && bits == 64 #Bug 1642198 + win10_2004 && !debug # Bug 1642198 +[test_hover_near_text.html] +[test_multiple_font_size.html] +[test_use_tree_cycle.html] +[test_bug1544209.html] diff --git a/layout/svg/tests/svg_example_script.svg b/layout/svg/tests/svg_example_script.svg new file mode 100644 index 0000000000..5eab758f92 --- /dev/null +++ b/layout/svg/tests/svg_example_script.svg @@ -0,0 +1,7 @@ +<svg version="1.1"> + <script> + document.documentElement.style.backgroundColor = 'rebeccapurple'; + throw "badment, should never fire."; + </script> + <g><circle cx="25.8" cy="9.3" r="1.5"/></g> +</svg> diff --git a/layout/svg/tests/svg_example_test.html b/layout/svg/tests/svg_example_test.html new file mode 100644 index 0000000000..45c31c98b4 --- /dev/null +++ b/layout/svg/tests/svg_example_test.html @@ -0,0 +1,7 @@ +<svg id="layout" viewBox="0 0 120 120" version="1.1" + xmlns="http://www.w3.org/2000/svg"> + <circle cx="60" cy="60" r="50"/> +</svg> + +<svg id="svgel"> +</svg> diff --git a/layout/svg/tests/test_bug1544209.html b/layout/svg/tests/test_bug1544209.html new file mode 100644 index 0000000000..b2226b3ea9 --- /dev/null +++ b/layout/svg/tests/test_bug1544209.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1544209">Mozilla Bug 1544209</a> + +<svg height="800px" width="800px"> + <text transform="scale(3,3)" id="a" x="20px" y="20px">ABC<tspan id="b">ABC</tspan></text> +</svg> + +<script type="application/javascript"> + let a = document.getElementById("a"), + b = document.getElementById("b"); + + let wtext = a.getBoundingClientRect().width, + wtspan = b.getBoundingClientRect().width; + + ok(wtext >= wtspan, "<tspan> should not be wider than <text>"); + isfuzzy((wtext - wtspan) / wtext, 0.5, 0.1, "<tspan> should be approximately half of the <text> width"); +</script> diff --git a/layout/svg/tests/test_context_properties_allowed_domains.html b/layout/svg/tests/test_context_properties_allowed_domains.html new file mode 100644 index 0000000000..26f38a8770 --- /dev/null +++ b/layout/svg/tests/test_context_properties_allowed_domains.html @@ -0,0 +1,95 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Bug 1699892 - SVG context properties for allowed domains</title> +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> +<script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script> +<script> + /** + * Returns a Promise that resolves when target fires a load event. + */ + function waitForLoad(target) { + return new Promise(resolve => { + target.addEventListener("load", () => { + if (event.target == target) { + resolve(); + }}, { once: true }); + }); + } + + function makeContextFillFrame(source) { + return ` + <style> + img { + -moz-context-properties: fill; + fill: green; + } + </style> + <img src="${source}" style="width: 100px; height: 100px;"> + `; + } + + /** + * Creates an iframe, loads src in it, and waits for the load event + * for the iframe to fire. Then it snapshots the iframe and returns + * the snapshot (and removes the iframe from the document, to clean up). + * + * src can be a URL starting with http, or is otherwise assumed to be + * a srcdoc string. + */ + async function loadSrcImageAndSnapshot({ src, srcdoc }) { + let frame = document.createElement("iframe"); + document.body.appendChild(frame); + + if (src) { + frame.src = src; + } else { + frame.srcdoc = srcdoc; + } + + await waitForLoad(frame); + + let snapshot = await snapshotWindow(frame, false); + document.body.removeChild(frame); + return snapshot; + } + + add_task(async () => { + const ALLOWED_DOMAIN = "example.org"; + const DISALLOWED_DOMAIN = "example.com"; + + await SpecialPowers.pushPrefEnv({ + set: [["svg.context-properties.content.allowed-domains", ALLOWED_DOMAIN]] + }); + + // When the context properties are allowed, we expect a green + // square. When they are not allowed, we expected a red square. + + let redReference = await loadSrcImageAndSnapshot({ + srcdoc: `<div style="width: 100px; height: 100px; background: red"></div>`, + }); + + let greenReference = await loadSrcImageAndSnapshot({ + srcdoc: `<div style="width: 100px; height: 100px; background: green"></div>`, + }); + + let allowedSnapshot = await loadSrcImageAndSnapshot({ + src: `file_context_fill_fallback_red.html?${ALLOWED_DOMAIN}` + }); + + let disallowedSnapshot = await loadSrcImageAndSnapshot({ + src: `file_context_fill_fallback_red.html?${DISALLOWED_DOMAIN}` + }); + + const kNoFuzz = null; + info("Reference snapshots should look different from each other"); + assertSnapshots(redReference, greenReference, false, kNoFuzz, "red", "green"); + + info("Allowed domain should be green"); + assertSnapshots(allowedSnapshot, greenReference, true, kNoFuzz, ALLOWED_DOMAIN, "green"); + + info("Disallowed domain should be red"); + assertSnapshots(disallowedSnapshot, redReference, true, kNoFuzz, DISALLOWED_DOMAIN, "red"); + }); +</script> +<body> +</body> diff --git a/layout/svg/tests/test_disabled.html b/layout/svg/tests/test_disabled.html new file mode 100644 index 0000000000..acf52e73a2 --- /dev/null +++ b/layout/svg/tests/test_disabled.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<!-- +Copied from https://bugzilla.mozilla.org/show_bug.cgi?id=744830 +--> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=166235">Mozilla Bug 166235</a> +<iframe></iframe> +<script type="application/javascript"> + SimpleTest.waitForExplicitFinish(); + SpecialPowers.pushPrefEnv({"set": [["svg.disabled", true]]}, function() { + document.querySelector('iframe').src = "file_disabled_iframe.html"; + }); +</script> diff --git a/layout/svg/tests/test_disabled_chrome.html b/layout/svg/tests/test_disabled_chrome.html new file mode 100644 index 0000000000..e7564f17f2 --- /dev/null +++ b/layout/svg/tests/test_disabled_chrome.html @@ -0,0 +1,54 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=744830 +--> +<head> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=166235">Mozilla Bug 166235</a> +<div id="testnodes"><span>hi</span> there <!-- mon ami --></div> +<pre id="test"> +<script type="application/javascript"> + add_task(async function() { + const initialPrefValue = SpecialPowers.getBoolPref("svg.disabled"); + SpecialPowers.setBoolPref("svg.disabled", true); + const Cu = SpecialPowers.Components.utils; + const { ContentTaskUtils } = ChromeUtils.import("resource://testing-common/ContentTaskUtils.jsm"); + let t = document.getElementById('testnodes'); + + let url = 'chrome://mochitests/content/chrome/layout/svg/tests/svg_example_test.html' + const chromeIframeEl = document.createElement('iframe'); + let chromeLoadPromise = ContentTaskUtils.waitForEvent(chromeIframeEl, 'load', false); + chromeIframeEl.src = url; + t.appendChild(chromeIframeEl); + + await chromeLoadPromise; + const chromeBR = chromeIframeEl.contentDocument.body.getBoundingClientRect(); + + url = "http://mochi.test:8888/chrome/layout/svg/tests/svg_example_test.html"; + const iframeEl = document.createElement('iframe'); + iframeEl.src = url; + let loadPromise = ContentTaskUtils.waitForEvent(iframeEl, 'load', false); + t.appendChild(iframeEl); + await loadPromise; + + const contentBR = iframeEl.contentDocument.body.getBoundingClientRect(); + ok(chromeBR.height > contentBR.height, "Chrome content height should be bigger than content due to layout"); + + url = "http://mochi.test:8888/chrome/layout/svg/tests/svg_example_script.svg"; + const iframeElScript = document.createElement("iframe"); + let loadPromiseScript = ContentTaskUtils.waitForEvent(iframeElScript, "load", false); + iframeElScript.src = url; + t.appendChild(iframeElScript); + await loadPromiseScript; + ok(!iframeElScript.contentDocument.documentElement.style, "Content should not be styled"); + + SpecialPowers.setBoolPref("svg.disabled", initialPrefValue); + }); +</script> +</pre> +</body> +</html> diff --git a/layout/svg/tests/test_embed_sizing.html b/layout/svg/tests/test_embed_sizing.html new file mode 100644 index 0000000000..9afbc7ca7d --- /dev/null +++ b/layout/svg/tests/test_embed_sizing.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> + +<p>Test intrinsic sizing of embed elements referencing SVG documents, both same +origin and cross origin.</p> + +<div id="container" style="width: 500px;"></div> + +<script> +const TESTS = [ + { outer: "none", inner: "none", expected: "300x150" }, + { outer: "none", inner: "size", expected: "200x900" }, + { outer: "none", inner: "ratio", expected: "500x2500" }, + { outer: "none", inner: "both", expected: "200x400" }, + { outer: "size", inner: "none", expected: "100x150" }, + { outer: "size", inner: "size", expected: "100x450" }, + { outer: "size", inner: "ratio", expected: "100x500" }, + { outer: "size", inner: "both", expected: "100x200" }, + { outer: "ratio", inner: "none", expected: "500x1500" }, + { outer: "ratio", inner: "size", expected: "200x900" }, + { outer: "ratio", inner: "ratio", expected: "500x1500" }, + { outer: "ratio", inner: "both", expected: "200x400" }, + { outer: "both", inner: "none", expected: "100x300" }, + { outer: "both", inner: "size", expected: "100x300" }, + { outer: "both", inner: "ratio", expected: "100x300" }, + { outer: "both", inner: "both", expected: "100x300" }, +]; + +add_task(async function() { + for (let test of TESTS) { + for (let crossorigin of [false, true]) { + let host = crossorigin ? "http://example.org" : "http://mochi.test:8888"; + let e = document.createElement("embed"); + + switch (test.outer) { + case "none": + break; + case "size": + e.style.width = "100px"; + break; + case "ratio": + e.style.aspectRatio = "1 / 3"; + break; + case "both": + e.style.width = "100px"; + e.style.aspectRatio = "1 / 3"; + break; + default: + throw new Error("unexpected subtest"); + } + + await new Promise(function(resolve) { + e.src = host + location.pathname.replace("test_embed_sizing.html", `file_embed_sizing_${test.inner}.svg`); + e.onload = resolve; + container.append(e); + }); + + let desc = `Subtest (${test.outer}/${test.inner}/${crossorigin ? 'cross' : 'same'} origin)`; + is(`${e.offsetWidth}x${e.offsetHeight}`, test.expected, desc); + e.remove(); + } + } +}); +</script> diff --git a/layout/svg/tests/test_filter_crossorigin.html b/layout/svg/tests/test_filter_crossorigin.html new file mode 100644 index 0000000000..e31c13bee1 --- /dev/null +++ b/layout/svg/tests/test_filter_crossorigin.html @@ -0,0 +1,60 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=695385 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 695385</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/WindowSnapshot.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body onload="run()"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=695385">Mozilla Bug 695385</a> +<br> +<!-- These iframes' renderings are expected to match: --> +<iframe src="http://mochi.test:8888/tests/layout/svg/tests/file_filter_crossorigin.svg"></iframe> +<iframe src="file_black_yellow.svg"></iframe> +<br> +<!-- These iframes' renderings are expected to match: --> +<iframe src="http://example.org/tests/layout/svg/tests/file_filter_crossorigin.svg"></iframe> +<iframe src="file_yellow_black.svg"></iframe> + +<pre id="test"> +<script type="application/javascript"> + +function promiseExecuteSoon() { + return new Promise(SimpleTest.executeSoon); +} + +// Main Function +async function run() { + SimpleTest.waitForExplicitFinish(); + + // XXXdholbert Wait a few ticks, to give the iframes a little more + // opportunity to load their external resources before we call + // snapshotWindow. This is an attempt at a workaround/diagnostic for + // https://bugzilla.mozilla.org/show_bug.cgi?id=1706542 + for (let i = 0; i < 60; i++) { + await promiseExecuteSoon(); + } + + let snapshots = new Array(4); + for (let i = 0; i < snapshots.length; i++) { + snapshots[i] = await snapshotWindow(frames[i], false); + } + + // Compare mochi.test iframe against its reference: + assertSnapshots(snapshots[0], snapshots[1], true, null, + "Testcase loaded from mochi.test", "Reference: black/yellow"); + + // Compare example.org iframe against its reference: + assertSnapshots(snapshots[2], snapshots[3], true, null, + "Testcase loaded from example.org", "Reference: yellow/black"); + SimpleTest.finish(); +} +</script> +</pre> +</body> +</html> diff --git a/layout/svg/tests/test_hover_near_text.html b/layout/svg/tests/test_hover_near_text.html new file mode 100644 index 0000000000..2bf808e61a --- /dev/null +++ b/layout/svg/tests/test_hover_near_text.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/> + <title>Test mouse hover near text element inside svg element with viewBox attribute</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + </head> + <body style="margin:0"> + <div> + <svg viewBox="-1 -1 2 2" width="300" height="300"> + <text style="font-size:0.1px" onmouseover="this.setAttribute('fill', 'red')">Hi</text> + </svg> + </div> + <p> + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1519144">Mozilla Bug 1519144</a> + </p> + <script type="application/javascript"> + let utils = SpecialPowers.getDOMWindowUtils(window); + utils.sendMouseEvent('mousemove', 155, 125, 0, 0, 0); //hover above the text + utils.sendMouseEvent('mousemove', 125, 155, 0, 0, 0); //hover to the left of the text + requestIdleCallback(() => { + ok(!document.getElementsByTagName('text')[0].hasAttribute('fill'), + 'Text element should not receive an event'); + SimpleTest.finish(); + }); + SimpleTest.waitForExplicitFinish() + </script> + </body> +</html> diff --git a/layout/svg/tests/test_multiple_font_size.html b/layout/svg/tests/test_multiple_font_size.html new file mode 100644 index 0000000000..aca32eac03 --- /dev/null +++ b/layout/svg/tests/test_multiple_font_size.html @@ -0,0 +1,25 @@ +<!DOCTYPE HTML> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1370646">Mozilla Bug 1370646</a> + +<svg xmlns="http://www.w3.org/2000/svg" width="440" height="100" viewBox="0 0 440 100"> + <text> + <tspan id="a" style="font-size:100px">3</tspan> + </text> + <text> + <tspan id="b" style="font-size:100px">3</tspan> + <tspan style="font-size:0.1px">0</tspan> + </text> +</svg> + +<script type="application/javascript"> + SimpleTest.waitForExplicitFinish(); + + let alen = document.getElementById("a").getComputedTextLength(), + blen = document.getElementById("b").getComputedTextLength(); + + SimpleTest.isfuzzy(alen, blen, 5, "lengths should be close"); + + SimpleTest.finish(); +</script> diff --git a/layout/svg/tests/test_use_tree_cycle.html b/layout/svg/tests/test_use_tree_cycle.html new file mode 100644 index 0000000000..e820f0f2a2 --- /dev/null +++ b/layout/svg/tests/test_use_tree_cycle.html @@ -0,0 +1,37 @@ +<!doctype html> +<title>Test for bug 1531333</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<style> + symbol { display: block } +</style> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10"> + <symbol id="svg-sprite" viewBox="0 0 133 230866"> + <title>svg-sprite</title> + <symbol id="svg-sprite" viewBox="0 0 133 230866"> + <title>svg-sprite</title> + <use xlink:href="#svg-sprite" width="500" height="500" /> + </symbol> + <use xlink:href="#svg-sprite" y="1601" width="133" height="228958" /> + </symbol> + <use xlink:href="#svg-sprite" y="1601" width="133" height="230866" /> +</svg> +<script> +function countUseElements(subtreeRoot) { + if (!subtreeRoot) + return 0; + + let i = 0; + for (const use of subtreeRoot.querySelectorAll("use")) + i += 1 + countUseElements(SpecialPowers.wrap(use).openOrClosedShadowRoot); + return i; +} +SimpleTest.waitForExplicitFinish(); +onload = function() { + document.body.offsetTop; + // The three in the document, plus the two created from the element that's + // not in the <symbol> subtree. + is(countUseElements(document), 5, "Shouldn't create more than 5 use elements"); + SimpleTest.finish(); +} +</script> |