summaryrefslogtreecommitdiffstats
path: root/dom/bindings/test/test_returnUnion.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/bindings/test/test_returnUnion.html')
-rw-r--r--dom/bindings/test/test_returnUnion.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/bindings/test/test_returnUnion.html b/dom/bindings/test/test_returnUnion.html
new file mode 100644
index 0000000000..eca681068a
--- /dev/null
+++ b/dom/bindings/test/test_returnUnion.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1048659
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1048659</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+ /* global TestInterfaceJS */
+ /** Test for returning unions from JS-implemented WebIDL. **/
+ SimpleTest.waitForExplicitFinish();
+ SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, go);
+
+ function go() {
+ var t = new TestInterfaceJS();
+ var t2 = new TestInterfaceJS();
+
+ is(t.pingPongUnion(t2), t2, "ping pong union for left case should be identity");
+ is(t.pingPongUnion(12), 12, "ping pong union for right case should be identity");
+
+ is(t.pingPongUnionContainingNull("this is not a string"), "this is not a string",
+ "ping pong union containing union for left case should be identity");
+ is(t.pingPongUnionContainingNull(null), null,
+ "ping pong union containing null for right case null should be identity");
+ is(t.pingPongUnionContainingNull(t2), t2,
+ "ping pong union containing null for right case should be identity");
+
+ is(t.pingPongNullableUnion(t2), t2, "ping pong nullable union for left case should be identity");
+ is(t.pingPongNullableUnion(12), 12, "ping pong nullable union for right case should be identity");
+ is(t.pingPongNullableUnion(null), null, "ping pong nullable union for null case should be identity");
+
+ var rejectedBadUnion = false;
+ var result = null;
+ try {
+ result = t.returnBadUnion();
+ } catch (e) {
+ rejectedBadUnion = true;
+ }
+ is(result, null, "bad union should not set a value for result");
+ ok(rejectedBadUnion, "bad union should throw an exception");
+
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1048659">Mozilla Bug 1048659</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>