mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e8fd44a410
We land these before actually landing bug 923904, because we want to build the tests for bug 968335 on top of the same infrastructure.
67 lines
2.4 KiB
HTML
67 lines
2.4 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=923904
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 923904</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript">
|
|
|
|
/** Test for cloning of |any| and |object| for JS-Implemented WebIDL. **/
|
|
SimpleTest.waitForExplicitFinish();
|
|
SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
|
|
|
|
function go() {
|
|
var someAny = { a: 11 };
|
|
var someObj = { b: 22, c: "str" };
|
|
var t = new TestInterfaceJS(someAny, someObj);
|
|
is(Object.getPrototypeOf(t), TestInterfaceJS.prototype, "Prototype setup works correctly");
|
|
is(t.anyArg.toSource(), someAny.toSource(), "anyArg comes back looking like what we sent");
|
|
is(t.objectArg.toSource(), someObj.toSource(), "objectArg comes back looking like what we sent");
|
|
isnot(t.anyArg, t.anyArg, "get a new anyArg each time");
|
|
isnot(t.objectArg, t.objectArg, "get a new objectArg each time");
|
|
|
|
t.anyAttr = 2;
|
|
is(t.anyAttr, 2, "ping-pong works");
|
|
testObjectCloned(t, 'anyAttr');
|
|
testObjectCloned(t, 'objectAttr');
|
|
|
|
is(someAny.toSource(), t.pingPongAny(someAny).toSource(), "ping-pong works with any");
|
|
is(someObj.toSource(), t.pingPongObject(someObj).toSource(), "ping-pong works with obj");
|
|
isnot(someAny, t.pingPongAny(someAny), "Clone works for ping-pong any");
|
|
isnot(someObj, t.pingPongObject(someObj), "Clone works for ping-pong obj");
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function testObjectCloned(iface, propname) {
|
|
var obj = { prop: 42 };
|
|
iface[propname] = obj;
|
|
is(iface[propname].prop, 42, "objects come back as well");
|
|
is(iface[propname].__proto__, Object.prototype, "vanilla object");
|
|
isnot(iface[propname], obj, "Should not be the original object");
|
|
isnot(iface[propname], iface[propname], "Should get cloned each time");
|
|
try {
|
|
iface[propname] = { stringProp: "hi", reflectorProp: document };
|
|
ok(false, "Should throw when trying to clone reflector");
|
|
} catch (e) {
|
|
ok(/cloned/.test(e), "Should throw clone error: " + e);
|
|
}
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=923904">Mozilla Bug 923904</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|