From 6062b6e73528fd2dede6cd06d06e8469465623f7 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Tue, 25 Nov 2014 16:46:15 -0800 Subject: [PATCH] Bug 1098417 part 4: Add reftests for anchor-point handling, with SVG images & a range of "object-position" values. (no review) --HG-- rename : layout/reftests/w3c-css/submitted/images3/support/generate-object-position-png-tests.sh => layout/reftests/w3c-css/submitted/images3/support/generate-object-position-svg-tests.sh --- .../images3/object-position-svg-001-ref.html | 42 +++++++++ .../images3/object-position-svg-001e.html | 44 ++++++++++ .../images3/object-position-svg-001i.html | 44 ++++++++++ .../images3/object-position-svg-001o.html | 44 ++++++++++ .../images3/object-position-svg-001p.html | 44 ++++++++++ .../images3/object-position-svg-002-ref.html | 42 +++++++++ .../images3/object-position-svg-002e.html | 44 ++++++++++ .../images3/object-position-svg-002i.html | 44 ++++++++++ .../images3/object-position-svg-002o.html | 44 ++++++++++ .../images3/object-position-svg-002p.html | 44 ++++++++++ .../w3c-css/submitted/images3/reftest.list | 8 ++ .../generate-object-position-svg-tests.sh | 88 +++++++++++++++++++ 12 files changed, 532 insertions(+) create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-001-ref.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-001e.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-001i.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-001o.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-001p.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-002-ref.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-002e.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-002i.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-002o.html create mode 100644 layout/reftests/w3c-css/submitted/images3/object-position-svg-002p.html create mode 100644 layout/reftests/w3c-css/submitted/images3/support/generate-object-position-svg-tests.sh diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-001-ref.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001-ref.html new file mode 100644 index 00000000000..61c386d88f6 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001-ref.html @@ -0,0 +1,42 @@ + + + + + + CSS Reftest Reference + + + + +
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-001e.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001e.html new file mode 100644 index 00000000000..05f226cd887 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001e.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size embed element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-001i.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001i.html new file mode 100644 index 00000000000..eecf0f4330c --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001i.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size img element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-001o.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001o.html new file mode 100644 index 00000000000..589999c91f1 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001o.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size object element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-001p.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001p.html new file mode 100644 index 00000000000..8b0b468b2fd --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-001p.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size video element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-002-ref.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002-ref.html new file mode 100644 index 00000000000..d75e5edb7cb --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002-ref.html @@ -0,0 +1,42 @@ + + + + + + CSS Reftest Reference + + + + +
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-002e.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002e.html new file mode 100644 index 00000000000..0bde50d0ca6 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002e.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size embed element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-002i.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002i.html new file mode 100644 index 00000000000..202b171c3a5 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002i.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size img element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-002o.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002o.html new file mode 100644 index 00000000000..e05938167c4 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002o.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size object element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/object-position-svg-002p.html b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002p.html new file mode 100644 index 00000000000..3c6b7a3d400 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/object-position-svg-002p.html @@ -0,0 +1,44 @@ + + + + + + CSS Test: various 'object-position' values on a fixed-size video element, with a SVG image and 'object-fit:contain'. + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/w3c-css/submitted/images3/reftest.list b/layout/reftests/w3c-css/submitted/images3/reftest.list index 3fc4b2440e5..44fe371b31d 100644 --- a/layout/reftests/w3c-css/submitted/images3/reftest.list +++ b/layout/reftests/w3c-css/submitted/images3/reftest.list @@ -170,3 +170,11 @@ fails == object-fit-fill-svg-006p.html object-fit-fill-svg-006-ref.html # bug 10 == object-position-png-002i.html object-position-png-002-ref.html == object-position-png-002o.html object-position-png-002-ref.html == object-position-png-002p.html object-position-png-002-ref.html +fails == object-position-svg-001e.html object-position-svg-001-ref.html # bug 1103286 +== object-position-svg-001i.html object-position-svg-001-ref.html +fails == object-position-svg-001o.html object-position-svg-001-ref.html # bug 1103286 +== object-position-svg-001p.html object-position-svg-001-ref.html +fails == object-position-svg-002e.html object-position-svg-002-ref.html # bug 1103286 +== object-position-svg-002i.html object-position-svg-002-ref.html +fails == object-position-svg-002o.html object-position-svg-002-ref.html # bug 1103286 +== object-position-svg-002p.html object-position-svg-002-ref.html diff --git a/layout/reftests/w3c-css/submitted/images3/support/generate-object-position-svg-tests.sh b/layout/reftests/w3c-css/submitted/images3/support/generate-object-position-svg-tests.sh new file mode 100644 index 00000000000..e00385a4748 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/images3/support/generate-object-position-svg-tests.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ +# +# This is a script that I used to generate a suite of tests for the CSS +# properties "object-fit" and "object-position" (focusing on edge-case +# object-position values that require pixel rounding), using a template +# testcase file and reference case file. +# +# The reference case uses the "background-size" & "background-position" +# equivalent of the tested "object-fit" / "object-position" values. + +FILE_PATH="./" +REFTEST_LIST_FILE="$FILE_PATH/reftest.list" + +TEMPLATE_TESTCASE_FILENAME=$FILE_PATH/support/template-object-position-test.html +TEMPLATE_REFERENCE_FILENAME=$FILE_PATH/support/template-object-position-ref.html + +imageFileFormat="svg" + +# Array of image files to use for testing: +imageFileArr=("support/colors-16x8.svg" "support/colors-8x16.svg") +numImageFiles=${#imageFileArr[@]} + +# Array of CSS classes to delete from the template, for a given image-file. +# DETAILS: The template files contain some elements/styles that exercise +# object-position x-values (op_x), and other elements/styles that exercise +# object-position y-values (op_y). But actually, we'll only have extra space +# for these percent values to resolve against in *one* dimension (since our +# image-files are rectangular, and the container element is square, and we +# scale the image up with "object-fit: contain"). So, we delete the +# elements/styles in the dimension where object-position % values will just +# resolve to 0 ("op_x" for the fat image, and "op_y" for the tall image). +classPatternToDeleteArr=("op_x" "op_y") + +# Array of tag-names for elements that we'd like to test: +# (Also: array of a single-letter abbreviation for each element, an array of +# the close tag for each element -- if a close tag is needed -- and an array +# indicating the attribute that each element uses to specify its image source.) +tagNameArr=( "embed" "img" "object" "video" ) +tagLetterArr=( "e" "i" "o" "p" ) +tagCloseTokenArr=( "" "" "" "" ) +tagSrcAttrArr=( "src" "src" "data" "poster" ) +numTags=${#tagNameArr[@]} + + for ((j = 0; j < $numImageFiles; j++)); do + imageFile=${imageFileArr[$j]} + + classPatternToDelete=${classPatternToDeleteArr[$j]} + + let testNum=$j+1 + testNum="00$testNum" # zero-pad to 3 digits, per w3c convention + + filenameStub="object-position-$imageFileFormat-$testNum" + + # Generate a reference case: + filenameRef="$filenameStub-ref.html" + echo Generating ${filenameRef}. + cat $TEMPLATE_REFERENCE_FILENAME \ + | sed "s,REPLACEME_IMAGE_FILENAME,$imageFile," \ + | sed "/$classPatternToDelete/d" \ + > $FILE_PATH/$filenameRef + + # Generate a test for each of our tags: + for ((k = 0; k < $numTags; k++)); do + tagName=${tagNameArr[$k]} + tagLetter=${tagLetterArr[$k]} + tagCloseToken=${tagCloseTokenArr[$k]} + tagSrcAttr=${tagSrcAttrArr[$k]} + + filenameTest="$filenameStub$tagLetter.html" + testTitle="various 'object-position' values on a fixed-size $tagName element, with a SVG image and 'object-fit:contain'." + echo Generating ${filenameTest}. + cat $TEMPLATE_TESTCASE_FILENAME \ + | sed "s,REPLACEME_IMAGE_FILENAME,$imageFile," \ + | sed "s/REPLACEME_TEST_TITLE/$testTitle/" \ + | sed "s,REPLACEME_REFERENCE_FILENAME,$filenameRef," \ + | sed "s/REPLACEME_CONTAINER_TAG/$tagName/" \ + | sed "s,REPLACEME_CONTAINER_CLOSETAG,$tagCloseToken," \ + | sed "s/REPLACEME_SRC_ATTR/$tagSrcAttr/" \ + | sed "/$classPatternToDelete/d" \ + > $FILE_PATH/$filenameTest + + echo "== $filenameTest $filenameRef" \ + >> $REFTEST_LIST_FILE + done + done