check if using a proxy is required, and if so, issue a warning if none is configured. p=fvanderbiest,me r=me (closes #3015)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11038 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+14
-5
@@ -319,7 +319,7 @@
|
||||
}
|
||||
|
||||
function test_ProxyHost(t) {
|
||||
t.plan(4);
|
||||
t.plan(5);
|
||||
|
||||
/*
|
||||
* Setup
|
||||
@@ -334,6 +334,7 @@
|
||||
var proto = OpenLayers.Request.XMLHttpRequest.prototype;
|
||||
var _open = proto.open;
|
||||
var log = [];
|
||||
var port;
|
||||
proto.open = function(method, url, async, user, password) {
|
||||
log.push(url);
|
||||
};
|
||||
@@ -349,9 +350,17 @@
|
||||
OpenLayers.Request.GET({url: "http://bar?k1=v1&k2=v2"});
|
||||
t.eq(log.length, 1, "[1] XHR.open called once");
|
||||
t.eq(log[0], expectedURL, "[1] the URL used for XHR is correct (" + log[0] + ")");
|
||||
|
||||
|
||||
// 1 test
|
||||
log = [];
|
||||
OpenLayers.ProxyHost = "http://fooproxy/?url=";
|
||||
port = window.location.port ? ':'+window.location.port : '';
|
||||
expectedURL = window.location.protocol+"//"+window.location.hostname+port+"/service";
|
||||
OpenLayers.Request.GET({url: expectedURL});
|
||||
t.eq(log[0], expectedURL, "[2] proxy is not used when requesting the same server");
|
||||
|
||||
// 2 tests
|
||||
log = []
|
||||
log = [];
|
||||
OpenLayers.ProxyHost = function(url) {
|
||||
var p = OpenLayers.Util.getParameters(url);
|
||||
var p = OpenLayers.Util.getParameterString(p);
|
||||
@@ -359,8 +368,8 @@
|
||||
};
|
||||
expectedURL = "http://barproxy/?k1=v1&k2=v2";
|
||||
OpenLayers.Request.GET({url: "http://bar?k1=v1&k2=v2"});
|
||||
t.eq(log.length, 1, "[2] XHR.open called once");
|
||||
t.eq(log[0], expectedURL, "[2] the URL used for XHR is correct (" + log[0] + ")");
|
||||
t.eq(log.length, 1, "[3] XHR.open called once");
|
||||
t.eq(log[0], expectedURL, "[3] the URL used for XHR is correct (" + log[0] + ")");
|
||||
|
||||
/*
|
||||
* Teardown
|
||||
|
||||
Reference in New Issue
Block a user