Bug 1164292 - Tests. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Tue, 12 May 2015 14:31:39 -0700
changeset 244137 6e940b4892ee13698ee98bea0f2fccac1b9889a3
parent 244136 9386e2d74b32e93746a13c6f6751ab66da71bfb2
child 244138 2fd7da3aa49ae1b245e3b2fbc6ecfac1d7e57893
push id12987
push userphilringnalda@gmail.com
push dateSat, 16 May 2015 16:53:11 +0000
treeherderfx-team@2f6ea66057fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1164292
milestone41.0a1
Bug 1164292 - Tests. r=gabor
caps/moz.build
caps/tests/unit/test_origin.js
caps/tests/unit/xpcshell.ini
--- a/caps/moz.build
+++ b/caps/moz.build
@@ -1,16 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += ['tests/mochitest']
 
+XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
+
 XPIDL_SOURCES += [
     'nsIDomainPolicy.idl',
     'nsIPrincipal.idl',
     'nsIScriptSecurityManager.idl',
 ]
 
 XPIDL_MODULE = 'caps'
 
new file mode 100644
--- /dev/null
+++ b/caps/tests/unit/test_origin.js
@@ -0,0 +1,14 @@
+var Cu = Components.utils;
+function run_test() {
+  do_check_eq(Cu.getObjectPrincipal({}).origin, '[System Principal]');
+  var exampleOrg = Cu.getObjectPrincipal(new Cu.Sandbox('http://example.org'));
+  do_check_eq(exampleOrg.origin, 'http://example.org');
+  var exampleCom = Cu.getObjectPrincipal(new Cu.Sandbox('https://www.example.com:123'));
+  do_check_eq(exampleCom.origin, 'https://www.example.com:123');
+  var nullPrin = Cu.getObjectPrincipal(new Cu.Sandbox(null));
+  do_check_true(/^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(nullPrin.origin));
+  var ep = Cu.getObjectPrincipal(new Cu.Sandbox([exampleCom, nullPrin, exampleOrg]));
+
+  // Origins should be in lexical order.
+  do_check_eq(ep.origin, `[Expanded Principal [${exampleOrg.origin}, ${exampleCom.origin}, ${nullPrin.origin}]]`);
+}
new file mode 100644
--- /dev/null
+++ b/caps/tests/unit/xpcshell.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+head =
+tail =
+
+[test_origin.js]