Commit 2c9547ab 2c9547ab025cc31b1cccdbc08485e1e9b677662d by Nicolas Perriault

fixes #565 - undefined response when unicode URL

1 parent 7a83beaf
...@@ -1151,7 +1151,7 @@ Casper.prototype.handleReceivedResource = function(resource) { ...@@ -1151,7 +1151,7 @@ Casper.prototype.handleReceivedResource = function(resource) {
1151 return; 1151 return;
1152 } 1152 }
1153 this.resources.push(resource); 1153 this.resources.push(resource);
1154 if (resource.url !== this.requestUrl) { 1154 if (resource.url !== this.requestUrl && decodeURIComponent(resource.url) !== this.requestUrl) {
1155 return; 1155 return;
1156 } 1156 }
1157 this.currentHTTPStatus = null; 1157 this.currentHTTPStatus = null;
......
1 casper.test.begin "resources tests", 5, (test) ->
2 casper.start "tests/site/resources.html", ->
3 test.assertEquals @resources.length, 1, "only one resource found"
4
5 onTime = ->
6 test.assertEquals(
7 @resources.length
8 2
9 "two resources found"
10 )
11 test.assertResourceExists(
12 /dummy\.js/i
13 "phantom image found via test RegExp"
14 )
15 test.assertResourceExists(
16 (res) -> res.url.match "dummy.js"
17 "phantom image found via test Function"
18 )
19 test.assertResourceExists(
20 "dummy.js"
21 "phantom image found via test String"
22 )
23
24 onTimeout = -> test.fail "waitForResource timeout occured"
25
26 @waitForResource "dummy.js", onTime, onTimeout
27
28 casper.run(-> test.done())
1 /*global casper*/
2 /*jshint strict:false*/
3 casper.test.begin("Basic resources tests", 5, function(test) {
4 casper.start("tests/site/resources.html", function() {
5 test.assertEquals(this.resources.length, 1, "only one resource found");
6 });
7
8 casper.waitForResource("dummy.js", function() {
9 test.assertEquals(this.resources.length, 2, "two resources found");
10 test.assertResourceExists(/dummy\.js/i, "phantom image found via test RegExp");
11 test.assertResourceExists(function(res) {
12 return res.url.match("dummy.js");
13 }, "phantom image found via test Function");
14 test.assertResourceExists("dummy.js", "phantom image found via test String");
15 }, function onTimeout() {
16 test.fail("waitForResource timeout occured");
17 });
18
19 casper.run(function() {
20 test.done();
21 });
22 });