3 require("client-redirect");
6 suite_setup: function () {
7 this.real_redirects = client_redirect.redirects;
8 client_redirect.redirects = {};
9 define_client_redirect("r1",
11 return /^example\.com$/.test(uri.host)
12 && uri.filePath == "/foo"
15 define_client_redirect("r2",
16 build_url_regexp($domain = "example", $allow_www,
19 return "http://example.com/"+m[1]+"/"+m[1];
22 suite_teardown: function () {
23 client_redirect.redirects = this.real_redirects;
25 test_client_redirect_1: function () {
26 var uri = make_uri("http://not-example.com/foo")
27 .QueryInterface(Ci.nsIURL);
28 assert_not(client_redirect.redirects.r1(uri));
30 test_client_redirect_2: function () {
31 var uri = make_uri("http://example.com/")
32 .QueryInterface(Ci.nsIURL);
33 assert_not(client_redirect.redirects.r1(uri));
35 test_client_redirect_3: function () {
36 var uri = make_uri("http://example.com/foo")
37 .QueryInterface(Ci.nsIURL);
38 assert_equals(client_redirect.redirects.r1(uri),
39 "http://example.com/foo/bar");
41 test_client_redirect_4: function () {
42 var uri = make_uri("http://example.com/")
43 .QueryInterface(Ci.nsIURL);
44 assert_not(client_redirect.redirects.r2(uri));
46 test_client_redirect_5: function () {
47 var uri = make_uri("http://example.com/foo")
48 .QueryInterface(Ci.nsIURL);
49 assert_equals(client_redirect.redirects.r2(uri),
50 "http://example.com/foo/foo");