tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

generate-object-position-xul-tests.sh (2813B)


      1 #!/bin/bash
      2 #
      3 # Any copyright is dedicated to the Public Domain.
      4 # http://creativecommons.org/publicdomain/zero/1.0/
      5 #
      6 # Script to generate XUL <image> reftest files, from corresponding reftest
      7 # files that use <img>.
      8 #
      9 # This script expects to be run from this working directory:
     10 #  mozilla-central/layout/reftests/w3c-css/submitted/images3
     11 # and it expects to be run *after* generate-object-fit-xul-tests.sh, since the
     12 # copied test files will make use of image resources which are copied by that
     13 # other script.
     14 
     15 XUL_REFTEST_PATH="../../../xul"
     16 
     17 reftestListFileName="$XUL_REFTEST_PATH/reftest.list"
     18 
     19 # Loop across all object-position tests that use <img> ("i" suffix):
     20 for origTestName in object-position-png-*i.html; do
     21  newTestName=$(echo $origTestName |
     22                sed "s/i.html/.xul/")
     23 
     24  # Find the corresponding reference case:
     25  referenceName=$(echo $origTestName |
     26                  sed "s/i.html/-ref.html/")
     27 
     28  # Generate reference file (dropping "support" subdir from image paths):
     29  echo "Copying $referenceName to $XUL_REFTEST_PATH."
     30  newReferenceFullPath=$XUL_REFTEST_PATH/$referenceName
     31  hg cp $referenceName $newReferenceFullPath
     32  sed -i "s,support/,," $newReferenceFullPath
     33 
     34  # Generate testcase
     35  # (converting <video poster="support/foo.png"> to <video src="foo.webm">):
     36  echo "Generating $newTestName from $origTestName."
     37  newTestFullPath=$XUL_REFTEST_PATH/$newTestName
     38  hg cp $origTestName $newTestFullPath
     39 
     40  # Replace doctype with XML decl:
     41  sed -i "s/<!DOCTYPE html>/<?xml version=\"1.0\"?>/" $newTestFullPath
     42 
     43  # Replace html tags with window tags:
     44  sed -i "s,<html>,<window xmlns=\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\">," $newTestFullPath
     45 
     46  # Delete a bunch of HTML (not XUL) / W3C-testsuite boilerplate:
     47  sed -i "/head>/d" $newTestFullPath # Delete head open & close tags
     48  sed -i "/body>/d" $newTestFullPath # Delete body open & close tags
     49  sed -i "/<meta/d" $newTestFullPath # Delete meta charset tag
     50  sed -i "/<title/d" $newTestFullPath # Delete title line
     51  sed -i "/<link/d" $newTestFullPath # Delete link tags
     52 
     53  # Fix style open/close tags, and add 8px of padding on outer <window> to
     54  # match our HTML reference case, and change style rule to target <image>.
     55  # Also, add <hbox> to wrap the image elements.
     56  sed -i "s,  <style type=\"text/css\">,\<style xmlns=\"http://www.w3.org/1999/xhtml\"><![CDATA[\n      window { padding: 8px; }," $newTestFullPath
     57  sed -i "s,  </style>,]]></style>\n  <hbox>," $newTestFullPath
     58  sed -i "s,</html>,  </hbox>\n</window>," $newTestFullPath
     59  sed -i "s/img {/image {/" $newTestFullPath
     60 
     61  sed -i "s,support/,," $newTestFullPath
     62  sed -i "s,<img\(.*\)>,<image\1/>," $newTestFullPath
     63 
     64  # Update reftest manifest:
     65  echo "== $newTestName $referenceName" \
     66    >> $reftestListFileName
     67 
     68 done