Bug 845201 - Pass mayThrow=true to iterate. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Tue, 26 Feb 2013 16:41:55 -0800
changeset 123106 7731263e33fe39665f59687974c9d8f82b757b2f
parent 123105 eea25ab998eb086dc6e9091b270da839c80c307d
child 123107 6562cc879c537915cca41dd72668e9bc3075a695
push id24372
push useremorley@mozilla.com
push dateWed, 27 Feb 2013 13:22:59 +0000
treeherdermozilla-central@0a91da5f5eab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs845201
milestone22.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
Bug 845201 - Pass mayThrow=true to iterate. r=mrbkap We only want fallback behavior here if the policy decides to fail silently. If the policy passes *bp == false, we want to just throw.
js/src/jsproxy.cpp
js/xpconnect/tests/unit/test_bug845201.js
js/xpconnect/tests/unit/xpcshell.ini
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -2556,17 +2556,17 @@ Proxy::keys(JSContext *cx, JSObject *pro
 bool
 Proxy::iterate(JSContext *cx, HandleObject proxy, unsigned flags, MutableHandleValue vp)
 {
     JS_CHECK_RECURSION(cx, return false);
     BaseProxyHandler *handler = GetProxyHandler(proxy);
     vp.setUndefined(); // default result if we refuse to perform this action
     if (!handler->hasPrototype()) {
         AutoEnterPolicy policy(cx, handler, proxy, JSID_VOID,
-                               BaseProxyHandler::GET, /* mayThrow = */ false);
+                               BaseProxyHandler::GET, true);
         // If the policy denies access but wants us to return true, we need
         // to hand a valid (empty) iterator object to the caller.
         if (!policy.allowed()) {
             AutoIdVector props(cx);
             return policy.returnValue() &&
                    EnumeratedIdVectorToIterator(cx, proxy, flags, props, vp);
         }
         return handler->iterate(cx, proxy, flags, vp.address());
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_bug845201.js
@@ -0,0 +1,18 @@
+function sbTest() {
+  var threw = false;
+  try {
+    for (var x in Components) { }
+    do_check_true(false, "Shouldn't be able to enumerate Components");
+  } catch(e) {
+    do_check_true(true, "Threw appropriately");
+    threw = true;
+  }
+  do_check_true(threw, "Shouldn't have thrown uncatchable exception");
+}
+
+function run_test() {
+  var sb = Components.utils.Sandbox('http://www.example.com', { wantComponents: true });
+  sb.do_check_true = do_check_true;
+  Components.utils.evalInSandbox(sbTest.toSource(), sb);
+  Components.utils.evalInSandbox('sbTest();', sb);
+}
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -8,16 +8,17 @@ tail =
 [test_bug596580.js]
 [test_bug604362.js]
 [test_bug608142.js]
 [test_bug641378.js]
 [test_bug677864.js]
 [test_bug711404.js]
 [test_bug778409.js]
 [test_bug780370.js]
+[test_bug845201.js]
 [test_bug_442086.js]
 [test_file.js]
 [test_blob.js]
 [test_import.js]
 [test_import_fail.js]
 [test_js_weak_references.js]
 [test_reflect_parse.js]
 [test_localeCompare.js]