Backed out changeset 2960ea3e50ca (bug 1881157) for causing crashtest assertion failu...
[gecko.git] / layout / svg / tests / test_embed_sizing.html
blob9afbc7ca7d38b709b7c569e9b9d100e304ac0435
1 <!DOCTYPE html>
2 <script src="/tests/SimpleTest/SimpleTest.js"></script>
3 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
5 <p>Test intrinsic sizing of embed elements referencing SVG documents, both same
6 origin and cross origin.</p>
8 <div id="container" style="width: 500px;"></div>
10 <script>
11 const TESTS = [
12 { outer: "none", inner: "none", expected: "300x150" },
13 { outer: "none", inner: "size", expected: "200x900" },
14 { outer: "none", inner: "ratio", expected: "500x2500" },
15 { outer: "none", inner: "both", expected: "200x400" },
16 { outer: "size", inner: "none", expected: "100x150" },
17 { outer: "size", inner: "size", expected: "100x450" },
18 { outer: "size", inner: "ratio", expected: "100x500" },
19 { outer: "size", inner: "both", expected: "100x200" },
20 { outer: "ratio", inner: "none", expected: "500x1500" },
21 { outer: "ratio", inner: "size", expected: "200x900" },
22 { outer: "ratio", inner: "ratio", expected: "500x1500" },
23 { outer: "ratio", inner: "both", expected: "200x400" },
24 { outer: "both", inner: "none", expected: "100x300" },
25 { outer: "both", inner: "size", expected: "100x300" },
26 { outer: "both", inner: "ratio", expected: "100x300" },
27 { outer: "both", inner: "both", expected: "100x300" },
30 add_task(async function() {
31 for (let test of TESTS) {
32 for (let crossorigin of [false, true]) {
33 let host = crossorigin ? "http://example.org" : "http://mochi.test:8888";
34 let e = document.createElement("embed");
36 switch (test.outer) {
37 case "none":
38 break;
39 case "size":
40 e.style.width = "100px";
41 break;
42 case "ratio":
43 e.style.aspectRatio = "1 / 3";
44 break;
45 case "both":
46 e.style.width = "100px";
47 e.style.aspectRatio = "1 / 3";
48 break;
49 default:
50 throw new Error("unexpected subtest");
53 await new Promise(function(resolve) {
54 e.src = host + location.pathname.replace("test_embed_sizing.html", `file_embed_sizing_${test.inner}.svg`);
55 e.onload = resolve;
56 container.append(e);
57 });
59 let desc = `Subtest (${test.outer}/${test.inner}/${crossorigin ? 'cross' : 'same'} origin)`;
60 is(`${e.offsetWidth}x${e.offsetHeight}`, test.expected, desc);
61 e.remove();
64 });
65 </script>