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/. */
5 /* See https://bugzilla.mozilla.org/show_bug.cgi?id=813901 */
7 // Make sure that we can't inject __exposedProps__ via the proto of a COW-ed object.
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));
17 var sb = new Cu.Sandbox('http://www.example.org');
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/);