mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
added Function.prototype.bind polyfill for PhantomJS. Make Casper happy.
This commit is contained in:
parent
8acd91b4d9
commit
a16e1bab09
14
Gruntfile.js
14
Gruntfile.js
@ -14,11 +14,11 @@ module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
jshint : {
|
||||
/*options: {
|
||||
"evil": true,
|
||||
"asi": true,
|
||||
"smarttabs": true,
|
||||
"eqnull": true
|
||||
},*/
|
||||
"evil": true,
|
||||
"asi": true,
|
||||
"smarttabs": true,
|
||||
"eqnull": true
|
||||
},*/
|
||||
files : [
|
||||
'Gruntfile.js',
|
||||
'package.json',
|
||||
@ -39,10 +39,10 @@ module.exports = function (grunt) {
|
||||
filesSrc : ['tests/integration/casperjs/*_test.js'],
|
||||
options : {
|
||||
args : {
|
||||
baseUrl : 'http://localhost:' + '<%= connect.www.options.port %>/?debug'
|
||||
baseUrl : 'http://localhost:' + '<%= connect.www.options.port %>/'
|
||||
},
|
||||
direct : false,
|
||||
logLevel : 'error',
|
||||
logLevel : 'debug',
|
||||
printCommand : false,
|
||||
printFilePaths : true
|
||||
}
|
||||
|
26
index.html
26
index.html
@ -121,29 +121,30 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
|
||||
var loadScript = function (src, callback) {
|
||||
document.write('<scr'+'ipt src ="'+src+'" onload="'+callback+'"></sc'+'ript>');
|
||||
var script = window.document.createElement('script');
|
||||
script.setAttribute('src',src);
|
||||
script.setAttribute('onload',callback);
|
||||
window.document.body.appendChild(script);
|
||||
};
|
||||
|
||||
if (window.location.href.indexOf("debug") != -1) {
|
||||
window.exports = {};
|
||||
loadScript("script-load-list.js", "loadDebugScripts()");
|
||||
window.loadDebugScripts = function () {
|
||||
exports.scripts.forEach(function (script){
|
||||
loadScript(script, "done()")
|
||||
})
|
||||
}
|
||||
var loaded = 0;
|
||||
window.done = function () {
|
||||
loaded ++;
|
||||
if (loaded == exports.scripts.length) {
|
||||
var scriptIndex = 0;
|
||||
window.loadNextScript = function () {
|
||||
if (scriptIndex == exports.scripts.length) {
|
||||
pskl.app.init();
|
||||
// cleanup
|
||||
delete window.exports;
|
||||
delete window.loadDebugScripts;
|
||||
delete window.done;
|
||||
} else {
|
||||
loadScript(exports.scripts[scriptIndex], "loadNextScript()");
|
||||
scriptIndex ++;
|
||||
}
|
||||
};
|
||||
|
||||
loadScript("script-load-list.js", "loadNextScript()");
|
||||
} else {
|
||||
var script;
|
||||
if (window.location.href.indexOf("pack") != -1) {
|
||||
@ -154,7 +155,6 @@
|
||||
loadScript(script, "pskl.app.init()");
|
||||
}
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -11,6 +11,19 @@ jQuery.namespace = function() {
|
||||
return o;
|
||||
};
|
||||
|
||||
/**
|
||||
* Need a polyfill for PhantomJS
|
||||
*/
|
||||
if (typeof Function.prototype.bind !== "function") {
|
||||
Function.prototype.bind = function(scope) {
|
||||
"use strict";
|
||||
var _function = this;
|
||||
return function() {
|
||||
return _function.apply(scope, arguments);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* @provide pskl.utils
|
||||
*
|
||||
|
@ -1,8 +1,12 @@
|
||||
casper
|
||||
.start(casper.cli.get('baseUrl'))
|
||||
.then(function () {
|
||||
this.test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created');
|
||||
})
|
||||
.run(function () {
|
||||
this.test.done();
|
||||
});
|
||||
.start(casper.cli.get('baseUrl')+"?debug")
|
||||
.then(function () {
|
||||
// If there was a JS error after the page load, casper won't perform asserts
|
||||
this.test.assertExists('html', 'Casper JS cannot assert DOM elements. A JS error has probably occured.');
|
||||
|
||||
this.test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created');
|
||||
|
||||
})
|
||||
.run(function () {
|
||||
this.test.done();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user