Fix for bug 691707 (Enumerating new proxy-based DOM bindings should enumerate the prototype too). r=mrbkap.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 07 Feb 2012 20:55:37 +0100
changeset 87726 3160e7df9b4db77df9d631faffe68e5201311de4
parent 87725 e999dda657ba03720ca5261a3a0fdf2af29fa7d2
child 87727 bb55af76a3b907f23f232f30004ecf645dceb58d
push id22143
push userphilringnalda@gmail.com
push dateSun, 26 Feb 2012 23:12:35 +0000
treeherdermozilla-central@b98fc24ac54b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs691707
milestone13.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
Fix for bug 691707 (Enumerating new proxy-based DOM bindings should enumerate the prototype too). r=mrbkap.
dom/tests/mochitest/bugs/Makefile.in
dom/tests/mochitest/bugs/test_bug691707.html
js/xpconnect/src/dombindings.cpp
--- a/dom/tests/mochitest/bugs/Makefile.in
+++ b/dom/tests/mochitest/bugs/Makefile.in
@@ -150,12 +150,13 @@ include $(topsrcdir)/config/rules.mk
 		test_window_bar.html \
 		file_window_bar.html \
 		test_resize_move_windows.html \
 		test_devicemotion_multiple_listeners.html \
 		devicemotion_outer.html \
 		devicemotion_inner.html \
 		test_bug698061.html \
 		test_bug707749.html \
+		test_bug691707.html \
 		$(NULL)
 
 libs:: 	$(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug691707.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=691707
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 691707</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691707">Mozilla Bug 691707</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 691707 **/
+
+var nodeList = document.body.childNodes;
+var properties = [i for (i in nodeList)];
+for (var j = 1; j < nodeList.length; ++j)
+    ok(properties.indexOf("" + j) >= 0, "Enumerating hit all numeric properties");
+ok(properties.indexOf("item") >= 0, "Enumerating hit 'item' from the prototype");
+ok(properties.indexOf("length") >= 0, "Enumerating hit 'length' from the prototype");
+
+</script>
+</pre>
+</body>
+</html>
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -847,18 +847,19 @@ ListBase<LC>::delete_(JSContext *cx, JSO
     *bp = !!b;
     return true;
 }
 
 template<class LC>
 bool
 ListBase<LC>::enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props)
 {
-    // FIXME: enumerate proto as well
-    return getOwnPropertyNames(cx, proxy, props);
+    JSObject *proto = JS_GetPrototype(proxy);
+    return getOwnPropertyNames(cx, proxy, props) &&
+           (!proto || js::GetPropertyNames(cx, proto, 0, &props));
 }
 
 template<class LC>
 bool
 ListBase<LC>::fix(JSContext *cx, JSObject *proxy, Value *vp)
 {
     vp->setUndefined();
     return true;