js/xpconnect/tests/unit/test_getObjectPrincipal.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/unit/test_getObjectPrincipal.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,11 @@
     1.4 +const Cc = Components.classes;
     1.5 +const Ci = Components.interfaces;
     1.6 +const Cu = Components.utils;
     1.7 +
     1.8 +function run_test() {
     1.9 +  var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
    1.10 +  do_check_true(secMan.isSystemPrincipal(Cu.getObjectPrincipal({})));
    1.11 +  var sb = new Cu.Sandbox('http://www.example.com');
    1.12 +  Cu.evalInSandbox('var obj = { foo: 42 };', sb);
    1.13 +  do_check_eq(Cu.getObjectPrincipal(sb.obj).origin, 'http://www.example.com');
    1.14 +}

mercurial