1
1
mirror of https://github.com/ariya/phantomjs.git synced 2024-10-26 14:29:13 +03:00
phantomjs/test/regression/pjs-12482.js
Zack Weinberg 9eb781f82d Reformat all individual tests' output as TAP.
This enables run-tests.py to parse it and produce structured,
pretty output.  A couple of latent failures were exposed and
marked expected (having to do with control passing beyond
phantom.exit()).

TAP: http://testanything.org/tap-specification.html

Part of issue #13478 (test suite overhaul).
2015-10-20 17:11:36 -04:00

49 lines
1.2 KiB
JavaScript

//! no-harness
// https://github.com/ariya/phantomjs/issues/12482
// regression caused by fix for
// https://github.com/ariya/phantomjs/issues/12431
var webpage = require('webpage');
var sys = require('system');
var pages = [
webpage.create(),
webpage.create(),
webpage.create()
];
var loaded = 0;
sys.stdout.write("1.." + pages.length + "\n");
setTimeout(function () { phantom.exit(1); }, 200);
function loadHook (status) {
loaded++;
if (status === "success") {
sys.stdout.write("ok " + loaded + " loading page\n");
} else {
sys.stdout.write("not ok " + loaded + " loading page\n");
}
if (loaded === pages.length) {
pages[1].close();
setTimeout(function(){
phantom.exit(0);
sys.stdout.write("not ok " + (pages.length+1) +
" should not get here # TODO\n");
}, 50);
}
}
function consoleHook (msg) {
sys.stdout.write(msg + "\n");
}
for (var i = 0; i < pages.length; i++) {
pages[i].onConsoleMessage = consoleHook;
pages[i].open(
"data:text/html,<script>setTimeout(function(){console.log("+
"'not ok "+(i+pages.length+2)+" page survived');},100)</script>",
loadHook);
}