Changeset 153625 in webkit


Ignore:
Timestamp:
Aug 1, 2013 5:01:21 PM (11 years ago)
Author:
dino@apple.com
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.

  1. 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:
Location:
trunk/LayoutTests
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r153624 r153625  
     12013-08-01  Dean Jackson  <dino@apple.com>
     2
     3        Minor cleanup for srcset tests
     4        https://bugs.webkit.org/show_bug.cgi?id=119407
     5
     6        Reviewed by Tim Horton.
     7
     8        Other than small typos and style tweaks, there are three
     9        main changes here:
     10
     11        1. Collect duplicated code into a helper file.
     12        2. Make sure the tests that add or remove the attributes
     13        can run standalone outside of DRT.
     14        3. Update the -simple test with new images that make it
     15        more clear what srcset is doing.
     16
     17        * fast/hidpi/image-srcset-change-dynamically-from-js.html:
     18        * fast/hidpi/image-srcset-invalid-inputs-correct-src.html:
     19        * fast/hidpi/image-srcset-invalid-inputs-except-one.html:
     20        * fast/hidpi/image-srcset-invalid-inputs.html:
     21        * fast/hidpi/image-srcset-only-src-attribute.html:
     22        * fast/hidpi/image-srcset-remove-dynamically-from-js.html:
     23        * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html:
     24        * fast/hidpi/image-srcset-simple.html:
     25        * fast/hidpi/image-srcset-src-selection.html:
     26        * fast/hidpi/resources/image-set-1x.png: Added.
     27        * fast/hidpi/resources/image-set-2x.png: Added.
     28        * fast/hidpi/resources/srcset-helper.js: Added.
     29        * platform/mac/fast/hidpi/image-srcset-simple-expected.png:
     30        * platform/mac/fast/hidpi/image-srcset-simple-expected.txt:
     31
    1322013-08-01  Romain Perier  <romain.perier@gmail.com>
    233
  • trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js.html

    r153624 r153625  
    22<head>
    33<script>
     4    function updateSrc() {
     5        var img = document.getElementById("foo");
     6        img.src = "resources/blue-100-px-square.png"
     7        img.srcset = "resources/green-200-px-square.png";
     8    }
     9
    410    function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
     11        if (!window.testRunner || !window.sessionStorage) {
     12            updateSrc();
    613            return;
     14        }
    715
    816        if (!sessionStorage.scaleFactorIsSet) {
     
    1018            testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
    1119        }
    12        
     20
    1321        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    1422            delete sessionStorage.pageReloaded;
    1523            delete sessionStorage.scaleFactorIsSet;
     24            updateSrc();
    1625            testRunner.notifyDone();
    17             // Updating srcset attribute on the fly before reloading the page
    18             var img = document.getElementById("foo");
    19             img.src = "resources/blue-100-px-square.png"
    20             img.srcset = "resources/green-200-px-square.png";
    2126        } else {
    22             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
     27            // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
    2328            // so to work around that, we must reload the page to get the 1x image.
    2429            sessionStorage.pageReloaded = true;
     
    2631        }
    2732    }
    28    
     33
    2934    function scaleFactorIsSet() {
    3035        sessionStorage.scaleFactorIsSet = true;
  • trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html

    r153624 r153625  
    22<head>
    33<script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
     4var targetScaleFactor = 1;
    305</script>
     6<script src="resources/srcset-helper.js"></script>
    317</head>
    328
  • trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html

    r153624 r153625  
    11<html>
    22<head>
    3 <script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
    30 </script>
     3<script src="resources/srcset-helper.js"></script>
    314</head>
    325
  • trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html

    r153624 r153625  
    11<html>
    22<head>
    3 <script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
    30 </script>
     3<script src="resources/srcset-helper.js"></script>
    314</head>
    325
  • trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html

    r153624 r153625  
    11<html>
    22<head>
    3 <script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
    30 </script>
     3<script src="resources/srcset-helper.js"></script>
    314</head>
    325
  • trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html

    r153624 r153625  
    22<head>
    33<script>
     4    function updateSrc() {
     5        var img = document.getElementById("foo");
     6        img.src = "";
     7    }
     8
    49    function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
     10        if (!window.testRunner || !window.sessionStorage) {
     11            updateSrc();
    612            return;
     13        }
    714
    815        if (!sessionStorage.scaleFactorIsSet) {
     
    1017            testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
    1118        }
    12        
     19
    1320        if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    1421            delete sessionStorage.pageReloaded;
    1522            delete sessionStorage.scaleFactorIsSet;
     23            updateSrc();
    1624            testRunner.notifyDone();
    17             // Updating srcset attribute on the fly before reloading the page
    18             var img = document.getElementById("foo");
    19             img.src = "";
    2025        } else {
    21             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
     26            // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
    2227            // so to work around that, we must reload the page to get the 1x image.
    2328            sessionStorage.pageReloaded = true;
     
    2530        }
    2631    }
    27    
     32
    2833    function scaleFactorIsSet() {
    2934        sessionStorage.scaleFactorIsSet = true;
  • trunk/LayoutTests/fast/hidpi/image-srcset-same-alternative-for-both-attributes.html

    r153624 r153625  
    22<head>
    33<script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
     4var targetScaleFactor = 1;
    305</script>
     6<script src="resources/srcset-helper.js"></script>
    317</head>
    328
  • trunk/LayoutTests/fast/hidpi/image-srcset-simple.html

    r153624 r153625  
    11<html>
    22<head>
    3 <script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(2, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 2x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
    30 </script>
     3<script src="resources/srcset-helper.js"></script>
    314</head>
    325
    336<body id="body">
    34     <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>
    35     <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>
     7    <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>
     8    <img height="100" width="100" src="" srcset="resources/image-set-1x.png 1x, resources/deleteButton.png 3x, resources/image-set-2x.png 2x"></img>
    369</body>
    3710</html>
  • trunk/LayoutTests/fast/hidpi/image-srcset-src-selection.html

    r153624 r153625  
    22<head>
    33<script>
    4     function runTest() {
    5         if (!window.testRunner || !window.sessionStorage)
    6             return;
    7 
    8         if (!sessionStorage.scaleFactorIsSet) {
    9             testRunner.waitUntilDone();
    10             testRunner.setBackingScaleFactor(1, scaleFactorIsSet);
    11         }
    12        
    13         if (sessionStorage.pageReloaded && sessionStorage.scaleFactorIsSet) {
    14             delete sessionStorage.pageReloaded;
    15             delete sessionStorage.scaleFactorIsSet;
    16             testRunner.notifyDone();
    17         } else {
    18             // Right now there is a bug that image-set does not properly deal with dynamic changes to the scale factor,
    19             // so to work around that, we must reload the page to get the 1x image.
    20             sessionStorage.pageReloaded = true;
    21             document.location.reload(true);
    22         }
    23     }
    24    
    25     function scaleFactorIsSet() {
    26         sessionStorage.scaleFactorIsSet = true;
    27     }
    28 
    29     window.onload = runTest;
     4var targetScaleFactor = 1;
    305</script>
     6<script src="resources/srcset-helper.js"></script>
    317</head>
    328
  • trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-simple-expected.txt

    r153624 r153625  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderBlock {DIV} at (0,0) size 784x36
    7         RenderText {#text} at (0,0) size 761x36
    8           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"
    9           text run at (0,18) width 207: "when the deviceScaleFactor is 2."
     7        RenderText {#text} at (0,0) size 775x36
     8          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"
     9          text run at (0,18) width 354: "a greenish background when the deviceScaleFactor is 2."
    1010      RenderBlock (anonymous) at (0,36) size 784x100
    1111        RenderImage {IMG} at (0,0) size 100x100
Note: See TracChangeset for help on using the changeset viewer.