Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:40:49+00:00 2026-06-17T04:40:49+00:00

Anyone know why the following unit test does not pass? describe(just a test, function

  • 0

Anyone know why the following unit test does not pass?

describe("just a test", function () {
    it("should set the iframe location", function () {

        $('body').append('<iframe id="myiframe" name="myiframe"</iframe>');

        expect(window['myiframe'].location.href).toEqual('about:blank');

        window['myiframe'].location.assign('about:history');
        expect(window['myiframe'].location.href).toEqual('about:history');
    });
});

This is just simplified code to try and find out why a real test does not work – I’m not bothered about cleaning up or anything.

The second expect fails. Is there a reason why changing the iframe location like this should not work?

(I am running the test with Chutzpah v1.4.2, both with the Visual Studio add in and from the command line.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:40:50+00:00Added an answer on June 17, 2026 at 4:40 am

    There are many reasons for this test to fail:

    • Trying to load ‘about:history’ in an <iframe> tag will cause an exception at least in both Firefox and Chrome (and will probably do so in PhantomJS’s under Chutzpah).
    • Trying to load a different domain other than where jasmine is running will not work because you can’t access the href property anymore. This is due to the browser’s cross-domain security restrictions; Firefox says ‘Error: Permission denied to access property 'href'‘, and Chrome says ‘Unsafe JavaScript attempt to access frame with URL‘. The frame would display properly tough.
    • Even if you load an URL that is in the same domain as the testRunner, the href will not reflect that change immediately, the second expect will fail (href will still equal ‘about:blank’) until the iframe has loaded, wich is way after your test already executed.

    The following modified code uses Jasmine waitsFor() and runs() to account for the last problem. It will wait for 1000ms for the condition to be met, allowing the iframe to finish loading. I left your original spec inside the wait() block, however the waitsFor will also fail if there is a timeout.

    describe("just a test", function () {
      it("should set the iframe location", function () {
        $('body').append('<iframe id="myiframe" name="myiframe"</iframe>');
        expect(window['myiframe'].location.href).toEqual('about:blank');
    
        window['myiframe'].location.assign('about:');
    
        waitsFor(function(){
          return window['myiframe'].location.href == 'about:'
        },1000);
        runs(function(){
          expect(window['myiframe'].location.href).toEqual('about:');
        });
      });
    });
    

    Note that I also used ‘about:’ (withouth the ‘blank’), as is the only -other- URL I know that won’t throw an exception. However, it would be a good idea to use something else, maybe a pair of static fixture files in the same domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a solution to the following markup validation error? I'm not
Does anyone know why the following code does not work in FireFox but does
Does anyone know why my ListView with following Code is not working? I checked
Does anyone know how to make the following Matlab code approximate the exponential function
Does anyone know how to test Mongoose Validations? Example, I have the following Schema
does anyone know if the following java Method in the java.util.concurrent Package ScheduledExecutorService.html#scheduleAtFixedRate() absolutely
Does anyone know why the following query fails in Derby? delete from MyTable where
Does anyone know why the following random distributions of matrices generate different plots? (This
Question says it all. Does anyone know if the following... size_t div(size_t value) {
Does anyone know how to write the following in a neater, one line format?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.