js/xpconnect/tests/unit/test_bug976151.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/unit/test_bug976151.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,24 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +const Cu = Components.utils;
     1.9 +function run_test() {
    1.10 +  let unprivilegedSb = new Cu.Sandbox('http://www.example.com');
    1.11 +  function checkCantWrap(val) {
    1.12 +    try {
    1.13 +      unprivilegedSb.prop = val;
    1.14 +      do_check_true(false);
    1.15 +    } catch (e) {
    1.16 +      do_check_true(/denied|insecure|/.test(e));
    1.17 +    }
    1.18 +  }
    1.19 +  let xoSb = new Cu.Sandbox('http://www.example.net');
    1.20 +  let epSb = new Cu.Sandbox(['http://www.example.com']);
    1.21 +  checkCantWrap(eval);
    1.22 +  checkCantWrap(xoSb.eval);
    1.23 +  checkCantWrap(epSb.eval);
    1.24 +  checkCantWrap(Function);
    1.25 +  checkCantWrap(xoSb.Function);
    1.26 +  checkCantWrap(epSb.Function);
    1.27 +}

mercurial