Giter Site home page Giter Site logo

Comments (6)

jeffwatkins avatar jeffwatkins commented on July 29, 2024

I don't suppose you could post the test you're using? That would be helpful.

from jasmine-dom.

yushchenko avatar yushchenko commented on July 29, 2024

Tried to reproduce using small sample (test.js)

describe('jasmine-dom', function(){
    it('should load the fixture without errors', function() {
        loadFixtures('fixture.html');
    });
});

fixture.html content

<div id="testdiv">123</div>

Used URL file:///C:/home/projects/jasmine-dom-test/runner.html with for default jasmine test runner. Files runner.hml, test.js, feature.html are located in the same directory.

The test pass only in Safary and FF but in Chrome and IE8 it fails with error like that

NETWORK_ERR: NETWORK_ERR: XMLHttpRequest Exception 101

As i now understand it shouldn't work in any browser because jasmine-dom uses XHR to get a fixture so a web server is must...

In fact, even in Safary and FF adding check, if the fixture has been loaded, broke the test:

    it('should load the fixture without errors', function() {
        loadFixtures('fixture.html');
        var div = document.getElementById('testdiv');
        expect(div).toHaveId('testdiv');
    });

So loadFixtures doesn't load html into DOM, just not throws an exception in these browsers... looks a bit inconsistent...

Obvious work around - use web server, but sometimes it would be very convenient just click on runner.html and get test results.

I'm not sure but loading markup using iframe should work with such file://... URLs.

from jasmine-dom.

jeffwatkins avatar jeffwatkins commented on July 29, 2024

Thanks for digging into that. I'll see what I can do. I know I use XHR with file URLs all the time, so there must be more to it.

from jasmine-dom.

jeffwatkins avatar jeffwatkins commented on July 29, 2024

Chrome has a bug that prevents XHR from loading anything when loaded from a file URL. Based on the discussions on the ticket, this is unlikely to change any time soon.

However, I believe I've fixed this for the other browsers. I've tested this now for Firefox and Safari on my Mac and it worked fine. Please let me know if you have trouble with IE. In Firefox, the XHR was never calling the onreadystatechange callback, because the request was synchronous.

from jasmine-dom.

xiongchiamiov avatar xiongchiamiov commented on July 29, 2024

It should be noted that, according to the previously-linked discussion, this should work if you launch Chrome with the --allow-file-access-from-files flag.

You might want to add this information to the README.

from jasmine-dom.

jeffwatkins avatar jeffwatkins commented on July 29, 2024

Updated README.

from jasmine-dom.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.