Skip to content

Commit

Permalink
Manual port of: FBTest for issue 5049
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Apr 12, 2013
1 parent 3cc23d8 commit 0563a3d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/content/console/spy/5049/issue5049-1.txt
@@ -0,0 +1 @@
Hello Firebug user!
1 change: 1 addition & 0 deletions tests/content/console/spy/5049/issue5049-2.txt
@@ -0,0 +1 @@
Hello Firebug user 2!
47 changes: 47 additions & 0 deletions tests/content/console/spy/5049/issue5049.html
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>Issue 5049: onreadystatechange fails for back-to-back XMLHTTP requests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="https://getfirebug.com/tests/head/_common/testcase.css"
type="text/css" rel="stylesheet"/>
</head>
<body>
<header>
<h1><a href="http://code.google.com/p/fbug/issues/detail?id=5049">Issue 5049</a>:
onreadystatechange fails for back-to-back XMLHTTP requests</h1>
</header>
<div>
<section id="description">
<h3>Steps to reproduce</h3>
<ol>
<li>Open Firebug</li>
<li>Enable and switch to the <em>Console</em> panel</li>
<li>Click this button <button id="testButton" onclick="onExecuteTest()">Click Me!</button></li>
<li>Two XMLHttpRequest logs to <code>issue5049.txt</code> should be displayed</li>
<li>Both requests should have HTTP status and time (displayed at the end)</li>
</ol>
</section>
<script type="text/javascript">
function onExecuteTest()
{
var xhr = new XMLHttpRequest();
var url = "issue5049-1.txt";
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
url = "issue5049-2.txt";
xhr.onreadystatechange = function() {};
xhr.open("GET", url);
xhr.send(null);
}
}
xhr.open("GET", url);
xhr.send(null);
}
</script>
<footer>Jan Odvarko &lt;odvarko@gmail.com&gt;</footer>
</div>
</body>
</html>
63 changes: 63 additions & 0 deletions tests/content/console/spy/5049/issue5049.js
@@ -0,0 +1,63 @@
function runTest()
{
FBTest.sysout("issue5049.START");
FBTest.setPref("showXMLHttpRequests", true);
FBTest.openNewTab(basePath + "console/spy/5049/issue5049.html", function(win)
{
FBTest.openFirebug();
FBTest.enableConsolePanel(function(win)
{
var options = {
tagName: "div",
classes: "logRow logRow-spy loaded",
counter: 2
};

waitForDisplayedElementAsync("console", options, function(row)
{
setTimeout(function() {
var panel = FBTest.getPanel("console");
var root = panel.panelNode;

var statuses = root.querySelectorAll(".spyRow .spyStatus");
if (FBTest.compare(2, statuses.length, "There must be two statuses"))
{
FBTest.ok(statuses[0].textContent, "There must be a status info: " +
statuses[0].textContent);
FBTest.ok(statuses[1].textContent, "There must be a status info: " +
statuses[1].textContent);

FBTrace.sysout("statuses", statuses)
}

var times = root.querySelectorAll(".spyRow .spyTime");
FBTest.compare(2, times.length, "There must be two time fields");
{
FBTest.ok(times[0].textContent, "There must be a time info: " +
times[0].textContent);
FBTest.ok(times[1].textContent, "There must be a time info: " +
times[1].textContent);

FBTrace.sysout("times", times)
}

FBTest.testDone("issue5049.DONE");
});
});

// Execute test implemented on the test page.
FBTest.click(win.document.getElementById("testButton"));
});
});
}

function waitForDisplayedElementAsync(panelName, config, callback)
{
FBTest.waitForDisplayedElement(panelName, config, function(element)
{
setTimeout(function(element)
{
callback(element);
});
});
}
3 changes: 2 additions & 1 deletion tests/content/firebug.html
@@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
Expand Down Expand Up @@ -129,6 +129,7 @@
{group: "console/spy", uri: "console/spy/4085/issue4085.js", desc: "Errors inside an XmlHttpRequest.onReadyStateChange still fail silently", testPage: "console/spy/4085/issue4085.html" },
{group: "console/spy", uri: "console/spy/4738/issue4738.js", desc: "Open in new tab opens wrong url when reusing XMLHttpRequest objects", testPage: "console/spy/4738/issue4738.html" },
{group: "console/spy", uri: "console/spy/4171/issue4171.js", desc: "Expanding an XMLHttpRequest in Console tab before it ends makes JSON tab disappear", testPage: "console/spy/4171/issue4171.html" },
{group: "console/spy", uri: "console/spy/5049/issue5049.js", desc: "onreadystatechange fails for back-to-back XMLHTTP requests", testPage: "console/spy/5049/issue5049.html" },
{group: "console/api", uri: "console/api/assert.js", desc: "Test for console.assert API.", testPage: "console/api/assert.html" },
{group: "console/api", uri: "console/api/clear.js", desc: "Test for console.clear API.", testPage: "console/api/clear.html" },
{group: "console/api", uri: "console/api/count.js", desc: "Test for console.count API.", testPage: "console/api/count.html" },
Expand Down

0 comments on commit 0563a3d

Please sign in to comment.