Proxies in Karma config + Uncaught SecurityError: Blocked a frame with origin...

2,100 views
Skip to first unread message

per.ro...@factor10.com

unread,
Oct 8, 2013, 3:27:43 PM10/8/13
to karma...@googlegroups.com
I'm attempting to run Angular E2E tests using Karma. My application server is running on http://localhost:8000. In my karma-e2e.conf.js, I have:

proxies: {
  '/': 'http://localhost:8000'
},
// URL root prevent conflicts with the site root
urlRoot: '_karma_'

Despite this, when I run using karma start karma-e2e.conf.js, I get:

Uncaught SecurityError: Blocked a frame with origin "http://localhost:9876" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
at http://localhost:9876/base/node_modules/karma-ng-scenario/lib/adapter.js?1381257827000:43

I'm using Chrome 30.0.1599.69.

What am I missing?

Thanks,
Per

Vojta Jína

unread,
Oct 12, 2013, 9:32:58 PM10/12/13
to karma...@googlegroups.com
Arent' you navigating to "http://localhost:8000/x" in your specs?
You should use relative paths, like `browser().navigateTo('/index.html');

Isn't there any redirect? Like your webserver returns 303 to http://localhost:8000/x ?
The proxy should handle that though.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/karma-users/3d67c51e-fbec-48c9-98a5-01a44181beaf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Message has been deleted

Per Rovegård

unread,
Oct 13, 2013, 5:09:07 PM10/13/13
to karma...@googlegroups.com
This is my spec:

describe("E2E Tests", function() {
        beforeEach(function() {
                browser().navigateTo('/');
        });

        it('should navigate to somewhere fancy', function() {
                var emailCount = element("#email").count();
                expect(emailCount).toBe(1);
        });
});

The root request (/) is redirected to http://localhost:8000/app/index.html (absolute URI), and if I turn off singleRun and keep Chrome open I can see in the network pane that Chrome fetches /app/index.html and the contents referenced from it (CSS, images).

What can I do to debug further?

Thanks,
Per

Vojta Jína

unread,
Oct 13, 2013, 5:59:17 PM10/13/13
to karma...@googlegroups.com
Yep, I think the redirect is the problem.

I thought this was fixed, but it's not. We need to get this PR merged into http-proxy:

V.


Per Rovegård

unread,
Nov 18, 2013, 6:21:00 PM11/18/13
to karma...@googlegroups.com
Indeed! I applied the changes from that PR to the latest node-http-proxy, and then added support for 303 responses. Then I just replaced Karma's node_modules/http_proxy with my custom one, and it started working!


Thanks for the pointer!

Per
Reply all
Reply to author
Forward
0 new messages