blob: 59c740e5a82aaa7e909a34b9de0099ab8be1c6f8 (
plain)
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const PAGECONTENT =
"<!DOCTYPE html>" +
"<html>" +
"<style>" +
"html { " +
" height: 120vh;" +
" overflow-y: scroll;" +
"}" +
"</style>" +
"</html>";
const pageUrl = "data:text/html," + encodeURIComponent(PAGECONTENT);
add_task(async function test() {
if (window.devicePixelRatio == 1) {
ok(
true,
"Skip this test since this test is supposed to run on HiDPI mode, " +
"the devixePixelRato on this machine is " +
window.devicePixelRatio
);
return;
}
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
// Scroll the content a bit.
const originalScrollPosition = await SpecialPowers.spawn(
tab.linkedBrowser,
[],
async () => {
content.document.scrollingElement.scrollTop = 100;
return content.document.scrollingElement.scrollTop;
}
);
// Disabling HiDPI mode and check the scroll position.
SpecialPowers.DOMWindowUtils.setHiDPIMode(false);
// Make sure we restore even if this test failed.
registerCleanupFunction(() => {
SpecialPowers.DOMWindowUtils.restoreHiDPIMode();
});
const scrollPosition = await SpecialPowers.spawn(
tab.linkedBrowser,
[],
async () => {
return content.document.scrollingElement.scrollTop;
}
);
is(
originalScrollPosition,
scrollPosition,
"The scroll position should be kept"
);
BrowserTestUtils.removeTab(tab);
});
|