Skip to content

Instantly share code, notes, and snippets.

@n1k0
Last active December 14, 2015 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save n1k0/5161721 to your computer and use it in GitHub Desktop.
Save n1k0/5161721 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>My page</title>
<script>
window.onbeforeunload = function() {
alert('plop');
}
</script>
</head>
<body>
<h1>Test page</h1>
</body>
</html>
/*jshint strict:false*/
/*global CasperError, casper, console, phantom, require*/
casper.test.begin('test onbeforeunload', 3, {
setUp: function(test) {
casper.on('remote.alert', function(msg) {
test.assertEquals(msg, 'plop');
});
},
test: function(test) {
casper.start('page.html', function() {
test.assertTitle('My page');
});
casper.thenOpen('http://google.com', function() {
test.assertTitle('Google');
});
casper.run(function() {
test.done();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment