e2e karma runner results in cross-origin frame error despite proxy

979 views
Skip to first unread message

Adam St. John

unread,
Feb 19, 2014, 8:00:49 PM2/19/14
to ang...@googlegroups.com
Hi all,

I'm hoping someone can help me out as I'm exhausted. I am trying to set up a karma runner for e2e tests using a Rails backend. My karma config is something like the following:

    basePath : '../../',
    files : [
        'test/karma/scenarios/*.js'
    ],
    autoWatch : false,
    browsers : ['Chrome'],
    frameworks: ['ng-scenario'],
    singleRun : true,
    proxies : {
      '/': 'http://localhost:3000/'
    },
    plugins : [
            'karma-junit-reporter',
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-jasmine',
            'karma-ng-scenario'
            ],
    junitReporter : {
      outputFile: 'test_out/e2e.xml',
      suite: 'e2e'
    }

Karma launches fine and everything works for a test navigating to the root of the project. The problem occurs when we navigate to any other path such as "browser().navigateTo('partner/');"

At this point, the page loads for a split second and then karma and the browser choke with the following error:

Uncaught SecurityError: Blocked a frame with origin "http://localhost:9876" from accessing a cross-origin frame.

Any help or insight is greatly appreciated!

Thanks,
Adam 

Sean Amoroso

unread,
Feb 24, 2014, 11:15:13 AM2/24/14
to ang...@googlegroups.com
Have you figured this one out yet?  I'm encountering the same error and don't seem to be finding a solution.

In our application we use System.IdentityModel authentication so I need the redirect to login then come back to my application.

Adam St. John

unread,
Feb 24, 2014, 11:56:06 AM2/24/14
to ang...@googlegroups.com
Unfortunately, no, not yet.

-Adam


On Feb 24, 2014, at 11:15 AM, Sean Amoroso <seana...@gmail.com> wrote:

Have you figured this one out yet?  I'm encountering the same error and don't seem to be finding a solution.

In our application we use System.IdentityModel authentication so I need the redirect to login then come back to my application.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/VeqlVgUa6Wo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Sean Amoroso

unread,
Feb 24, 2014, 4:57:28 PM2/24/14
to ang...@googlegroups.com
I added this to my karma-e2e.conf.js file.  It's basically a hack to use chrome without web security:

    config.set({
        browsers: ['chrome_without_security'],
        customLaunchers: {
            chrome_without_security: {
                base: 'Chrome',
                flags: ['--disable-web-security']
            }
        }
    });

It works for me and is good enough for what I needed it for.  I saw some suggestions to use Protractor and I did get that up and running but didn't get all the syntax down enough.

Brett McBee-Wise

unread,
Feb 18, 2015, 5:56:57 PM2/18/15
to ang...@googlegroups.com
I had this exact same issue. For me it turned out that I had switched booting my app from

<html ng-app="myApp">

to:

angular.bootstrap(angular.element('html'),'myApp');

Apparently Karma doesn't support this and I was getting the cross domain issue you have noted. Karma uses the attribute as a way of defining the root element for the tests so because the attribute doesn't exist anymore Karma half way runs and fails.  The solution is hacky:

First apply the attribute to the html this will be applied after angular has loaded so it won't cause the app to boot. Then you do the manual bootstrap of the app.  You get no double boot and Karma is then happy.

$('html').attr("ng-app", "myApp");
angular.bootstrap(angular.element('html'),'myApp');
Reply all
Reply to author
Forward
Message has been deleted
0 new messages