diff --git a/layout/reftests/bugs/513318-1-ref.xul b/layout/reftests/bugs/513318-1-ref.xul
new file mode 100644
index 000000000000..40b12a6074a4
--- /dev/null
+++ b/layout/reftests/bugs/513318-1-ref.xul
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/layout/reftests/bugs/513318-1.xul b/layout/reftests/bugs/513318-1.xul
new file mode 100644
index 000000000000..a1b758629cfa
--- /dev/null
+++ b/layout/reftests/bugs/513318-1.xul
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
diff --git a/layout/reftests/bugs/513318-2-ref.xul b/layout/reftests/bugs/513318-2-ref.xul
new file mode 100644
index 000000000000..647545792d1e
--- /dev/null
+++ b/layout/reftests/bugs/513318-2-ref.xul
@@ -0,0 +1,9 @@
+
+
+
+
+ Hello Kitty
+
+
diff --git a/layout/reftests/bugs/513318-2.xul b/layout/reftests/bugs/513318-2.xul
new file mode 100644
index 000000000000..9734de16b297
--- /dev/null
+++ b/layout/reftests/bugs/513318-2.xul
@@ -0,0 +1,9 @@
+
+
+
+
+ Hello Kitty
+
+
diff --git a/layout/reftests/bugs/513318-3-ref.xul b/layout/reftests/bugs/513318-3-ref.xul
new file mode 100644
index 000000000000..bec47d615466
--- /dev/null
+++ b/layout/reftests/bugs/513318-3-ref.xul
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/layout/reftests/bugs/513318-3.xul b/layout/reftests/bugs/513318-3.xul
new file mode 100644
index 000000000000..dbe74638fe12
--- /dev/null
+++ b/layout/reftests/bugs/513318-3.xul
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list
index 7c323eaee0e0..cdef793d9d0b 100644
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1317,3 +1317,6 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
== 513153-1b.html 513153-1-ref.html
== 513153-2a.html 513153-2-ref.html
== 513153-2b.html 513153-2-ref.html
+== 513318-1.xul 513318-1-ref.xul
+!= 513318-2.xul 513318-2-ref.xul
+!= 513318-3.xul 513318-3-ref.xul
diff --git a/layout/xul/base/src/nsBox.cpp b/layout/xul/base/src/nsBox.cpp
index 333038a86211..ab589899f742 100644
--- a/layout/xul/base/src/nsBox.cpp
+++ b/layout/xul/base/src/nsBox.cpp
@@ -591,7 +591,7 @@ nsBox::SyncLayout(nsBoxLayoutState& aState)
rect = GetOverflowRect();
}
else {
- if (!DoesClipChildren()) {
+ if (!DoesClipChildren() && !IsCollapsed(aState)) {
// See if our child frames caused us to overflow after being laid
// out. If so, store the overflow area. This normally can't happen
// in XUL, but it can happen with the CSS 'outline' property and