diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini
index 4627b1174760..a0bae4613277 100644
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -851,3 +851,4 @@ skip-if = e10s || os != 'linux' || buildapp != 'browser'
[test_explicit_user_agent.html]
[test_change_policy.html]
skip-if = buildapp == 'b2g' #no ssl support
+[test_document.all_iteration.html]
diff --git a/dom/base/test/test_document.all_iteration.html b/dom/base/test/test_document.all_iteration.html
new file mode 100644
index 000000000000..a5140d9df114
--- /dev/null
+++ b/dom/base/test/test_document.all_iteration.html
@@ -0,0 +1,11 @@
+
+
+
Test for document.all iteration behavior
+
+
+
+
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 755ca476bb20..593e422630cd 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2222,7 +2222,14 @@ class MethodDefiner(PropertyDefiner):
return (any("@@iterator" in m.aliases for m in methods) or
any("@@iterator" == r["name"] for r in regular))
- if (any(m.isGetter() and m.isIndexed() for m in methods)):
+ # Check whether we need to output an @@iterator due to having an indexed
+ # getter. We only do this while outputting non-static and
+ # non-unforgeable methods, since the @@iterator function will be
+ # neither.
+ if (not static and
+ not unforgeable and
+ descriptor.supportsIndexedProperties() and
+ isMaybeExposedIn(descriptor.operations['IndexedGetter'], descriptor)):
if hasIterator(methods, self.regular):
raise TypeError("Cannot have indexed getter/attr on "
"interface %s with other members "