nathanboktae / mocha-phantomjs-core

Easiest way to run client-side Mocha tests in PhantomJS or SlimerJS :ghost:
MIT License
34 stars 11 forks source link

Handle failed iframe load #11

Closed ntkme closed 9 years ago

ntkme commented 9 years ago

This PR fix the problem where an aborted iframe load could cause mocha-phantomjs to fail.

PhantomJS intentionally calls page.onLoadFinished on iframe load and returns fail when iframe load is failed or aborted:

var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.src = "http://fail/";
Error loading resource http://fail/ (3). Details: Host fail not found
Failed to load the page. Check the url: test.html

This is just an extreme case that can be reproduce easily. In the real world, removing an iframe in loading from DOM (to speed up tests) could also trigger this problem.

mocha-phantomjs should keep running when iframe fails because test cases would fail as intended.

In short, page.onLoadFinished should be called only once on the test page itself.

nathanboktae commented 9 years ago

Thanks for the PR!