forked from forwardemail/superagent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.xdomain.js
More file actions
34 lines (28 loc) · 830 Bytes
/
test.xdomain.js
File metadata and controls
34 lines (28 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var assert = require('assert');
var request = require('../');
test('req.withCredentials()', function(next){
// we force port 80 here when we don't know
// this works on localhost testing cause we have a port
// but on regular localtunnel.me we don't
// and since localtunnel.me loads over https, port 80
// becomes cross domain
var port = window.location.port || 80;
var hostname = window.location.hostname;
request
.get('http://' + hostname + ':' + port + '/xdomain')
.withCredentials()
.end(function(res){
assert(200 == res.status);
assert('tobi' == res.text);
next();
})
})
test('x-domain failure', function(next){
request
.get('http://google.com')
.end(function(err, res){
assert(err, 'error missing');
assert(err.crossDomain, 'not .crossDomain');
next();
});
});