Commit 2118ecbb 2118ecbb2c1a29c0f23f2698781d8669dce52781 by Nicolas Perriault

fixed tests for phantomjs <1.9.0

1 parent 896e8ec8
......@@ -18,24 +18,26 @@ casper.test.begin('sendKeys() tests', 3, function(test) {
});
});
casper.test.begin('sendKeys() key modifiers tests', 1, function(test) {
casper.start().then(function() {
this.setContent([
'<input>',
'<script>var keys = []; window.addEventListener("keypress", function(e) {',
' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});',
'})</script>'
].join(''));
this.sendKeys('input', 'k');
this.sendKeys('input', 'k', {modifiers: "ctrl"});
this.sendKeys('input', 'k', {modifiers: "ctrl+alt"});
test.assertEquals(this.getGlobal('keys'),
[
{code: 107, alt: false, ctrl: false},
{code: 107, alt: false, ctrl: true},
{code: 107, alt: true, ctrl: true}
], 'sendKeys() uses key modifiers');
}).run(function() {
test.done();
if (utils.gteVersion(phantom.version, '1.9.0')) {
casper.test.begin('sendKeys() key modifiers tests', 1, function(test) {
casper.start().then(function() {
this.setContent([
'<input>',
'<script>var keys = []; window.addEventListener("keypress", function(e) {',
' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});',
'})</script>'
].join(''));
this.sendKeys('input', 'k');
this.sendKeys('input', 'k', {modifiers: "ctrl"});
this.sendKeys('input', 'k', {modifiers: "ctrl+alt"});
test.assertEquals(this.getGlobal('keys'),
[
{code: 107, alt: false, ctrl: false},
{code: 107, alt: false, ctrl: true},
{code: 107, alt: true, ctrl: true}
], 'sendKeys() uses key modifiers');
}).run(function() {
test.done();
});
});
});
}
......
......@@ -52,26 +52,28 @@ casper.test.begin('utils.clone() tests', 2, function(test) {
test.done();
});
casper.test.begin('utils.computeModifier() tests', 7, function(test) {
var modifiers = require('webpage').create().event.modifier;
test.assertType(modifiers, "object");
test.assertEquals(utils.computeModifier("", modifiers), 0,
'computeModifier() computes a "none" modifier');
test.assertEquals(utils.computeModifier("alt", modifiers),
modifiers.alt,
'computeModifier() computes an "alt" modifier');
test.assertEquals(utils.computeModifier("ctrl+alt", modifiers),
modifiers.ctrl | modifiers.alt,
'computeModifier() computes a "ctrl+alt" modifier');
test.assertEquals(utils.computeModifier("ctrl+alt+shift", modifiers),
modifiers.ctrl | modifiers.alt | modifiers.shift,
'computeModifier() computes a "ctrl+alt+shift" modifier');
test.assertThrows(utils.computeModifier, ["chucknorris", modifiers],
'computeModifier() checks for a valid modifier');
test.assertThrows(utils.computeModifier, ["chuck+norris", modifiers],
'computeModifier() checks for a valid complex modifier');
test.done();
});
if (utils.gteVersion(phantom.version, '1.9.0')) {
casper.test.begin('utils.computeModifier() tests', 7, function(test) {
var modifiers = require('webpage').create().event.modifier;
test.assertType(modifiers, "object");
test.assertEquals(utils.computeModifier("", modifiers), 0,
'computeModifier() computes a "none" modifier');
test.assertEquals(utils.computeModifier("alt", modifiers),
modifiers.alt,
'computeModifier() computes an "alt" modifier');
test.assertEquals(utils.computeModifier("ctrl+alt", modifiers),
modifiers.ctrl | modifiers.alt,
'computeModifier() computes a "ctrl+alt" modifier');
test.assertEquals(utils.computeModifier("ctrl+alt+shift", modifiers),
modifiers.ctrl | modifiers.alt | modifiers.shift,
'computeModifier() computes a "ctrl+alt+shift" modifier');
test.assertThrows(utils.computeModifier, ["chucknorris", modifiers],
'computeModifier() checks for a valid modifier');
test.assertThrows(utils.computeModifier, ["chuck+norris", modifiers],
'computeModifier() checks for a valid complex modifier');
test.done();
});
}
casper.test.begin('equals() tests', 23, function(test) {
test.assert(utils.equals(null, null), 'equals() null equality');
......