johnbintz/jasmine-headless-webkit — Issue #92: IFRAME src can't be set when running through jasmine-headless-webkit
Author: kevinrobinson
Created: 2011-12-06 22:17:07+00:00
State: open

I'm trying to use Jasmine to do full integration testing. So in the beforeEach() we add an IFRAME to the page, set its src to my full app and then the Jasmine specs can work as integration tests in this way. In this case it just checks that there is an element #email on the page. This works great in the browser (Chrome). Here's an example spec:

```javascript
describe("UI", function() {
it('mooooooooo', function() {
//since the Jasmine server and the full app are running on different ports
document.domain = document.domain;

var sandboxWindow = null;
var sandboxDocument = null;
var sandboxLoaded = false;
var $iframe = $('');
var testPageURL = 'http://domain.com:7080/signin';

runs(function() {
$iframe.attr('src', testPageURL);
$iframe.load(function() {
sandboxWindow = $iframe[0].contentWindow;
sandboxDocument = $iframe[0].contentDocument;
sandboxLoaded = true;
});
$('body').append($iframe);
});

waitsFor(function() {
return sandboxLoaded;
}, "iframe did not load", 10000);

runs(function() {
expect(sandboxWindow.$(sandboxDocument).find('#email').length).toEqual(1);
})
});
});
```

And this works great in Chrome. The problem is that this throws an error when running the same spec through jasmine-headless-webkit (on Red Hat). It says:

$ jasmine-headless-webkit

Running Jasmine specs...
........................Can't load file:///home/username/project/jhw.13792.html, the file may be broken.
Out of curiosity, did your tests try to submit a form and you haven't prevented that?
Try running your tests in your browser with the Jasmine server and see what happens.

Test ordering seed: --seed 596

I figure this is because of differences between QtWebkit and Chrome and I know what I'm doing is stretching the bounds a little. But it would be great if we can write integration tests this way because then they can be written in Javascript and Jasmine and be debugged in Web Inspector. It just seems like a better solution than using something like Capybara where there's a DSL and Ruby layer on top of what I really want to do, which is write my tests in Javascript, Jasmine-style.

I found this post http://distillations.2rye.com/2011/11/jasmine-headless-vs-in-browser/! which mentions the same problem and concludes they just can't run these kinds of tests headlessly. And while this is helpful and a decent workaround, it means this approach won't really work for CI. I don't know enough about how this works under the hood or the internals of QtWebkit so not really sure where to even start looking into this.

Any thoughts?

Thanks,
Kevin