Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Handle multiple onLoadFinished callbacks with no-op #24

merged 3 commits into from

4 participants


My jasmine test suite make heavy use of iframes, and I've seen that the onLoadFinished callback gets invoked multiple times during the course of the suite run, once for the main page and again for iframes. Sometimes one of these frames fails (possibly due to a dummy or null src?) and it causes the phantom proc to exit in this function. With this code in place my suite runs to completion successfully.

I found a similar fix committed in guard-jasmine a while back: guard/guard-jasmine#19


+1 this is very important for a project that we are using grunt-lib-phantomjs


@jaredstehler-cengage one thing you will have to do is update the package.json to 0.0.4 since the 0.0.3 is already realeased

@jsoverson jsoverson merged commit 27bd696 into gruntjs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 3, 2013
  1. @jaredstehler-cengage
Commits on Aug 5, 2013
  1. @jaredstehler

    Merge pull request #1 from gruntjs/master

    jaredstehler authored
    pulling latest master
  2. @jaredstehler

    bumping version

    jaredstehler authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +1 −1  package.json
  2. +3 −0  phantomjs/main.js
2  package.json
@@ -1,7 +1,7 @@
"name": "grunt-lib-phantomjs",
"description": "Grunt and PhantomJS, sitting in a tree.",
- "version": "0.3.0",
+ "version": "0.4.0",
"homepage": "",
"author": {
"name": "Grunt Team",
3  phantomjs/main.js
@@ -118,6 +118,9 @@ page.onInitialized = function() {
// Run when the page has finished loading.
page.onLoadFinished = function(status) {
+ // reset this handler to a no-op so further calls to onLoadFinished from iframes don't affect us
+ page.onLoadFinished = function() { /* no-op */}
// The window has loaded.
sendMessage('onLoadFinished', status);
if (status !== 'success') {
Something went wrong with that request. Please try again.