Created
February 9, 2011 13:37
-
-
Save gentooboontoo/818478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Env-js fail test</title> | |
<script src="jquery-1.4.4.min.js"></script> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<!-- | |
We need to trigger a custom download depending on many parameters. | |
We use a form to dynamically make a POST request with custom parameters (not implemented | |
in this test since not meaningful). | |
In real browsers, it triggers a download. | |
In envjs, it fails with: | |
$events[target.uuid] is undefined | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/env.js:1735:in `__dispatchEvent__' [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:1718 [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:7537 [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:7562 [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:7256 [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:7298 [JavaScript] | |
/usr/local/lib64/ruby/gems/1.8/gems/envjs-0.3.8/lib/envjs/static.js:7594 [JavaScript] | |
http:/0.0.0.0:8080/tmp/envjs-failtest/main.js:4 [JavaScript] | |
We do not use xhr to make a post request because it's not | |
possible to make a download through it. | |
We need a POST because we have many info to pass to server (GET request url is not long enough). | |
--> | |
<form method="post" action="random.bin"></form> | |
<!-- it also fails with plain text file but do not show 'malformed UTF-8 character' error --> | |
<!-- <form method="post" action="foo.txt"></form> --> | |
<select> | |
<option value="none">Choose...</option> | |
<option value="go">Go!</option> | |
</select> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
jQuery('select').change(function() { | |
downloadFile(); | |
this.selectedIndex = 0; | |
}); | |
jQuery("select").val("go") | |
// (Should) trigger download | |
jQuery("select").change() | |
}); | |
function downloadFile() { | |
//window.location.href = "random.bin"; | |
//window.open("random.bin"); | |
//window.open("foo.txt"); | |
jQuery("form").submit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment