Title: [153625] trunk/LayoutTests
Revision
153625
Author
[email protected]
Date
2013-08-01 17:01:21 -0700 (Thu, 01 Aug 2013)

Log Message

Minor cleanup for srcset tests
https://bugs.webkit.org/show_bug.cgi?id=119407

Reviewed by Tim Horton.

Other than small typos and style tweaks, there are three
main changes here:

1. Collect duplicated code into a helper file.
2. Make sure the tests that add or remove the attributes
can run standalone outside of DRT.
3. Update the -simple test with new images that make it
more clear what srcset is doing.

* fast/hidpi/image-srcset-change-dynamically-from-js.html:
* fast/hidpi/image-srcset-invalid-inputs-correct-src.html:
* fast/hidpi/image-srcset-invalid-inputs-except-one.html:
* fast/hidpi/image-srcset-invalid-inputs.html:
* fast/hidpi/image-srcset-only-src-attribute.html:
* fast/hidpi/image-srcset-remove-dynamically-from-js.html:
* fast/hidpi/image-srcset-same-alternative-for-both-attributes.html:
* fast/hidpi/image-srcset-simple.html:
* fast/hidpi/image-srcset-src-selection.html:
* fast/hidpi/resources/image-set-1x.png: Added.
* fast/hidpi/resources/image-set-2x.png: Added.
* fast/hidpi/resources/srcset-helper.js: Added.
* platform/mac/fast/hidpi/image-srcset-simple-expected.png:
* platform/mac/fast/hidpi/image-srcset-simple-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153624 => 153625)


--- trunk/LayoutTests/ChangeLog	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/ChangeLog	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,3 +1,34 @@
+2013-08-01  Dean Jackson  <[email protected]>
+
+        Minor cleanup for srcset tests
+        https://bugs.webkit.org/show_bug.cgi?id=119407
+
+        Reviewed by Tim Horton.
+
+        Other than small typos and style tweaks, there are three
+        main changes here:
+
+        1. Collect duplicated code into a helper file.
+        2. Make sure the tests that add or remove the attributes
+        can run standalone outside of DRT.
+        3. Update the -simple test with new images that make it
+        more clear what srcset is doing.
+
+        * fast/hidpi/image-srcset-change-dynamically-from-js.html:
+        * fast/hidpi/image-srcset-invalid-inputs-correct-src.html:
+        * fast/hidpi/image-srcset-invalid-inputs-except-one.html:
+        * fast/hidpi/image-srcset-invalid-inputs.html:
+        * fast/hidpi/image-srcset-only-src-attribute.html:
+        * fast/hidpi/image-srcset-remove-dynamically-from-js.html:
+        * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html:
+        * fast/hidpi/image-srcset-simple.html:
+        * fast/hidpi/image-srcset-src-selection.html:
+        * fast/hidpi/resources/image-set-1x.png: Added.
+        * fast/hidpi/resources/image-set-2x.png: Added.
+        * fast/hidpi/resources/srcset-helper.js: Added.
+        * platform/mac/fast/hidpi/image-srcset-simple-expected.png:
+        * platform/mac/fast/hidpi/image-srcset-simple-expected.txt:
+
 2013-08-01  Romain Perier  <[email protected]>
 
         Implement img element's srcset attribute

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,31 +1,36 @@
 <html>
 <head>
 <script>
+    function updateSrc() {
+        var img = document.getElementById("foo");
+        img.src = ""
+        img.srcset = "resources/green-200-px-square.png";
+    }
+
     function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
+        if (!window.testRunner || !window.sessionStorage) {
+            updateSrc();
             return;
+        }
 
         if (!sessionStorage.scaleFactorIsSet) {
             testRunner.waitUntilDone();
             testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
         }
-        
+
         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
             delete sessionStorage.pageReloaded;
             delete sessionStorage.scaleFactorIsSet;
+            updateSrc();
             testRunner.notifyDone();
-            // Updating srcset attribute on the fly before reloading the page
-            var img = document.getElementById("foo");
-            img.src = ""
-            img.srcset = "resources/green-200-px-square.png";
         } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
+            // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
             // so to work around that, we must reload the page to get the 1x image.
             sessionStorage.pageReloaded = true;
             document.location.reload(true);
         }
     }
-    
+
     function scaleFactorIsSet() {
         sessionStorage.scaleFactorIsSet = true;
     }

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,9 @@
 <html>
 <head>
 <script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
+var targetScaleFactor = 1;
 </script>
+<script src=""
 </head>
 
 <body id="body">

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,6 @@
 <html>
 <head>
-<script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
-</script>
+<script src=""
 </head>
 
 <body id="body">

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,6 @@
 <html>
 <head>
-<script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
-</script>
+<script src=""
 </head>
 
 <body id="body">

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,6 @@
 <html>
 <head>
-<script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
-</script>
+<script src=""
 </head>
 
 <body id="body">

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,30 +1,35 @@
 <html>
 <head>
 <script>
+    function updateSrc() {
+        var img = document.getElementById("foo");
+        img.src = ""
+    }
+
     function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
+        if (!window.testRunner || !window.sessionStorage) {
+            updateSrc();
             return;
+        }
 
         if (!sessionStorage.scaleFactorIsSet) {
             testRunner.waitUntilDone();
             testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
         }
