1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* This test ensures the overlay is covering the entire window event thought
* the body is smaller than the viewport
*/
add_task(async function test_overlay() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: SHORT_TEST_PAGE,
},
async browser => {
let helper = new ScreenshotsHelper(browser);
let contentInfo = await helper.getContentDimensions();
ok(contentInfo, "Got dimensions back from the content");
helper.triggerUIFromToolbar();
await helper.waitForOverlay();
await helper.dragOverlay(10, 10, 500, 500);
let { scrollWidth, scrollHeight } =
await helper.getScreenshotsOverlayDimensions();
Assert.equal(
scrollWidth,
contentInfo.clientWidth,
"The overlay spans the width of the window"
);
Assert.equal(
scrollHeight,
contentInfo.clientHeight,
"The overlay spans the height of the window"
);
}
);
});
add_task(async function test_window_resize() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: SHORT_TEST_PAGE,
},
async browser => {
let helper = new ScreenshotsHelper(browser);
let contentInfo = await helper.getContentDimensions();
ok(contentInfo, "Got dimensions back from the content");
const originalWindowWidth = window.outerWidth;
const originalWindowHeight = window.outerHeight;
const BIG_WINDOW_SIZE = 920;
const SMALL_WINDOW_SIZE = 620;
await helper.resizeContentWindow(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE);
helper.triggerUIFromToolbar();
await helper.waitForOverlay();
await helper.dragOverlay(10, 10, 100, 100);
let dimensions = await helper.getScreenshotsOverlayDimensions();
let oldWidth = dimensions.scrollWidth;
let oldHeight = dimensions.scrollHeight;
await helper.resizeContentWindow(BIG_WINDOW_SIZE, BIG_WINDOW_SIZE);
await helper.waitForSelectionLayerDimensionChange(oldWidth, oldHeight);
contentInfo = await helper.getContentDimensions();
dimensions = await helper.getScreenshotsOverlayDimensions();
Assert.equal(
dimensions.scrollWidth,
contentInfo.clientWidth,
"The overlay spans the width of the window"
);
Assert.equal(
dimensions.scrollHeight,
contentInfo.clientHeight,
"The overlay spans the height of the window"
);
oldWidth = dimensions.scrollWidth;
oldHeight = dimensions.scrollHeight;
await helper.resizeContentWindow(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE);
await helper.waitForSelectionLayerDimensionChange(oldWidth, oldHeight);
contentInfo = await helper.getContentDimensions();
dimensions = await helper.getScreenshotsOverlayDimensions();
Assert.equal(
dimensions.scrollWidth,
contentInfo.clientWidth,
"The overlay spans the width of the window"
);
Assert.equal(
dimensions.scrollHeight,
contentInfo.clientHeight,
"The overlay spans the height of the window"
);
Assert.less(
dimensions.scrollWidth,
BIG_WINDOW_SIZE,
"Screenshots overlay is smaller than the big window width"
);
Assert.less(
dimensions.scrollHeight,
BIG_WINDOW_SIZE,
"Screenshots overlay is smaller than the big window height"
);
await helper.resizeContentWindow(
originalWindowWidth,
originalWindowHeight
);
}
);
});
|