Navigation Menu

Skip to content

Commit

Permalink
Reduce XHR timeout tests execution time
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=102184

Reviewed by Csaba Osztrogonác.

Reduce all timeouts by five.

* http/tests/resources/load-and-stall.cgi:
* http/tests/resources/load-and-stall.php:
* http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-runner.js:
* http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js:
(RequestTracker.prototype.startXHR):
(RequestTracker.prototype.handleEvent):
(AbortedRequest.prototype.getMessage):
(AbortedRequest.prototype.handleEvent):
(SyncRequestSettingTimeoutAfterOpen.startXHR):
(SyncRequestSettingTimeoutBeforeOpen.startXHR):
(TestCounter.testComplete):

Canonical link: https://commits.webkit.org/121499@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carewolf committed Nov 27, 2012
1 parent 83c5db5 commit 6e3c7e3
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 31 deletions.
21 changes: 21 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
2012-11-27 Allan Sandfeld Jensen <allan.jensen@digia.com>

Reduce XHR timeout tests execution time
https://bugs.webkit.org/show_bug.cgi?id=102184

Reviewed by Csaba Osztrogonác.

Reduce all timeouts by five.

* http/tests/resources/load-and-stall.cgi:
* http/tests/resources/load-and-stall.php:
* http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-runner.js:
* http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js:
(RequestTracker.prototype.startXHR):
(RequestTracker.prototype.handleEvent):
(AbortedRequest.prototype.getMessage):
(AbortedRequest.prototype.handleEvent):
(SyncRequestSettingTimeoutAfterOpen.startXHR):
(SyncRequestSettingTimeoutBeforeOpen.startXHR):
(TestCounter.testComplete):

2012-11-27 Mihnea Ovidenie <mihnea@adobe.com>

[CSS Regions] Absolutely positioned regions do not expand to fill their container
Expand Down
3 changes: 2 additions & 1 deletion LayoutTests/http/tests/resources/load-and-stall.cgi
Expand Up @@ -2,6 +2,7 @@

use CGI;
use File::stat;
use Time::HiRes;

