Title: [172368] trunk
Revision
172368
Author
[email protected]
Date
2014-08-08 17:23:38 -0700 (Fri, 08 Aug 2014)

Log Message

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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172367 => 172368)


--- trunk/LayoutTests/ChangeLog	2014-08-09 00:00:04 UTC (rev 172367)
+++ trunk/LayoutTests/ChangeLog	2014-08-09 00:23:38 UTC (rev 172368)
@@ -1,5 +1,18 @@
 2014-08-08  Simon Fraser  <[email protected]>
 
+        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  <[email protected]>
+
         [WK2] Scrolling does not work inside nested frames
         https://bugs.webkit.org/show_bug.cgi?id=135775
         <rdar://problem/17959896>

Added: trunk/LayoutTests/fast/harness/image-diff-template-expected.txt (0 => 172368)


--- trunk/LayoutTests/fast/harness/image-diff-template-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/image-diff-template-expected.txt	2014-08-09 00:23:38 UTC (rev 172368)
@@ -0,0 +1,2 @@
+Difference between images: diff
+Loading...

Added: trunk/LayoutTests/fast/harness/image-diff-template.html (0 => 172368)


--- trunk/LayoutTests/fast/harness/image-diff-template.html	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/image-diff-template.html	2014-08-09 00:23:38 UTC (rev 172368)
@@ -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=""
+<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 = ""
+        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>

Modified: trunk/Tools/ChangeLog (172367 => 172368)


--- trunk/Tools/ChangeLog	2014-08-09 00:00:04 UTC (rev 172367)
+++ trunk/Tools/ChangeLog	2014-08-09 00:23:38 UTC (rev 172368)
@@ -1,3 +1,15 @@
+2014-08-08  Simon Fraser  <[email protected]>
+
+        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  <[email protected]>
 
         Gardening: fix Windows build after r172259.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py (172367 => 172368)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py	2014-08-09 00:00:04 UTC (rev 172367)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py	2014-08-09 00:23:38 UTC (rev 172368)
@@ -168,60 +168,18 @@
         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=""
-<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 = ""
-        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):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to