diff --git a/firefox.spec b/firefox.spec
index c6ee5f7..857aa37 100644
--- a/firefox.spec
+++ b/firefox.spec
@@ -201,11 +201,12 @@ Source34: firefox-search-provider.ini
Source35: google-loc-api-key
Source37: mochitest-python.tar.gz
Source38: print_results
-Source39: perrors
+Source39: print-errors
Source40: run-tests-x11
Source41: run-tests-wayland
Source42: psummary
Source43: print_failures
+Source44: print-error-reftest
# Build patches
Patch3: mozilla-build-arm.patch
@@ -792,7 +793,7 @@ find-links=`pwd`/mochitest-python
no-index=true
EOF
tar xf %{SOURCE37}
-cp %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE38} %{SOURCE39} %{SOURCE43} .
+cp %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE38} %{SOURCE39} %{SOURCE43} %{SOURCE44} .
mkdir -p test_results
%if %{test_on_wayland}
./run-tests-wayland %{test_offscreen} || true
diff --git a/print-error-reftest b/print-error-reftest
new file mode 100755
index 0000000..7a58c1c
--- /dev/null
+++ b/print-error-reftest
@@ -0,0 +1,13 @@
+#!/usr/bin/bash
+# Print reftest failures and compose them to html
+
+TEST_DIR="$1"
+TEST_FLAVOUR="$2"
+OUTPUT_FILE="failures-reftest$TEST_FLAVOUR.html"
+
+grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" -e "IMAGE 1 (TEST):" -e "IMAGE 2 (REFERENCE):" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > $OUTPUT_FILE
+sed -i '/REFTEST IMAGE 1/a ">' $OUTPUT_FILE
+sed -i '/REFTEST IMAGE 2/a ">
' $OUTPUT_FILE
+sed -i '/REFTEST TEST/a
' $OUTPUT_FILE
+sed -i -e 's/^REFTEST IMAGE 1 (TEST): /&1 > failures-mochitest$TEST_FLAVOUR
grep --text " FAIL " $TEST_DIR/xpcshell$TEST_FLAVOUR 2>&1 > failures-xpcshell$TEST_FLAVOUR
-grep --text "REFTEST TEST-UNEXPECTED-FAIL" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > failures-reftest$TEST_FLAVOUR
+grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > failures-reftest$TEST_FLAVOUR
diff --git a/print_failures b/print_failures
index 3827601..e3b8b63 100755
--- a/print_failures
+++ b/print_failures
@@ -3,5 +3,7 @@
export TEST_DIR="test_results"
-./perrors $TEST_DIR ""
-./perrors $TEST_DIR "-wr"
+./print-errors $TEST_DIR ""
+./print-errors $TEST_DIR "-wr"
+./print-error-reftest $TEST_DIR ""
+./print-error-reftest $TEST_DIR "-wr"