test_bug813901.js (876B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /* See https://bugzilla.mozilla.org/show_bug.cgi?id=813901 */ 6 7 // Make sure that we can't inject __exposedProps__ via the proto of a COW-ed object. 8 9 function checkThrows(expression, sb, regexp) { 10 var result = Cu.evalInSandbox('(function() { try { ' + expression + '; return "allowed"; } catch (e) { return e.toString(); }})();', sb); 11 dump('result: ' + result + '\n\n\n'); 12 Assert.ok(!!regexp.exec(result)); 13 } 14 15 function run_test() { 16 17 var sb = new Cu.Sandbox('http://www.example.org'); 18 sb.obj = {foo: 2}; 19 checkThrows('obj.foo = 3;', sb, /denied/); 20 Cu.evalInSandbox("var p = {};", sb); 21 sb.obj.__proto__ = sb.p; 22 checkThrows('obj.foo = 4;', sb, /denied/); 23 }