Skip to content

Instantly share code, notes, and snippets.

@bwhite
Created February 9, 2014 20:53
Show Gist options
  • Save bwhite/8905788 to your computer and use it in GitHub Desktop.
Save bwhite/8905788 to your computer and use it in GitHub Desktop.
[wearscript] Tests the java/javascript bridge for character violations. A string can be sent to java and back as long as it has no null characters in it. For callbacks there are more restrictions (as such all data should be b64d).
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function server() {
var a=[]; for (var i = 0; i < 256; i++) a.push(String.fromCharCode(i));b256=a.join('');
a=[]; for (var i = 1; i < 256; i++) a.push(String.fromCharCode(i));b255=a.join('');
WS.log('echolen(b256): ' + WS.echolen(b256));
WS.log('echolen(b255): ' + WS.echolen(b255));
WS.log('echo(b256).length: ' + WS.echo(b256).length);
WS.log('echo(b255).length: ' + WS.echo(b255).length);
WS.echocall('javascript:WS.log("' + b256 + '".length)');
WS.echocall('javascript:WS.log("' + b255 + '".length)');
}
function main() {
if (WS.scriptVersion(1)) return;
WS.serverConnect('{{WSUrl}}', 'server');
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment