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 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
6 registerCleanupFunction(() => {
7 Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
11 QueryInterface: ChromeUtils.generateQI(["nsIXPCTestUtils"]),
12 doubleWrapFunction(fun) { return fun }
16 // Generate a CCW to a function.
17 var sb = new Cu.Sandbox(this);
18 sb.eval('function fun(x) { return x; }');
19 Assert.equal(sb.fun("foo"), "foo");
21 // Double-wrap the CCW.
22 var utils = xpcWrap(TestUtils, Ci.nsIXPCTestUtils);
23 var doubleWrapped = utils.doubleWrapFunction(sb.fun);
24 Assert.equal(doubleWrapped.echo("foo"), "foo");
29 // Make sure it still works.
30 Assert.equal(doubleWrapped.echo("foo"), "foo");