$query = new CGI;
$name = $query->param('name');
Expand All @@ -21,7 +22,7 @@ while (($n = read FILE, $data, 1024) != 0) {
$total += $n;
if ($total > $stallAt) {
if (defined $stallFor) {
sleep($stallFor)
Time::HiRes::sleep($stallFor)
}
last;
}
Expand Down
2 changes: 1 addition & 1 deletion LayoutTests/http/tests/resources/load-and-stall.php
Expand Up @@ -27,7 +27,7 @@
flush();
ob_flush();
}
sleep($stallFor);
usleep($stallFor * 1000000);
echo(fread($file, filesize($name) - $stallAt));
} else {
echo(fread($file, filesize($name)));
Expand Down
Expand Up @@ -21,7 +21,7 @@ function groupFromLocation() {
}

// Setting up testharness.js
setup({ explicit_done: true, timeout: 3 * 60 * 1000 });
setup({ explicit_done: true, timeout: 30 * 1000 });

// Abort test execution if an individual test case fails.
add_result_callback(function (t) {
Expand Down
Expand Up @@ -11,10 +11,17 @@
request handlers.
*/

var TIME_NORMAL_LOAD = 1000;
var TIME_LATE_TIMEOUT = 800;
var TIME_XHR_LOAD = 600;
var TIME_REGULAR_TIMEOUT = 400;
var TIME_SYNC_TIMEOUT = 200;
var TIME_DELAY = 200;

/*
* This should point to a resource that responds after a delay of 3 seconds.
* This should point to a resource that responds after a delay of TIME_XHR_LOAD milliseconds.
*/
var STALLED_REQUEST_URL = "/resources/load-and-stall.cgi?name=../../../http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js&stallFor=3&stallAt=0&mimeType=text/plain";
var STALLED_REQUEST_URL = "/resources/load-and-stall.cgi?name=../../../http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js&stallFor=" + TIME_XHR_LOAD/1000 + "&stallAt=0&mimeType=text/plain";

var inWorker = false;
try {
Expand Down Expand Up @@ -109,7 +116,7 @@ RequestTracker.prototype = {
}
catch (e) {
// Synchronous case in workers.
ok(!this.async && this.timeLimit < 3000 && e.name == "TimeoutError", "Unexpected error: " + e);
ok(!this.async && this.timeLimit < TIME_XHR_LOAD && e.name == "TimeoutError", "Unexpected error: " + e);
TestCounter.testComplete();
}
},
Expand Down Expand Up @@ -144,11 +151,11 @@ RequestTracker.prototype = {
this.hasFired = true;

var type = evt.type, expectedType;
// The XHR responds after 3000 milliseconds with a load event.
var timeLimit = this.mustReset && (this.resetAfter < Math.min(3000, this.timeLimit)) ?
// The XHR responds after TIME_XHR_LOAD milliseconds with a load event.
var timeLimit = this.mustReset && (this.resetAfter < Math.min(TIME_XHR_LOAD, this.timeLimit)) ?
this.resetTo :
this.timeLimit;
if ((timeLimit == 0) || (timeLimit >= 3000)) {
if ((timeLimit == 0) || (timeLimit >= TIME_XHR_LOAD)) {
expectedType = "load";
}
else {
Expand Down Expand Up @@ -185,7 +192,7 @@ AbortedRequest.prototype = {
req.onabort = handleEvent;
req.ontimeout = handleEvent;

req.timeout = 2000;
req.timeout = TIME_REGULAR_TIMEOUT;
var _this = this;

function abortReq() {
Expand All @@ -201,7 +208,7 @@ AbortedRequest.prototype = {
ok(false, "Unexpected error: " + e);
TestCounter.testComplete();
}
}, 5000);
}, TIME_NORMAL_LOAD);
}
else {
// Abort events can only be triggered on sent requests.
Expand Down Expand Up @@ -230,7 +237,7 @@ AbortedRequest.prototype = {
* @returns {String} The test description.
*/
getMessage: function() {
return "time to abort is " + this.abortDelay + ", timeout set at 2000";
return "time to abort is " + this.abortDelay + ", timeout set at " + TIME_REGULAR_TIMEOUT;
},

/**
Expand All @@ -248,7 +255,7 @@ AbortedRequest.prototype = {
return;
}

var expectedEvent = (this.abortDelay >= 2000 && !this.hasFired) ? "timeout" : "abort";
var expectedEvent = (this.abortDelay >= TIME_REGULAR_TIMEOUT && !this.hasFired) ? "timeout" : "abort";
this.hasFired = true;
is(evt.type, expectedEvent, this.getMessage());
TestCounter.testComplete();
Expand All @@ -261,7 +268,7 @@ var SyncRequestSettingTimeoutAfterOpen = {
var req = new XMLHttpRequest();
req.open("GET", STALLED_REQUEST_URL, false);
try {
req.timeout = 1000;
req.timeout = TIME_SYNC_TIMEOUT;
}
catch (e) {
pass = true;
Expand All @@ -275,7 +282,7 @@ var SyncRequestSettingTimeoutBeforeOpen = {
startXHR: function() {
var pass = false;
var req = new XMLHttpRequest();
req.timeout = 1000;
req.timeout = TIME_SYNC_TIMEOUT;
try {
req.open("GET", STALLED_REQUEST_URL, false);
}
Expand All @@ -290,39 +297,39 @@ var SyncRequestSettingTimeoutBeforeOpen = {
var TestRequestGroups = {
"simple" : [
new RequestTracker(true, "no time out scheduled, load fires normally", 0),
new RequestTracker(true, "load fires normally", 5000),
new RequestTracker(true, "timeout hit before load", 2000)
new RequestTracker(true, "load fires normally", TIME_NORMAL_LOAD),
new RequestTracker(true, "timeout hit before load", TIME_REGULAR_TIMEOUT)
],

"twice" : [
new RequestTracker(true, "load fires normally with no timeout set, twice", 0, 2000, 0),
new RequestTracker(true, "load fires normally with same timeout set twice", 5000, 2000, 5000),
new RequestTracker(true, "timeout fires normally with same timeout set twice", 2000, 1000, 2000)
new RequestTracker(true, "load fires normally with no timeout set, twice", 0, TIME_REGULAR_TIMEOUT, 0),
new RequestTracker(true, "load fires normally with same timeout set twice", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD),
new RequestTracker(true, "timeout fires normally with same timeout set twice", TIME_REGULAR_TIMEOUT, TIME_DELAY, TIME_REGULAR_TIMEOUT)
],

// FIXME: http://webkit.org/b/98156 - Late updates are not supported yet, these tests are not run.
"overrides" : [
new RequestTracker(true, "timeout disabled after initially set", 5000, 2000, 0),
new RequestTracker(true, "timeout overrides load after a delay", 5000, 1000, 2000),
new RequestTracker(true, "timeout enabled after initially disabled", 0, 2000, 5000)
new RequestTracker(true, "timeout disabled after initially set", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, 0),
new RequestTracker(true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT),
new RequestTracker(true, "timeout enabled after initially disabled", 0, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD)
],

"overridesexpires" : [
new RequestTracker(true, "timeout set to expiring value after load fires", 5000, 4000, 1000),
new RequestTracker(true, "timeout set to expiring value after load fires", TIME_NORMAL_LOAD, TIME_LATE_TIMEOUT, TIME_DELAY),
// FIXME: http://webkit.org/b/98156 - Late updates are not supported yet, this test is not run.
// new RequestTracker(true, "timeout set to expired value before load fires", 5000, 2000, 1000),
new RequestTracker(true, "timeout set to non-expiring value after timeout fires", 1000, 2000, 5000)
// new RequestTracker(true, "timeout set to expired value before load fires", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_DELAY),
new RequestTracker(true, "timeout set to non-expiring value after timeout fires", TIME_DELAY, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD)
],

"aborted" : [
new AbortedRequest(false),
new AbortedRequest(true, -1),
new AbortedRequest(true, 5000)
new AbortedRequest(true, TIME_NORMAL_LOAD)
],

"abortedonmain" : [
new AbortedRequest(true, 0),
new AbortedRequest(true, 1000)
new AbortedRequest(true, TIME_DELAY)
],

"synconmain" : [
Expand All @@ -332,8 +339,8 @@ var TestRequestGroups = {

"synconworker" : [
new RequestTracker(false, "no time out scheduled, load fires normally", 0),
new RequestTracker(false, "load fires normally", 5000),
new RequestTracker(false, "timeout hit before load", 2000)
new RequestTracker(false, "load fires normally", TIME_NORMAL_LOAD),
new RequestTracker(false, "timeout hit before load", TIME_REGULAR_TIMEOUT)
]
};

Expand All @@ -345,7 +352,7 @@ var TestCounter = {
// Allow for the possibility there are other events coming.
self.setTimeout(function() {
TestCounter.next();
}, 5000);
}, TIME_NORMAL_LOAD);
},

next: function() {
Expand Down

0 comments on commit 6e3c7e3

Please sign in to comment.