Bug 915962 - Part 3: Do not crash when pressing the space bar without having an element focused; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 21 Apr 2015 14:06:54 -0400
changeset 240454 183d3acaef74aa353aed6cc2078627184a35a524
parent 240453 579ad8bc3ccfc1e49c74268692ad3d7af07fbf99
child 240455 23ed444769a8431ba08e07f271a3bf06044290c9
push id28636
push userkwierso@gmail.com
push dateThu, 23 Apr 2015 00:16:12 +0000
treeherdermozilla-central@a5af73b32ac8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs915962
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 915962 - Part 3: Do not crash when pressing the space bar without having an element focused; r=roc
dom/xbl/nsXBLPrototypeHandler.cpp
editor/libeditor/tests/test_bug915962.html
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -473,17 +473,17 @@ nsXBLPrototypeHandler::DispatchXBLComman
     nsCOMPtr<nsIContent> focusedContent;
     if (windowToCheck) {
       nsCOMPtr<nsPIDOMWindow> focusedWindow;
       focusedContent =
         nsFocusManager::GetFocusedDescendant(windowToCheck, true, getter_AddRefs(focusedWindow));
     }
 
     // If the focus is in an editable region, don't scroll.
-    if (focusedContent->IsEditable()) {
+    if (focusedContent && focusedContent->IsEditable()) {
       return NS_OK;
     }
 
     // If the focus is in a form control, don't scroll.
     for (nsIContent* c = focusedContent; c; c = c->GetParent()) {
       nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(c);
       if (formControl) {
         return NS_OK;
--- a/editor/libeditor/tests/test_bug915962.html
+++ b/editor/libeditor/tests/test_bug915962.html
@@ -62,14 +62,29 @@ function startTest() {
   step();
 
   ok(win.scrollY <= oldY, "Page is not scrolled down");
   ok(clicked, "The button should be clicked");
 
   win.close();
   cwu.restoreNormalRefresh();
 
-  SimpleTest.finish();
+  win = window.open("file_bug915962.html", "_blank",
+                    "width=600,height=600,scrollbars=yes");
+  cwu = SpecialPowers.getDOMWindowUtils(win);
+  SimpleTest.waitForFocus(function() {
+    is(win.scrollY, 0, "Sanity check");
+    synthesizeKey(" ", {}, win);
+
+    step();
+
+    isnot(win.scrollY, 0, "Page is scrolled down without crashing");
+
+    win.close();
+    cwu.restoreNormalRefresh();
+
+    SimpleTest.finish();
+  }, win);
 }
 </script>
 </pre>
 </body>
 </html>