Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/rendering/replaced-elements/svg-inline-sizing/svg-inline.js

Issue 1157863007: W3C Test: import web-platform-tests/html/rendering (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-run update-w3c-deps Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // global async_test, assert_equals
2 //
3 // This test generates a couple of scenarios (each a
4 // SVGSizing.TestData) for sizing inline <svg> and uses a simple
5 // JavaScript sizing implementation for comparison.
6 //
7 // The tests loops through different combinations of:
8 //
9 // * width and height attributes and style on <svg>
10 //
11 // * viewBox on <svg> (gives intrinsic ratio)
12 //
13 // * width and height on containing block of <svg>
14 //
15 // All these may contribute to the final size of the SVG. The test
16 // focuses on the size of the CSS box generated by the SVG. Little
17 // focus is put on variations within an attribute that doesn't affect
18 // the final size.
19 //
20 // To debug a specific test append ?<test-id> to the URL. An <iframe>
21 // is generated with equivalent test and the source of the test is
22 // added to a <pre> element.
23
24 var debugHint = function(id) { return "(append ?"+id+" to debug) "; };
25 var testSingleId;
26 if (window.location.search) {
27 testSingleId = window.location.search.substring(1);
28 debugHint = function(id) { return ""; };
29 }
30
31 var testContainer = document.querySelector('#testContainer');
32 var outerWidth = testContainer.getBoundingClientRect().width;
33 var outerHeight = testContainer.getBoundingClientRect().height;
34
35 SVGSizing.doCombinationTest(
36 [["placeholder", [ null ]],
37 ["containerWidthStyle", [null, "400px"]],
38 ["containerHeightStyle", [null, "400px"]],
39 ["svgViewBoxAttr", [ null, "0 0 100 200" ]],
40 ["svgWidthStyle", [ null, "100px", "50%" ]],
41 ["svgHeightStyle", [ null, "100px", "50%" ]],
42 ["svgWidthAttr", [ null, "200", "25%" ]],
43 ["svgHeightAttr", [ null, "200", "25%" ]]],
44 function(config, id, cont) {
45 var testData = new SVGSizing.TestData(config);
46
47 var expectedRect =
48 testData.computeInlineReplacedSize(outerWidth, outerHeight);
49 var svgElement = testData.buildSVGOrPlaceholder();
50 var container =
51 testData.buildContainer(svgElement);
52
53 var checkSize = function() {
54 var svgRect =
55 svgElement.getBoundingClientRect();
56
57 try {
58 assert_equals(svgRect.width,
59 expectedRect.width,
60 debugHint(id) + "Wrong width");
61 assert_equals(svgRect.height,
62 expectedRect.height,
63 debugHint(id) + "Wrong height");
64 } finally {
65 testContainer.removeChild(container);
66 if (testSingleId)
67 document.body.removeChild(testContainer);
68 cont(id+1);
69 }
70 };
71
72 testContainer.appendChild(container);
73 test(checkSize, testData.name);
74
75 if (testSingleId == id) {
76 testData.buildDemo(expectedRect, id);
77 }
78 }, testSingleId);
OLDNEW
« no previous file with comments | « LayoutTests/imported/web-platform-tests/html/rendering/replaced-elements/svg-inline-sizing/svg-inline.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698