Title: [90081] trunk/Tools
Revision
90081
Author
[email protected]
Date
2011-06-29 19:30:02 -0700 (Wed, 29 Jun 2011)

Log Message

2011-06-29  Adam Barth  <[email protected]>

        Reviewed by Eric Seidel.

        new-run-webkit-tests: images page switch actual and expected images before they're loaded
        https://bugs.webkit.org/show_bug.cgi?id=63199

        We now preload the images and keep the DOM nodes in memory instead of
        going back to the MemoryCache all the time.  (Also, remove some nutty
        </img> HTML.)

        * Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (90080 => 90081)


--- trunk/Tools/ChangeLog	2011-06-30 02:06:39 UTC (rev 90080)
+++ trunk/Tools/ChangeLog	2011-06-30 02:30:02 UTC (rev 90081)
@@ -2,6 +2,19 @@
 
         Reviewed by Eric Seidel.
 
+        new-run-webkit-tests: images page switch actual and expected images before they're loaded
+        https://bugs.webkit.org/show_bug.cgi?id=63199
+
+        We now preload the images and keep the DOM nodes in memory instead of
+        going back to the MemoryCache all the time.  (Also, remove some nutty
+        </img> HTML.)
+
+        * Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py:
+
+2011-06-29  Adam Barth  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
         new-run-webkit-tests should tell you when it creates new expectations
         https://bugs.webkit.org/show_bug.cgi?id=63675
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py (90080 => 90081)


--- trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py	2011-06-30 02:06:39 UTC (rev 90080)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py	2011-06-30 02:30:02 UTC (rev 90081)
@@ -232,26 +232,52 @@
         diffs_html_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFFS_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><title>%(title)s</title>
+        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><img class=animatedImage data-prefix="%(prefix)s"></img>;
+<div class=imageText></div>
+<div class=imageContainer data-prefix="%(prefix)s">Loading...</div>
 <script>
-    function toggleImages()
-    {
-        var image = document.querySelector('.animatedImage');
-        var text = document.querySelector('.imageText');
+(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';
-            image.src = "" + '-actual.png';
+            container.replaceChild(actualImage, container.firstChild);
         } else {
             text.textContent = 'Expected Image';
-            image.src = "" + '-expected.png';
+            container.replaceChild(expectedImage, container.firstChild);
         }
     }
-    toggleImages();
-    setInterval(toggleImages, 2000)
+
+    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>
 """ % { 'title': self._testname, 'diff_filename': self._output_testname('-diff.png'), 'prefix': self._output_testname('') }
         self._port._filesystem.write_binary_file(diffs_html_filename, html)
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to