-        
+
         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
             delete sessionStorage.pageReloaded;
             delete sessionStorage.scaleFactorIsSet;
+            updateSrc();
             testRunner.notifyDone();
-            // Updating srcset attribute on the fly before reloading the page
-            var img = document.getElementById("foo");
-            img.src = ""
         } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
+            // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
             // so to work around that, we must reload the page to get the 1x image.
             sessionStorage.pageReloaded = true;
             document.location.reload(true);
         }
     }
-    
+
     function scaleFactorIsSet() {
         sessionStorage.scaleFactorIsSet = true;
     }

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-same-alternative-for-both-attributes.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-same-alternative-for-both-attributes.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-same-alternative-for-both-attributes.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,9 @@
 <html>
 <head>
 <script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
+var targetScaleFactor = 1;
 </script>
+<script src=""
 </head>
 
 <body id="body">

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-simple.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-simple.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-simple.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,37 +1,10 @@
 <html>
 <head>
-<script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 2x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
-</script>
+<script src=""
 </head>
 
 <body id="body">
-    <div>This test passes if the div below is a blue 100px square when the deviceScaleFactor is 1, and if it is a 100px green square when the deviceScaleFactor is 2.</div>
-    <img height="100" width="100" src="" srcset="resources/blue-100-px-square.png 1x, resources/deleteButton.png 3x, resources/green-200-px-square.png 2x"></img>
+    <div>This test passes if the image below says 1x with a reddish background when the deviceScaleFactor is 1, and if says 2x with a greenish background when the deviceScaleFactor is 2.</div>
+    <img height="100" width="100" src="" srcset="resources/image-set-1x.png 1x, resources/deleteButton.png 3x, resources/image-set-2x.png 2x"></img>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/hidpi/image-srcset-src-selection.html (153624 => 153625)


--- trunk/LayoutTests/fast/hidpi/image-srcset-src-selection.html	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-src-selection.html	2013-08-02 00:01:21 UTC (rev 153625)
@@ -1,33 +1,9 @@
 <html>
 <head>
 <script>
-    function runTest() {
-        if (!window.testRunner || !window.sessionStorage)
-            return;
-
-        if (!sessionStorage.scaleFactorIsSet) {
-            testRunner.waitUntilDone();
-            testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
-        }
-        
-        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
-            delete sessionStorage.pageReloaded;
-            delete sessionStorage.scaleFactorIsSet;
-            testRunner.notifyDone();
-        } else {
-            // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
-            // so to work around that, we must reload the page to get the 1x image.
-            sessionStorage.pageReloaded = true;
-            document.location.reload(true);
-        }
-    }
-    
-    function scaleFactorIsSet() {
-        sessionStorage.scaleFactorIsSet = true;
-    }
-
-    window._onload_ = runTest;
+var targetScaleFactor = 1;
 </script>
+<script src=""
 </head>
 
 <body id="body">

Added: trunk/LayoutTests/fast/hidpi/resources/image-set-1x.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/hidpi/resources/image-set-1x.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/hidpi/resources/image-set-2x.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/hidpi/resources/image-set-2x.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js (0 => 153625)


--- trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js	                        (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js	2013-08-02 00:01:21 UTC (rev 153625)
@@ -0,0 +1,29 @@
+function runTest() {
+    if (!window.testRunner || !window.sessionStorage)
+        return;
+
+    if (!window.targetScaleFactor)
+        window.targetScaleFactor = 2;
+
+    if (!sessionStorage.scaleFactorIsSet) {
+        testRunner.waitUntilDone();
+        testRunner.setBackingScaleFactor(targetScaleFactor, scaleFactorIsSet);
+    }
+
+    if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
+        delete sessionStorage.pageReloaded;
+        delete sessionStorage.scaleFactorIsSet;
+        testRunner.notifyDone();
+    } else {
+        // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
+        // so to work around that, we must reload the page to get the new image.
+        sessionStorage.pageReloaded = true;
+        document.location.reload(true);
+    }
+}
+
+function scaleFactorIsSet() {
+    sessionStorage.scaleFactorIsSet = true;
+}
+
+window.addEventListener("load", runTest, false);
Property changes on: trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-simple-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-simple-expected.txt (153624 => 153625)


--- trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-simple-expected.txt	2013-08-02 00:00:29 UTC (rev 153624)
+++ trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-simple-expected.txt	2013-08-02 00:01:21 UTC (rev 153625)
@@ -4,9 +4,9 @@
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
       RenderBlock {DIV} at (0,0) size 784x36
-        RenderText {#text} at (0,0) size 761x36
-          text run at (0,0) width 761: "This test passes if the div below is a blue 100px square when the deviceScaleFactor is 1, and if it is a 100px green square"
-          text run at (0,18) width 207: "when the deviceScaleFactor is 2."
+        RenderText {#text} at (0,0) size 775x36
+          text run at (0,0) width 775: "This test passes if the image below says 1x with a reddish background when the deviceScaleFactor is 1, and if says 2x with"
+          text run at (0,18) width 354: "a greenish background when the deviceScaleFactor is 2."
       RenderBlock (anonymous) at (0,36) size 784x100
         RenderImage {IMG} at (0,0) size 100x100
         RenderText {#text} at (0,0) size 0x0
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to