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
|
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
add_task(async function () {
waitForExplicitFinish();
const tabURL =
getRootDirectory(gTestPath) +
"browser_bug1184989_prevent_scrolling_when_preferences_flipped.xhtml";
await BrowserTestUtils.withNewTab(
{ gBrowser, url: tabURL },
async function (browser) {
let doc = browser.contentDocument;
let container = doc.getElementById("container");
// Test button
let button = doc.getElementById("button");
button.focus();
let initialScrollTop = container.scrollTop;
EventUtils.sendString(" ");
await checkPageScrolling(container, "button", initialScrollTop);
// Test checkbox
let checkbox = doc.getElementById("checkbox");
checkbox.focus();
initialScrollTop = container.scrollTop;
EventUtils.sendString(" ");
ok(checkbox.checked, "Checkbox is checked");
await checkPageScrolling(container, "checkbox", initialScrollTop);
// Test radio
let radiogroup = doc.getElementById("radiogroup");
radiogroup.focus();
initialScrollTop = container.scrollTop;
EventUtils.sendString(" ");
await checkPageScrolling(container, "radio", initialScrollTop);
}
);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:preferences#search" },
async function (browser) {
let doc = browser.contentDocument;
let container = doc.getElementsByClassName("main-content")[0];
// Test search
let engineList = doc.getElementById("engineList");
engineList.focus();
let initialScrollTop = container.scrollTop;
EventUtils.sendString(" ");
is(
engineList.view.selection.currentIndex,
0,
"Search engineList is selected"
);
EventUtils.sendString(" ");
await checkPageScrolling(
container,
"search engineList",
initialScrollTop
);
}
);
// Test session restore
const CRASH_URL = "about:mozilla";
const CRASH_FAVICON = "chrome://branding/content/icon32.png";
const CRASH_SHENTRY = { url: CRASH_URL };
const CRASH_TAB = { entries: [CRASH_SHENTRY], image: CRASH_FAVICON };
const CRASH_STATE = { windows: [{ tabs: [CRASH_TAB] }] };
const TAB_URL = "about:sessionrestore";
const TAB_FORMDATA = { url: TAB_URL, id: { sessionData: CRASH_STATE } };
const TAB_SHENTRY = { url: TAB_URL, triggeringPrincipal_base64 };
const TAB_STATE = { entries: [TAB_SHENTRY], formdata: TAB_FORMDATA };
let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(
gBrowser,
"about:blank"
));
// Fake a post-crash tab
SessionStore.setTabState(tab, JSON.stringify(TAB_STATE));
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
let doc = tab.linkedBrowser.contentDocument;
// Make body scrollable
doc.body.style.height = doc.body.clientHeight + 100 + "px";
let tabsToggle = doc.getElementById("tabsToggle");
tabsToggle.focus();
let initialScrollTop = doc.documentElement.scrollTop;
EventUtils.sendString(" ");
await checkPageScrolling(
doc.documentElement,
"session restore",
initialScrollTop
);
gBrowser.removeCurrentTab();
finish();
});
function checkPageScrolling(container, type, initialScrollTop = 0) {
return new Promise(resolve => {
setTimeout(() => {
is(
container.scrollTop,
initialScrollTop,
"Page should not scroll when " + type + " flipped"
);
resolve();
}, 0);
});
}
|