diff --git a/browser/components/preferences/in-content/search.js b/browser/components/preferences/in-content/search.js
index 0b8e5e88820c..be34eb8595e6 100644
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -223,6 +223,8 @@ var gSearchPane = {
let newValue = !gEngineView._engineStore.engines[index].shown;
gEngineView.setCellValue(index, tree.columns.getFirstColumn(),
newValue.toString());
+ // Prevent page from scrolling on the space key.
+ aEvent.preventDefault();
}
else {
let isMac = Services.appinfo.OS == "Darwin";
diff --git a/browser/components/preferences/in-content/sync.js b/browser/components/preferences/in-content/sync.js
index 9e2482a88362..3390073dd0c4 100644
--- a/browser/components/preferences/in-content/sync.js
+++ b/browser/components/preferences/in-content/sync.js
@@ -559,12 +559,16 @@ var gSyncPane = {
replaceQueryString: true
});
});
+ // Prevent page from scrolling on the space key.
+ event.preventDefault();
}
},
openManageFirefoxAccount: function(event) {
if (this.clickOrSpaceOrEnterPressed(event)) {
this.manageFirefoxAccount();
+ // Prevent page from scrolling on the space key.
+ event.preventDefault();
}
},
@@ -667,4 +671,3 @@ var gSyncPane = {
textbox.value = value;
},
};
-
diff --git a/browser/components/preferences/in-content/tests/browser.ini b/browser/components/preferences/in-content/tests/browser.ini
index a3805b1c3f20..3e1d5912abe8 100644
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -12,6 +12,9 @@ support-files =
[browser_bug795764_cachedisabled.js]
[browser_bug1018066_resetScrollPosition.js]
[browser_bug1020245_openPreferences_to_paneContent.js]
+[browser_bug1184989_prevent_scrolling_when_preferences_flipped.js]
+support-files =
+ browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
[browser_change_app_handler.js]
skip-if = os != "win" # This test tests the windows-specific app selection dialog, so can't run on non-Windows
[browser_connection.js]
diff --git a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
new file mode 100644
index 000000000000..0972b2de4ff4
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
@@ -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);
+ });
+}
diff --git a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
new file mode 100644
index 000000000000..59b644c8fa24
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/components/sessionstore/content/aboutSessionRestore.js b/browser/components/sessionstore/content/aboutSessionRestore.js
index 186c95d8b0c1..5a5af9b4c441 100644
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -205,6 +205,8 @@ function onListKeyDown(aEvent) {
{
case KeyEvent.DOM_VK_SPACE:
toggleRowChecked(document.getElementById("tabList").currentIndex);
+ // Prevent page from scrolling on the space key.
+ aEvent.preventDefault();
break;
case KeyEvent.DOM_VK_RETURN:
var ix = document.getElementById("tabList").currentIndex;
diff --git a/toolkit/content/widgets/button.xml b/toolkit/content/widgets/button.xml
index e338d67de0c9..89d9d86c6d92 100644
--- a/toolkit/content/widgets/button.xml
+++ b/toolkit/content/widgets/button.xml
@@ -143,7 +143,13 @@
and then they would see the incorrect value of checked. Additionally
a command attribute would redirect the command events anyway.-->
-
+
+
+
-
+
+
+
@@ -337,8 +349,11 @@
this.open = true;
- if (event.originalTarget == this)
+ if (event.originalTarget == this) {
this.open = true;
+ // Prevent page from scrolling on the space key.
+ event.preventDefault();
+ }
diff --git a/toolkit/content/widgets/checkbox.xml b/toolkit/content/widgets/checkbox.xml
index 93f4c7bb2c77..c6a5babfd8e4 100644
--- a/toolkit/content/widgets/checkbox.xml
+++ b/toolkit/content/widgets/checkbox.xml
@@ -24,7 +24,7 @@
-
+
@@ -44,24 +44,26 @@
]]>