2008-03-07 06:54:41 -08:00
|
|
|
var listener = {
|
2009-09-16 03:21:19 -07:00
|
|
|
testFunction: null,
|
|
|
|
|
|
|
|
handleEvent: function (e) {
|
2008-03-07 06:54:41 -08:00
|
|
|
this.testFunction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tests for correct behaviour of getEffectiveHost on identity handler */
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
2009-09-16 03:21:19 -07:00
|
|
|
|
2008-03-07 06:54:41 -08:00
|
|
|
ok(gIdentityHandler, "gIdentityHandler should exist");
|
2009-09-16 03:21:19 -07:00
|
|
|
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.selectedBrowser.addEventListener("load", listener, true);
|
2008-03-07 06:54:41 -08:00
|
|
|
listener.testFunction = testNormalDomain;
|
2009-09-16 03:21:19 -07:00
|
|
|
content.location = "http://test1.example.org/";
|
2008-03-07 06:54:41 -08:00
|
|
|
}
|
|
|
|
|
2010-08-27 08:12:02 -07:00
|
|
|
// Greek IDN for 'example.test'.
|
|
|
|
var idnDomain = "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE";
|
|
|
|
|
2008-03-07 06:54:41 -08:00
|
|
|
function testNormalDomain() {
|
|
|
|
is(gIdentityHandler._lastLocation.host, 'test1.example.org', "Identity handler is getting the full location");
|
|
|
|
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for test1.example.org");
|
2009-09-16 03:21:19 -07:00
|
|
|
|
2010-08-27 08:12:02 -07:00
|
|
|
listener.testFunction = testIDNDomain;
|
|
|
|
content.location = "http://sub1." + idnDomain + "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIDNDomain() {
|
|
|
|
is(gIdentityHandler._lastLocation.host, "sub1." + idnDomain, "Identity handler is getting the full location");
|
|
|
|
is(gIdentityHandler.getEffectiveHost(), idnDomain, "getEffectiveHost should return the IDN base domain in UTF-8");
|
|
|
|
|
2008-03-07 06:54:41 -08:00
|
|
|
listener.testFunction = testNormalDomainWithPort;
|
2009-09-16 03:21:19 -07:00
|
|
|
content.location = "http://sub1.test1.example.org:8000/";
|
2008-03-07 06:54:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNormalDomainWithPort() {
|
|
|
|
is(gIdentityHandler._lastLocation.host, 'sub1.test1.example.org:8000', "Identity handler is getting port information");
|
|
|
|
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for sub1.test1.example.org:8000");
|
2009-09-16 03:21:19 -07:00
|
|
|
|
2008-03-07 06:54:41 -08:00
|
|
|
listener.testFunction = testIPWithPort;
|
2009-09-16 03:21:19 -07:00
|
|
|
content.location = "http://127.0.0.1:8888/";
|
2008-03-07 06:54:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testIPWithPort() {
|
|
|
|
is(gIdentityHandler.getEffectiveHost(), '127.0.0.1', "getEffectiveHost should return 127.0.0.1 for 127.0.0.1:8888");
|
2009-09-16 03:21:19 -07:00
|
|
|
gBrowser.selectedBrowser.removeEventListener("load", listener, true);
|
2008-03-07 06:54:41 -08:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|