Skip to content

Commit caea758

Browse files
committed
Add spec for canceled requests
This adds a new page that makes a request to a slow endpoint and immediately cancels it. The spec checks that the network is idle afterwards.
1 parent 850f0ea commit caea758

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

spec/network_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ module Ferrum
6767
expect(browser.network.idle?).to be true
6868
end
6969

70+
it "captures canceled requests" do
71+
browser.go_to("/ferrum/with_ajax_connection_canceled")
72+
expect(browser.at_xpath("//h1[text() = 'Canceled']")).to be
73+
expect(browser.network.idle?).to be true
74+
end
75+
7076
it "keeps a running list between multiple web page views" do
7177
browser.go_to("/ferrum/with_js")
7278
expect(traffic.length).to eq(4)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
5+
<title>ferrum with_js</title>
6+
<script src="/ferrum/jquery.min.js" type="text/javascript" charset="utf-8"></script>
7+
</head>
8+
<body>
9+
<h1>Here</h1>
10+
<script>
11+
$.ajax("http://localhost:12345/slow_response").abort();
12+
$("h1").text("Canceled");
13+
</script>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)