Bug 975144 - Tests for rtcIdentityProvider property draft
authorMartin Thomson <martin.thomson@gmail.com>
Fri, 09 Jan 2015 15:42:02 -0800
changeset 236139 c036ac8dd8a0191fa5262e13fcc7dbfc65b2e79d
parent 236138 f3c6cb74d6249540a61db7b682ad621f21a24652
child 236140 cab675a7a4c0c5a8ca6238504766fde08f2201f9
push id389
push usermartin.thomson@gmail.com
push dateFri, 09 Jan 2015 23:59:51 +0000
bugs975144
milestone37.0a1
Bug 975144 - Tests for rtcIdentityProvider property
js/xpconnect/tests/unit/test_rtcIdentityProvider.js
js/xpconnect/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_rtcIdentityProvider.js
@@ -0,0 +1,35 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function run_test() {
+  let Cu = Components.utils;
+  let sb = new Cu.Sandbox('https://www.example.com',
+                          { wantGlobalProperties: ['rtcIdentityProvider'] });
+
+  function exerciseInterface() {
+    equal(typeof rtcIdentityProvider, 'object');
+    equal(typeof rtcIdentityProvider.register, 'function');
+    rtcIdentityProvider.register({
+      generateAssertion: function(a, b, c) {
+        return Promise.resolve({
+          idp: { domain: 'example.com' },
+          assertion: JSON.stringify([a, b, c])
+        });
+      },
+      validateAssertion: function(d, e) {
+        return Promise.resolve({
+          identity: 'user@example.com',
+          contents: JSON.stringify([d, e])
+        });
+      }
+    });
+  }
+
+  sb.equal = equal;
+  Cu.evalInSandbox('(' + exerciseInterface.toSource() + ')();', sb);
+  ok(sb.rtcIdentityProvider.idp);
+
+  Cu.importGlobalProperties(['rtcIdentityProvider']);
+  exerciseInterface();
+  ok(rtcIdentityProvider.idp);
+}
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -88,16 +88,17 @@ fail-if = os == "android"
 [test_promise.js]
 [test_returncode.js]
 skip-if = os == "android" # native test components aren't available on Android
 [test_textDecoder.js]
 [test_url.js]
 [test_URLSearchParams.js]
 [test_crypto.js]
 [test_css.js]
+[test_rtcIdentityProvider.js]
 [test_sandbox_atob.js]
 [test_isProxy.js]
 [test_getObjectPrincipal.js]
 [test_watchdog_enable.js]
 head = head_watchdog.js
 [test_watchdog_disable.js]
 head = head_watchdog.js
 [test_watchdog_toggle.js]