Skip to content

Commit

Permalink
Make event source tests a bit more tolerant of timing differences.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed May 3, 2014
1 parent 4f48c64 commit 4875091
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions eventsource/format-field-retry-bogus.htm
Expand Up @@ -8,18 +8,18 @@
<body>
<div id="log"></div>
<script>
var test = async_test(document.title, {timeout: 2500})
var test = async_test(document.title)
test.step(function() {
var timeoutms = 2000,
source = new EventSource("resources/message.py?message=retry%3A2000%0Aretry%3A1000x%0Adata%3Ax"),
var timeoutms = 3000,
source = new EventSource("resources/message.py?message=retry%3A3000%0Aretry%3A1000x%0Adata%3Ax"),
opened = 0
source.onopen = function() {
test.step(function() {
if(opened == 0)
opened = new Date().getTime()
else {
var diff = (new Date().getTime()) - opened
assert_true(Math.abs(1 - diff / timeoutms) < 0.1) // allow 10% difference
assert_true(Math.abs(1 - diff / timeoutms) < 0.25) // allow 25% difference
this.close();
test.done()
}
Expand Down
8 changes: 4 additions & 4 deletions eventsource/format-field-retry.htm
Expand Up @@ -8,10 +8,10 @@
<body>
<div id="log"></div>
<script>
var test = async_test(document.title, {timeout: 2500});
var test = async_test(document.title);
test.step(function() {
var timeoutms = 2000,
timeoutstr = "02000", // 1024 in octal, but should be 2000
var timeoutms = 3000,
timeoutstr = "03000", // 1536 in octal, but should be 3000
source = new EventSource("resources/message.py?message=retry%3A" + timeoutstr + "%0Adata%3Ax"),
opened = 0
source.onopen = function() {
Expand All @@ -20,7 +20,7 @@
opened = new Date().getTime()
else {
var diff = (new Date().getTime()) - opened
assert_true(Math.abs(1 - diff / timeoutms) < 0.1) // allow 10% difference
assert_true(Math.abs(1 - diff / timeoutms) < 0.25) // allow 25% difference
this.close();
test.done()
}
Expand Down

0 comments on commit 4875091

Please sign in to comment.