Load the layout test result image diff HTML from a file, rather than having it inline...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Aug 2014 00:23:38 +0000 (00:23 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Aug 2014 00:23:38 +0000 (00:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135780

Reviewed by Dan Bates.

Tools:

Pull the HTML for the image diff file into a separate file, for easier hackability.

* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter.write_image_diff_files):

LayoutTests:

Add image-diff-template.html and expected result (crazy, but this is what we do
for results.html too).

* fast/harness/image-diff-template-expected.txt: Added.
* fast/harness/image-diff-template.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172368 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/harness/image-diff-template-expected.txt [new file with mode: 0644]
LayoutTests/fast/harness/image-diff-template.html [new file with mode: 0644]
Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py

index 984ab41e8ac9d8b97b4bb4147eeea08d638f6710..617d931424d262f0d3bfdbb05ef4e3a0b7278530 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-08  Simon Fraser  <simon.fraser@apple.com>
+
+        Load the layout test result image diff HTML from a file, rather than having it inline in webkitpy
+        https://bugs.webkit.org/show_bug.cgi?id=135780
+
+        Reviewed by Dan Bates.
+        
+        Add image-diff-template.html and expected result (crazy, but this is what we do
+        for results.html too).
+
+        * fast/harness/image-diff-template-expected.txt: Added.
+        * fast/harness/image-diff-template.html: Added.
+
 2014-08-08  Simon Fraser  <simon.fraser@apple.com>
 
         [WK2] Scrolling does not work inside nested frames
diff --git a/LayoutTests/fast/harness/image-diff-template-expected.txt b/LayoutTests/fast/harness/image-diff-template-expected.txt
new file mode 100644 (file)
index 0000000..82699b3
--- /dev/null
@@ -0,0 +1,2 @@
+Difference between images: diff
+Loading...
diff --git a/LayoutTests/fast/harness/image-diff-template.html b/LayoutTests/fast/harness/image-diff-template.html
new file mode 100644 (file)
index 0000000..e3422af
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>%(title)s</title>
+<style>
+    .label {
+        font-weight: bold;
+    }
+</style>
+</head>
+<body>
+Difference between images: <a href="%(diff_filename)s">diff</a><br>
+<div class="imageText"></div>
+<div class="imageContainer" data-prefix="%(prefix)s">Loading...</div>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+(function() {
+    var preloadedImageCount = 0;
+
+    function preloadComplete()
+    {
+        ++preloadedImageCount;
+        if (preloadedImageCount < 2)
+            return;
+        toggleImages();
+        setInterval(toggleImages, 2000)
+    }
+
+    function preloadImage(url)
+    {
+        image = new Image();
+        image.addEventListener('load', preloadComplete);
+        image.src = url;
+        return image;
+    }
+
+    function toggleImages()
+    {
+        if (text.textContent == 'Expected Image') {
+            text.textContent = 'Actual Image';
+            container.replaceChild(actualImage, container.firstChild);
+        } else {
+            text.textContent = 'Expected Image';
+            container.replaceChild(expectedImage, container.firstChild);
+        }
+    }
+
+    var text = document.querySelector('.imageText');
+    var container = document.querySelector('.imageContainer');
+    var actualImage = preloadImage(container.getAttribute('data-prefix') + '-actual.png');
+    var expectedImage = preloadImage(container.getAttribute('data-prefix') + '-expected.png');
+})();
+</script>
+</body>
+</html>
index 20bd04d4a8628f775b43a7cc9130d14b52fc636f..00a67a8d6ad14710ee716701b3d892c50da14725 100644 (file)
@@ -1,3 +1,15 @@
+2014-08-08  Simon Fraser  <simon.fraser@apple.com>
+
+        Load the layout test result image diff HTML from a file, rather than having it inline in webkitpy
+        https://bugs.webkit.org/show_bug.cgi?id=135780
+
+        Reviewed by Dan Bates.
+        
+        Pull the HTML for the image diff file into a separate file, for easier hackability.
+
+        * Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
+        (TestResultWriter.write_image_diff_files):
+
 2014-08-08  Mark Lam  <mark.lam@apple.com>
 
         Gardening: fix Windows build after r172259.
index 932b22e57fd028d7d3342a9b40decb8fc71321c0..b444defed04d6a7f5a493d20cea83f6c6e1435d2 100644 (file)
@@ -168,60 +168,18 @@ class TestResultWriter(object):
         diff_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFF)
         self._write_binary_file(diff_filename, image_diff)
 
-        diffs_html_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFFS_HTML)
+        base_dir = self._port.path_from_webkit_base('LayoutTests', 'fast', 'harness')
+        image_diff_file = self._filesystem.read_text_file(self._filesystem.join(base_dir, 'image-diff-template.html'))
+
         # FIXME: old-run-webkit-tests shows the diff percentage as the text contents of the "diff" link.
         # FIXME: old-run-webkit-tests include a link to the test file.
-        html = """<!DOCTYPE HTML>
-<html>
-<head>
-<title>%(title)s</title>
-<style>.label{font-weight:bold}</style>
-</head>
-<body>
-Difference between images: <a href="%(diff_filename)s">diff</a><br>
-<div class=imageText></div>
-<div class=imageContainer data-prefix="%(prefix)s">Loading...</div>
-<script>
-(function() {
-    var preloadedImageCount = 0;
-    function preloadComplete() {
-        ++preloadedImageCount;
-        if (preloadedImageCount < 2)
-            return;
-        toggleImages();
-        setInterval(toggleImages, 2000)
-    }
-
-    function preloadImage(url) {
-        image = new Image();
-        image.addEventListener('load', preloadComplete);
-        image.src = url;
-        return image;
-    }
-
-    function toggleImages() {
-        if (text.textContent == 'Expected Image') {
-            text.textContent = 'Actual Image';
-            container.replaceChild(actualImage, container.firstChild);
-        } else {
-            text.textContent = 'Expected Image';
-            container.replaceChild(expectedImage, container.firstChild);
-        }
-    }
-
-    var text = document.querySelector('.imageText');
-    var container = document.querySelector('.imageContainer');
-    var actualImage = preloadImage(container.getAttribute('data-prefix') + '-actual.png');
-    var expectedImage = preloadImage(container.getAttribute('data-prefix') + '-expected.png');
-})();
-</script>
-</body>
-</html>
-""" % {
+        html = image_diff_file % {
             'title': self._test_name,
             'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DIFF),
             'prefix': self._output_testname(''),
         }
+
+        diffs_html_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFFS_HTML)
         self._filesystem.write_text_file(diffs_html_filename, html)
 
     def write_reftest(self, src_filepath):