Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created October 22, 2013 14:59
Show Gist options
  • Save briancavalier/d43f358f4dd078a3e017 to your computer and use it in GitHub Desktop.
Save briancavalier/d43f358f4dd078a3e017 to your computer and use it in GitHub Desktop.
PhantomJS test of using cujoJS/poly for Function.prototype.bind
var page = require('webpage').create(),
system = require('system'),
address;
if (system.args.length === 1) {
console.log('Please specify a url');
phantom.exit();
}
page.onConsoleMessage = function (msg) {
console.log('BROWSER', msg);
};
address = system.args[1];
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
phantom.exit();
}
});
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>test</title>
<script>
curl = {
baseUrl: '../',
paths: {
curl: 'test/curl'
},
packages: [
{ name: 'poly', location: '.', main: 'poly' }
]
};
</script>
<script src="curl.js"></script>
<script>
curl(['poly/function'], function() {
try {
// var x = Function.prototype.call.bind;
var slice = Function.prototype.call.bind(Array.prototype.slice);
console.log(slice, slice([1,2,3], 1));
} catch(e) {
console.log(e);
}
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment