Changeset 71196 in webkit


Ignore:
Timestamp:
Nov 2, 2010 6:07:40 PM (13 years ago)
Author:
Michael Nordman
Message:

2010-11-02 Michael Nordman <Michael Nordman>

Reviewed by Alexey Proskuryakov.

[Chromium] Some work on making appcache layout tests less flaky.
https://bugs.webkit.org/show_bug.cgi?id=48002
1) Make network-simulator.php less slow.
In addition to redirecting back to the requested url, the response contains
multiple content-length headers. Chrome's network stacks considers that an
error condition too and picks up on it faster (one round trip instead of multiple).
This avoids timeouts due to using PHP via slow CGI on windows.
2) Removed canLoad() from appcache/fallback.html layout test, the load()
result is sufficient for determining if it could be loaded. So fewer requests are
made to conduct the test, cutting out more time.
3) Removed some unneeded code from offline-access-frame.html. Appcache events are guaranteed
to be deferred until after 'onload' has happened. This test was coded prior to that
guarantee being satisfied.

  • http/tests/appcache/fallback.html:
  • http/tests/resources/network-simulator.php:
  • http/tests/resources/offline-access-frame.html:
Location:
trunk/LayoutTests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r71192 r71196  
     12010-11-02  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        [Chromium] Some work on making appcache layout tests less flaky.
     6        https://bugs.webkit.org/show_bug.cgi?id=48002
     7        1) Make network-simulator.php less slow.
     8        In addition to redirecting back to the requested url, the response contains
     9        multiple content-length headers. Chrome's network stacks considers that an
     10        error condition too and picks up on it faster (one round trip instead of multiple).
     11        This avoids timeouts due to using PHP via slow CGI on windows.
     12        2) Removed canLoad() from appcache/fallback.html layout test, the load()
     13        result is sufficient for determining if it could be loaded. So fewer requests are
     14        made to conduct the test, cutting out more time.
     15        3) Removed some unneeded code from offline-access-frame.html. Appcache events are guaranteed
     16        to be deferred until after 'onload' has happened. This test was coded prior to that
     17        guarantee being satisfied.
     18
     19        * http/tests/appcache/fallback.html:
     20        * http/tests/resources/network-simulator.php:
     21        * http/tests/resources/offline-access-frame.html:
     22
    1232010-11-02  Mihai Parparita  <mihaip@chromium.org>
    224       
  • trunk/LayoutTests/http/tests/appcache/fallback.html

    r39546 r71196  
    3030}
    3131
    32 function canLoad(url)
    33 {
    34     try {
    35         var req = new XMLHttpRequest();
    36         req.open("GET", url, false);
    37         req.send("");
    38         return true;
    39     } catch (e) {
    40         return false;
    41     }
    42 }
    43 
    4432function load(url)
    4533{
     
    5038        return req.responseText;
    5139    } catch (ex) {
    52         alert("Unexpected error loading " + url + ": " + ex);
     40        log("FAIL: Cannot load " + url + ", ex = " + ex);
    5341        hadError = true;
     42        return ""; // This value should not be expected as the responseText for a url presented to this function.
    5443    }
    5544}
     
    6655    setNetworkEnabled(true);
    6756
    68     if (!canLoad(testURL) || !/not in the cache/.test(load(testURL))) {
     57    if (!/not in the cache/.test(load(testURL))) {
    6958        log("FAIL: Cannot load an URL from fallback namespace when network is enabled");
    7059        hadError = true;
    7160    }
    7261
    73     if (!canLoad(nonexistentURL) || load(nonexistentURL) != "Hello, World!") {
     62    if (load(nonexistentURL) != "Hello, World!") {
    7463        log("FAIL: Fallback resource wasn't used for a 404 response");
    7564        hadError = true;
    7665    }
    7766
    78     if (!canLoad(redirectURL) || load(redirectURL) != "Hello, World!") {
     67    if (load(redirectURL) != "Hello, World!") {
    7968        log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin");
    8069        hadError = true;
     
    148137    setNetworkEnabled(false);
    149138
    150     if (!canLoad(testURL)) {
    151         log("FAIL: Cannot load an URL from fallback namespace when network is disabled");
    152         hadError = true;
    153     } else if (load(testURL) != load("resources/simple.txt")) {
     139    if (load(testURL) != load("resources/simple.txt")) {
    154140        log("FAIL: Loading an URL from fallback namespace when network is disabled returned unexpected response");
    155141        hadError = true;
  • trunk/LayoutTests/http/tests/appcache/resources/offline-access-frame.html

    r40354 r71196  
    1818applicationCache.onnoupdate = function() { log("noupdate"); test() }
    1919applicationCache.onerror = function() { log("error"); test() }
    20 
    21 if (applicationCache.status == applicationCache.IDLE) {
    22     // Update finished while we were waiting for offline-access.js to load.
    23     applicationCache.oncached = function() { log("cached") }
    24     applicationCache.onnoupdate = function() { log("noupdate") }
    25     applicationCache.onerror = function() { log("error") }
    26     test();
    27 }
    28 
    2920</script>
    3021</html>
  • trunk/LayoutTests/http/tests/resources/network-simulator.php

    r66128 r71196  
    33
    44// This script acts as a stateful proxy for retrieving files. When the state is set to
    5 // offline, it simulates a network error by redirecting to itself.
     5// offline, it simulates a network error with a nonsense response.
    66
    77if (!sys_get_temp_dir()) {
     
    6060    $state = getState($stateFile);
    6161    if ($state == "Offline") {
     62        # Simulate a network error by replying with a nonsense response.
    6263        header('HTTP/1.1 307 Temporary Redirect');
    63         # Simulate a network error by redirecting to self.
    64         header('Location: ' . $_SERVER['REQUEST_URI']);
     64        header('Location: ' . $_SERVER['REQUEST_URI']); # Redirect to self.
     65        header('Content-Length: 1');
     66        header('Content-Length: 5', false); # Multiple content-length headers, some network stacks can detect this condition faster.
     67        echo "Intentionally incorrect response.";
    6568    } else {
    6669        // A little securuty checking can't hurt.
     
    7174            $path = '..' . $path;
    7275
    73         generateNoCacheHTTPHeader();   
     76        generateNoCacheHTTPHeader();
    7477
    7578        if (file_exists($path)) {
Note: See TracChangeset for help on using the changeset viewer.