From 28040489d744e0c5d475a88663056c9040ed5320 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Wed, 10 Nov 2010 15:31:59 -0800 Subject: Merge WebKit at r71558: Initial merge by git. Change-Id: Ib345578fa29df7e4bc72b4f00e4a6fddcb754c4c --- LayoutTests/http/tests/appcache/fallback.html | 26 +++++----------------- .../appcache/resources/offline-access-frame.html | 9 -------- .../http/tests/resources/network-simulator.php | 11 +++++---- 3 files changed, 13 insertions(+), 33 deletions(-) (limited to 'LayoutTests/http') diff --git a/LayoutTests/http/tests/appcache/fallback.html b/LayoutTests/http/tests/appcache/fallback.html index aaf7a82..ed641e0 100644 --- a/LayoutTests/http/tests/appcache/fallback.html +++ b/LayoutTests/http/tests/appcache/fallback.html @@ -29,18 +29,6 @@ function setNetworkEnabled(state) } } -function canLoad(url) -{ - try { - var req = new XMLHttpRequest(); - req.open("GET", url, false); - req.send(""); - return true; - } catch (e) { - return false; - } -} - function load(url) { try { @@ -49,8 +37,9 @@ function load(url) req.send(""); return req.responseText; } catch (ex) { - alert("Unexpected error loading " + url + ": " + ex); + log("FAIL: Cannot load " + url + ", ex = " + ex); hadError = true; + return ""; // This value should not be expected as the responseText for a url presented to this function. } } @@ -65,17 +54,17 @@ function test() setNetworkEnabled(true); - if (!canLoad(testURL) || !/not in the cache/.test(load(testURL))) { + if (!/not in the cache/.test(load(testURL))) { log("FAIL: Cannot load an URL from fallback namespace when network is enabled"); hadError = true; } - if (!canLoad(nonexistentURL) || load(nonexistentURL) != "Hello, World!") { + if (load(nonexistentURL) != "Hello, World!") { log("FAIL: Fallback resource wasn't used for a 404 response"); hadError = true; } - if (!canLoad(redirectURL) || load(redirectURL) != "Hello, World!") { + if (load(redirectURL) != "Hello, World!") { log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin"); hadError = true; } @@ -147,10 +136,7 @@ function test6() { setNetworkEnabled(false); - if (!canLoad(testURL)) { - log("FAIL: Cannot load an URL from fallback namespace when network is disabled"); - hadError = true; - } else if (load(testURL) != load("resources/simple.txt")) { + if (load(testURL) != load("resources/simple.txt")) { log("FAIL: Loading an URL from fallback namespace when network is disabled returned unexpected response"); hadError = true; } diff --git a/LayoutTests/http/tests/appcache/resources/offline-access-frame.html b/LayoutTests/http/tests/appcache/resources/offline-access-frame.html index 68ef274..43015ae 100644 --- a/LayoutTests/http/tests/appcache/resources/offline-access-frame.html +++ b/LayoutTests/http/tests/appcache/resources/offline-access-frame.html @@ -17,14 +17,5 @@ applicationCache.onobsolete = function() { log("obsolete") } applicationCache.oncached = function() { log("cached"); test() } applicationCache.onnoupdate = function() { log("noupdate"); test() } applicationCache.onerror = function() { log("error"); test() } - -if (applicationCache.status == applicationCache.IDLE) { - // Update finished while we were waiting for offline-access.js to load. - applicationCache.oncached = function() { log("cached") } - applicationCache.onnoupdate = function() { log("noupdate") } - applicationCache.onerror = function() { log("error") } - test(); -} - diff --git a/LayoutTests/http/tests/resources/network-simulator.php b/LayoutTests/http/tests/resources/network-simulator.php index 4860028..ccfcf5c 100644 --- a/LayoutTests/http/tests/resources/network-simulator.php +++ b/LayoutTests/http/tests/resources/network-simulator.php @@ -2,7 +2,7 @@ require_once 'portabilityLayer.php'; // This script acts as a stateful proxy for retrieving files. When the state is set to -// offline, it simulates a network error by redirecting to itself. +// offline, it simulates a network error with a nonsense response. if (!sys_get_temp_dir()) { echo "FAIL: No temp dir was returned.\n"; @@ -59,9 +59,12 @@ function generateResponse($path) global $stateFile; $state = getState($stateFile); if ($state == "Offline") { + # Simulate a network error by replying with a nonsense response. header('HTTP/1.1 307 Temporary Redirect'); - # Simulate a network error by redirecting to self. - header('Location: ' . $_SERVER['REQUEST_URI']); + header('Location: ' . $_SERVER['REQUEST_URI']); # Redirect to self. + header('Content-Length: 1'); + header('Content-Length: 5', false); # Multiple content-length headers, some network stacks can detect this condition faster. + echo "Intentionally incorrect response."; } else { // A little securuty checking can't hurt. if (strstr($path, "..")) @@ -70,7 +73,7 @@ function generateResponse($path) if ($path[0] == '/') $path = '..' . $path; - generateNoCacheHTTPHeader(); + generateNoCacheHTTPHeader(); if (file_exists($path)) { header("Last-Modified: " . gmdate("D, d M Y H:i:s T", filemtime($path))); -- cgit v1.1