Skip to content

Commit 142f10c

Browse files
authored
Merge pull request #139 from Mifrill/fullscreen-viewport-broken-test
Fix test: resize viewport by fullscreen
2 parents 0262a15 + de26038 commit 142f10c

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

spec/browser_spec.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,25 @@ module Ferrum
8787
expect(browser.viewport_size).to eq([200, 400])
8888
end
8989

90-
it "allows the viewport to be resized by fullscreen" do
91-
browser.go_to("/ferrum/custom_html_size")
92-
expect(browser.viewport_size).to eq([1024, 768])
93-
browser.resize(fullscreen: true)
94-
expect(browser.viewport_size).to eq([1280, 1024])
90+
context 'fullscreen' do
91+
shared_examples 'resize viewport by fullscreen' do
92+
it "allows the viewport to be resized by fullscreen" do
93+
expect(browser.viewport_size).to eq([1024, 768])
94+
browser.go_to(path)
95+
browser.resize(fullscreen: true)
96+
expect(browser.viewport_size).to eq(viewport_size)
97+
end
98+
end
99+
100+
include_examples 'resize viewport by fullscreen' do
101+
let(:path) { "/ferrum/custom_html_size" }
102+
let(:viewport_size) { [1280, 1024] }
103+
end
104+
105+
include_examples 'resize viewport by fullscreen' do
106+
let(:path) { "/ferrum/custom_html_size_100%" }
107+
let(:viewport_size) { [1272, 1008] }
108+
end
95109
end
96110

97111
it "allows the page to be scrolled" do

spec/support/views/custom_html_size.erb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33
<title>custom_size</title>
44
<style>
55
html {
6-
width: 100%;
7-
height: 100%;
8-
}
9-
10-
.spacer {
11-
width: 1272px; /* using scrollWidth adds 8px */
12-
height: 1008px; /* using scrollHeight adds 16px */
6+
width: 1280px;
7+
height: 1024px;
138
}
149
</style>
1510
</head>
1611
<body>
17-
<div class="spacer"></div>
1812
</body>
1913
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<html>
2+
<head>
3+
<title>custom_size</title>
4+
<style>
5+
html {
6+
width: 100%;
7+
height: 100%;
8+
}
9+
10+
body {
11+
/*
12+
deal with the default Chrome margins
13+
https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/resources/html.css;
14+
*/
15+
margin: 0;
16+
}
17+
18+
.spacer {
19+
width: 1272px;
20+
height: 1008px;
21+
}
22+
</style>
23+
</head>
24+
<body>
25+
<div class="spacer"></div>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)