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) { ...@@ -18,24 +18,26 @@ casper.test.begin('sendKeys() tests', 3, function(test) {
18 }); 18 });
19 }); 19 });
20 20
21 casper.test.begin('sendKeys() key modifiers tests', 1, function(test) { 21 if (utils.gteVersion(phantom.version, '1.9.0')) {
22 casper.start().then(function() { 22 casper.test.begin('sendKeys() key modifiers tests', 1, function(test) {
23 this.setContent([ 23 casper.start().then(function() {
24 '<input>', 24 this.setContent([
25 '<script>var keys = []; window.addEventListener("keypress", function(e) {', 25 '<input>',
26 ' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});', 26 '<script>var keys = []; window.addEventListener("keypress", function(e) {',
27 '})</script>' 27 ' keys.push({code: e.which, alt: e.altKey, ctrl: e.ctrlKey});',
28 ].join('')); 28 '})</script>'
29 this.sendKeys('input', 'k'); 29 ].join(''));
30 this.sendKeys('input', 'k', {modifiers: "ctrl"}); 30 this.sendKeys('input', 'k');
31 this.sendKeys('input', 'k', {modifiers: "ctrl+alt"}); 31 this.sendKeys('input', 'k', {modifiers: "ctrl"});
32 test.assertEquals(this.getGlobal('keys'), 32 this.sendKeys('input', 'k', {modifiers: "ctrl+alt"});
33 [ 33 test.assertEquals(this.getGlobal('keys'),
34 {code: 107, alt: false, ctrl: false}, 34 [
35 {code: 107, alt: false, ctrl: true}, 35 {code: 107, alt: false, ctrl: false},
36 {code: 107, alt: true, ctrl: true} 36 {code: 107, alt: false, ctrl: true},
37 ], 'sendKeys() uses key modifiers'); 37 {code: 107, alt: true, ctrl: true}
38 }).run(function() { 38 ], 'sendKeys() uses key modifiers');
39 test.done(); 39 }).run(function() {
40 test.done();
41 });
40 }); 42 });
41 }); 43 }
......
...@@ -52,26 +52,28 @@ casper.test.begin('utils.clone() tests', 2, function(test) { ...@@ -52,26 +52,28 @@ casper.test.begin('utils.clone() tests', 2, function(test) {
52 test.done(); 52 test.done();
53 }); 53 });
54 54
55 casper.test.begin('utils.computeModifier() tests', 7, function(test) { 55 if (utils.gteVersion(phantom.version, '1.9.0')) {
56 var modifiers = require('webpage').create().event.modifier; 56 casper.test.begin('utils.computeModifier() tests', 7, function(test) {
57 test.assertType(modifiers, "object"); 57 var modifiers = require('webpage').create().event.modifier;
58 test.assertEquals(utils.computeModifier("", modifiers), 0, 58 test.assertType(modifiers, "object");
59 'computeModifier() computes a "none" modifier'); 59 test.assertEquals(utils.computeModifier("", modifiers), 0,
60 test.assertEquals(utils.computeModifier("alt", modifiers), 60 'computeModifier() computes a "none" modifier');
61 modifiers.alt, 61 test.assertEquals(utils.computeModifier("alt", modifiers),
62 'computeModifier() computes an "alt" modifier'); 62 modifiers.alt,
63 test.assertEquals(utils.computeModifier("ctrl+alt", modifiers), 63 'computeModifier() computes an "alt" modifier');
64 modifiers.ctrl | modifiers.alt, 64 test.assertEquals(utils.computeModifier("ctrl+alt", modifiers),
65 'computeModifier() computes a "ctrl+alt" modifier'); 65 modifiers.ctrl | modifiers.alt,
66 test.assertEquals(utils.computeModifier("ctrl+alt+shift", modifiers), 66 'computeModifier() computes a "ctrl+alt" modifier');
67 modifiers.ctrl | modifiers.alt | modifiers.shift, 67 test.assertEquals(utils.computeModifier("ctrl+alt+shift", modifiers),
68 'computeModifier() computes a "ctrl+alt+shift" modifier'); 68 modifiers.ctrl | modifiers.alt | modifiers.shift,
69 test.assertThrows(utils.computeModifier, ["chucknorris", modifiers], 69 'computeModifier() computes a "ctrl+alt+shift" modifier');
70 'computeModifier() checks for a valid modifier'); 70 test.assertThrows(utils.computeModifier, ["chucknorris", modifiers],
71 test.assertThrows(utils.computeModifier, ["chuck+norris", modifiers], 71 'computeModifier() checks for a valid modifier');
72 'computeModifier() checks for a valid complex modifier'); 72 test.assertThrows(utils.computeModifier, ["chuck+norris", modifiers],
73 test.done(); 73 'computeModifier() checks for a valid complex modifier');
74 }); 74 test.done();
75 });
76 }
75 77
76 casper.test.begin('equals() tests', 23, function(test) { 78 casper.test.begin('equals() tests', 23, function(test) {
77 test.assert(utils.equals(null, null), 'equals() null equality'); 79 test.assert(utils.equals(null, null), 'equals() null equality');
......