forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1184989 - Prevent flipping preference will scroll the page as wel…
…l. r=jaws MozReview-Commit-ID: 5j5FN8aFDlX
- Loading branch information
Showing
10 changed files
with
171 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...erences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); | ||
|
||
add_task(function* () { | ||
waitForExplicitFinish(); | ||
|
||
const tabURL = getRootDirectory(gTestPath) + "browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul"; | ||
|
||
yield BrowserTestUtils.withNewTab({ gBrowser, url: tabURL }, function* (browser) { | ||
let doc = browser.contentDocument; | ||
let container = doc.getElementById("container"); | ||
|
||
// Test button | ||
let button = doc.getElementById("button"); | ||
button.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
yield checkPageScrolling(container, "button"); | ||
|
||
// Test checkbox | ||
let checkbox = doc.getElementById("checkbox"); | ||
checkbox.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
ok(checkbox.checked, "Checkbox is checked"); | ||
yield checkPageScrolling(container, "checkbox"); | ||
|
||
// Test listbox | ||
let listbox = doc.getElementById("listbox"); | ||
let listitem = doc.getElementById("listitem"); | ||
listbox.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
ok(listitem.selected, "Listitem is selected"); | ||
yield checkPageScrolling(container, "listbox"); | ||
|
||
// Test radio | ||
let radiogroup = doc.getElementById("radiogroup"); | ||
radiogroup.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
yield checkPageScrolling(container, "radio"); | ||
}); | ||
|
||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:preferences#search" }, function* (browser) { | ||
let doc = browser.contentDocument; | ||
let container = doc.getElementsByClassName("main-content")[0]; | ||
|
||
// Test search | ||
let engineList = doc.getElementById("engineList"); | ||
engineList.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
is(engineList.view.selection.currentIndex, 0, "Search engineList is selected"); | ||
EventUtils.synthesizeKey(" ", {}); | ||
yield checkPageScrolling(container, "search engineList"); | ||
}); | ||
|
||
// 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}; | ||
const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA}; | ||
|
||
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); | ||
|
||
// Fake a post-crash tab | ||
ss.setTabState(tab, JSON.stringify(TAB_STATE)); | ||
|
||
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser); | ||
let doc = tab.linkedBrowser.contentDocument; | ||
|
||
// Make body scrollable | ||
doc.body.style.height = (doc.body.clientHeight + 100) + "px"; | ||
|
||
let tabList = doc.getElementById("tabList"); | ||
tabList.focus(); | ||
EventUtils.synthesizeKey(" ", {}); | ||
yield checkPageScrolling(doc.documentElement, "session restore"); | ||
|
||
gBrowser.removeCurrentTab(); | ||
finish(); | ||
}); | ||
|
||
function checkPageScrolling(container, type) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
is(container.scrollTop, 0, "Page should not scroll when " + type + " flipped"); | ||
resolve(); | ||
}, 0); | ||
}); | ||
} |
33 changes: 33 additions & 0 deletions
33
...rences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
XUL Widget Test for Bug 1184989 | ||
--> | ||
<page title="Bug 1184989 Test" | ||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | ||
|
||
<vbox id="container" style="height: 200px; overflow: auto;"> | ||
<vbox style="height: 500px;"> | ||
<hbox> | ||
<button id="button" label="button" /> | ||
</hbox> | ||
|
||
<hbox> | ||
<checkbox id="checkbox" label="checkbox" /> | ||
</hbox> | ||
|
||
<hbox style="height: 50px;"> | ||
<listbox id="listbox"> | ||
<listitem id="listitem" label="listitem" /> | ||
<listitem label="listitem" /> | ||
</listbox> | ||
</hbox> | ||
|
||
<hbox> | ||
<radiogroup id="radiogroup"> | ||
<radio id="radio" label="radio" /> | ||
</radiogroup> | ||
</hbox> | ||
</vbox> | ||
</vbox> | ||
|
||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters