blob: 6e339d587bda31af8b7513cc0c10ebc07230b8b3 [file] [log] [blame]
<!DOCTYPE html>
<html>
<script src="../../resources/ui-helper.js"></script>
<body>
<input type="file" name="file" id="file" onchange="onInputFileChange()">
<pre id='console'></pre>
<script>
function log(message)
{
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
function sendXMLHttpRequest(method, url)
{
var xhr = new XMLHttpRequest();
xhr.open(method, url, false);
try {
xhr.send();
log("Status: " + xhr.status);
log("Response: " + xhr.responseText);
} catch (error) {
log("Received exception " + error.code + ": " + error.name);
}
}
function onInputFileChange()
{
var file = document.getElementById("file").files[0];
var fileURL = window.URL.createObjectURL(file);
log("Test that XMLHttpRequest GET succeeds.");
sendXMLHttpRequest("GET", fileURL);
log("Test that XMLHttpRequest POST fails.");
sendXMLHttpRequest("POST", fileURL);
log("Test that XMLHttpRequest GET fails after the blob URL is revoked.");
window.URL.revokeObjectURL(fileURL);
sendXMLHttpRequest("GET", fileURL);
log("DONE");
if (testRunner.notifyDone)
testRunner.notifyDone();
}
function runTests()
{
testRunner.setOpenPanelFiles(['resources/UTF8.txt']);
var inputElement = document.getElementById("file");
var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY);
}
if (window.eventSender) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
window.onload = runTests;
}
</script>
</body>
</html>