Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix coding style of layout test fast/dom/timer-throttling-hidden-page…
….html

https://bugs.webkit.org/show_bug.cgi?id=98828

Patch by Kiran Muppala <cmuppala@apple.com> on 2012-10-09
Reviewed by Ojan Vafai.

Replaced tab characters with spaces, fixed position of braces and renamed
variables to be more explanatory.

* fast/dom/timer-throttling-hidden-page.html:

Canonical link: https://commits.webkit.org/116811@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130827 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Kiran Muppala authored and webkit-commit-queue committed Oct 9, 2012
1 parent 961a070 commit 61385da
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
2012-10-09 Kiran Muppala <cmuppala@apple.com>

Fix coding style of layout test fast/dom/timer-throttling-hidden-page.html
https://bugs.webkit.org/show_bug.cgi?id=98828

Reviewed by Ojan Vafai.

Replaced tab characters with spaces, fixed position of braces and renamed
variables to be more explanatory.

* fast/dom/timer-throttling-hidden-page.html:

2012-10-09 Sadrul Habib Chowdhury <sadrul@chromium.org>

[chromium] Add drop event for plugins.
Expand Down
51 changes: 25 additions & 26 deletions LayoutTests/fast/dom/timer-throttling-hidden-page.html
Expand Up @@ -5,67 +5,66 @@
description('<a href="https://bugs.webkit.org/show_bug.cgi?id=98474">Bug 98474</a>: Throttle DOM timers on hidden pages.');

var jsTestIsAsync = true;
var previousT = new Date().getTime();
var previousTime = new Date().getTime();
var timerCount = 0;
var firstTimerWhileHidden = true;
var isPageVisible = true;
var timeoutInterval = 100;
var tolerance = 20;
var timerAlignmentInterval = 1000;

function testTimer() {
var d = new Date();
var t = d.getTime();
function testTimer()
{
var date = new Date();
var time = date.getTime();
if (!isPageVisible) {
if (firstTimerWhileHidden) {
firstTimerIntervalWhilePageHidden = t - previousT;
firstTimerIntervalWhilePageHidden = time - previousTime;
var minValue = timeoutInterval - tolerance;
shouldBeGreaterThanOrEqual("firstTimerIntervalWhilePageHidden", minValue.toString());
var maxValue = timeoutInterval + timerAlignmentInterval + tolerance;
shouldBeGreaterThanOrEqual("firstTimerIntervalWhilePageHidden", minValue.toString());
var maxValue = timeoutInterval + timerAlignmentInterval + tolerance;
shouldBeTrue("firstTimerIntervalWhilePageHidden <= " + maxValue);
firstTimerWhileHidden = false;
} else {
timerIntervalWhilePageHidden = t - previousT;
timerIntervalWhilePageHidden = time - previousTime;
shouldBeCloseTo("timerIntervalWhilePageHidden", timerAlignmentInterval, tolerance);
}
}
else {
timerIntervalWhilePageVisible = t - previousT;
} else {
timerIntervalWhilePageVisible = time - previousTime;
shouldBeCloseTo("timerIntervalWhilePageVisible", timeoutInterval, tolerance);
}

timerCount++;
previousT = t;
previousTime = time;

if (timerCount == 1) {
testRunner.setPageVisibility("hidden");
isPageVisible = false;
} else if (timerCount == 3) {
isPageVisible = false;
} else if (timerCount == 3) {
testRunner.resetPageVisibility();
isPageVisible = true;
} else if (timerCount >= 4){
finishJSTest();
return;
return;
}
setTimeout(testTimer, timeoutInterval);
}
}

function runTest() {
if (!window.testRunner) {
debug('This test requires testRunner');
return;
function runTest()
{
if (!window.testRunner) {
debug('This test requires testRunner');
return;
}
var timeoutIntervalSpans = document.getElementsByClassName('timeoutInterval');
for (var i = 0; i < timeoutIntervalSpans.length; i++) {
timeoutIntervalSpans[i].innerText = timeoutInterval;
}
var timeoutIntervalSpans = document.getElementsByClassName('timeoutInterval');
for (var i = 0; i < timeoutIntervalSpans.length; i++)
timeoutIntervalSpans[i].innerText = timeoutInterval;

document.getElementById('alignmentInterval').innerText = timerAlignmentInterval / 1000;
document.getElementById('alignmentInterval').innerText = timerAlignmentInterval / 1000;

testRunner.dumpAsText();
setTimeout(testTimer, timeoutInterval);
}

</script>
</head>
<body onload="runTest()">
Expand Down

0 comments on commit 61385da

Please sign in to comment.