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
|
/*
* Bug 1330882 - A test case for opening new windows as rounded size when
* fingerprinting resistance is enabled.
*/
const CC = Components.Constructor;
let gMaxAvailWidth;
let gMaxAvailHeight;
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [["privacy.resistFingerprinting", true]],
});
// Calculate the maximum available size.
let maxAvailSize = await calcMaximumAvailSize();
gMaxAvailWidth = maxAvailSize.maxAvailWidth;
gMaxAvailHeight = maxAvailSize.maxAvailHeight;
});
add_task(async function test_new_window() {
// Open a new window.
let win = await BrowserTestUtils.openNewBrowserWindow();
// Load a page and verify its window size.
let tab = await BrowserTestUtils.openNewForegroundTab(
win.gBrowser,
TEST_PATH + "file_dummy.html"
);
await SpecialPowers.spawn(
tab.linkedBrowser,
[{ gMaxAvailWidth, gMaxAvailHeight }],
async function (input) {
is(
content.screen.width,
input.gMaxAvailWidth,
"The screen.width has a correct rounded value"
);
is(
content.screen.height,
input.gMaxAvailHeight,
"The screen.height has a correct rounded value"
);
is(
content.innerWidth,
input.gMaxAvailWidth,
"The window.innerWidth has a correct rounded value"
);
is(
content.innerHeight,
input.gMaxAvailHeight,
"The window.innerHeight has a correct rounded value"
);
}
);
BrowserTestUtils.removeTab(tab);
await BrowserTestUtils.closeWindow(win);
});
|