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
@ -39,10 +39,10 @@ module.exports = function (grunt) {
|
|||||||
filesSrc : ['tests/integration/casperjs/*_test.js'],
|
filesSrc : ['tests/integration/casperjs/*_test.js'],
|
||||||
options : {
|
options : {
|
||||||
args : {
|
args : {
|
||||||
baseUrl : 'http://localhost:' + '<%= connect.www.options.port %>/?debug'
|
baseUrl : 'http://localhost:' + '<%= connect.www.options.port %>/'
|
||||||
},
|
},
|
||||||
direct : false,
|
direct : false,
|
||||||
logLevel : 'error',
|
logLevel : 'debug',
|
||||||
printCommand : false,
|
printCommand : false,
|
||||||
printFilePaths : true
|
printFilePaths : true
|
||||||
}
|
}
|
||||||
|
26
index.html
26
index.html
@ -121,29 +121,30 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
var loadScript = function (src, callback) {
|
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) {
|
if (window.location.href.indexOf("debug") != -1) {
|
||||||
window.exports = {};
|
window.exports = {};
|
||||||
loadScript("script-load-list.js", "loadDebugScripts()");
|
var scriptIndex = 0;
|
||||||
window.loadDebugScripts = function () {
|
window.loadNextScript = function () {
|
||||||
exports.scripts.forEach(function (script){
|
if (scriptIndex == exports.scripts.length) {
|
||||||
loadScript(script, "done()")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
var loaded = 0;
|
|
||||||
window.done = function () {
|
|
||||||
loaded ++;
|
|
||||||
if (loaded == exports.scripts.length) {
|
|
||||||
pskl.app.init();
|
pskl.app.init();
|
||||||
// cleanup
|
// cleanup
|
||||||
delete window.exports;
|
delete window.exports;
|
||||||
delete window.loadDebugScripts;
|
delete window.loadDebugScripts;
|
||||||
delete window.done;
|
delete window.done;
|
||||||
|
} else {
|
||||||
|
loadScript(exports.scripts[scriptIndex], "loadNextScript()");
|
||||||
|
scriptIndex ++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
loadScript("script-load-list.js", "loadNextScript()");
|
||||||
} else {
|
} else {
|
||||||
var script;
|
var script;
|
||||||
if (window.location.href.indexOf("pack") != -1) {
|
if (window.location.href.indexOf("pack") != -1) {
|
||||||
@ -154,7 +155,6 @@
|
|||||||
loadScript(script, "pskl.app.init()");
|
loadScript(script, "pskl.app.init()");
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -11,6 +11,19 @@ jQuery.namespace = function() {
|
|||||||
return o;
|
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
|
* @provide pskl.utils
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
casper
|
casper
|
||||||
.start(casper.cli.get('baseUrl'))
|
.start(casper.cli.get('baseUrl')+"?debug")
|
||||||
.then(function () {
|
.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');
|
this.test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created');
|
||||||
|
|
||||||
})
|
})
|
||||||
.run(function () {
|
.run(function () {
|
||||||
this.test.done();
|
this.test.done();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user