Bug 551635. Don't crash if we focus the root element and there's no root scroll frame. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 11 Mar 2010 18:37:27 +1300
changeset 39969 a3f860add4c27ef0078796d0a8234ba070e24ce5
parent 39968 4df05ea5fe1b547e64a48b347f9312d84cdd3edd
child 39970 6f80d1746d80b6be893f09f84a3bdfb5b38306a7
push id12475
push userrocallahan@mozilla.com
push dateMon, 29 Mar 2010 01:47:57 +0000
treeherderautoland@6f80d1746d80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs551635
milestone1.9.3a4pre
Bug 551635. Don't crash if we focus the root element and there's no root scroll frame. r=mats
layout/generic/crashtests/551635-1.html
layout/generic/crashtests/crashtests.list
layout/generic/nsCanvasFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/551635-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript">
+
+function boom()
+{
+  document.documentElement.focus();
+}
+
+</script>
+</head>
+
+<frameset onload="boom();"></frameset>
+
+</html>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -285,8 +285,9 @@ load 513394-1.html
 load 514800-1.html
 load 517968.html
 load 520340.html
 load 533379-1.html
 load 533379-2.html
 load 534082-1.html
 load 541277-1.html
 load 541277-2.html
+load 551635-1.html
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -107,20 +107,22 @@ nsCanvasFrame::ScrollPositionWillChange(
 NS_IMETHODIMP
 nsCanvasFrame::SetHasFocus(PRBool aHasFocus)
 {
   if (mDoPaintFocus != aHasFocus) {
     mDoPaintFocus = aHasFocus;
     PresContext()->FrameManager()->GetRootFrame()->InvalidateOverflowRect();
 
     if (!mAddedScrollPositionListener) {
-      mAddedScrollPositionListener = PR_TRUE;
       nsIScrollableFrame* sf =
         PresContext()->GetPresShell()->GetRootScrollFrameAsScrollable();
-      sf->AddScrollPositionListener(this);
+      if (sf) {
+        sf->AddScrollPositionListener(this);
+        mAddedScrollPositionListener = PR_TRUE;
+      }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasFrame::SetInitialChildList(nsIAtom*        aListName,
                                    nsFrameList&    aChildList)