diff --git a/layout/generic/crashtests/367246-1.html b/layout/generic/crashtests/367246-1.html
new file mode 100644
index 000000000000..5a5a84565065
--- /dev/null
+++ b/layout/generic/crashtests/367246-1.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/layout/generic/crashtests/crashtests.list b/layout/generic/crashtests/crashtests.list
index 66c418268a63..ece1d583094e 100644
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -31,6 +31,7 @@ load 364686-1.xhtml
load 366021-1.xhtml
load 366667-1.html
load 366952-1.html
+load 367246-1.html
load 368330-1.html
load 368461-1.xhtml
load 368860-1.html
diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp
index 8469889fed74..a6ab61566910 100644
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2610,6 +2610,14 @@ nsGfxScrollFrameInner::GetScrolledRect(const nsSize& aScrollPortSize) const
} else {
if (x2 > aScrollPortSize.width)
x2 = aScrollPortSize.width;
+ // When the scrolled frame chooses a size larger than its available width (because
+ // its padding alone is larger than the available width), we need to keep the
+ // start-edge of the scroll frame anchored to the start-edge of the scrollport.
+ // When the scrolled frame is RTL, this means moving it in our left-based
+ // coordinate system, so we need to compensate for its extra width here by
+ // effectively repositioning the frame.
+ nscoord extraWidth = PR_MAX(0, mScrolledFrame->GetSize().width - aScrollPortSize.width);
+ x2 += extraWidth;
}
return nsRect(x1, y1, x2 - x1, y2 - y1);