mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
69 lines
3.3 KiB
XML
69 lines
3.3 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
|
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1123516
|
|
-->
|
|
<window title="Mozilla Bug 1123516"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<iframe id="t"></iframe>
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1123516"
|
|
target="_blank">Mozilla Bug 1123516</a>
|
|
</body>
|
|
|
|
<!-- test code goes here -->
|
|
<script type="application/javascript">
|
|
<![CDATA[
|
|
|
|
/** Test for Bug 1123516 **/
|
|
const Cu = Components.utils;
|
|
function doTest() {
|
|
var win = $("t").contentWindow;
|
|
var sandbox = Components.utils.Sandbox(win, { sandboxPrototype: win });
|
|
is(sandbox._content, undefined, "_content does nothing over Xray");
|
|
// Test cross-compartment usage of maplike/setlike WebIDL structures.
|
|
SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, function() {
|
|
try {
|
|
var maplike = Components.utils.evalInSandbox("var m = new TestInterfaceMaplike(); m;", sandbox);
|
|
maplike.set("test2", 2);
|
|
is(maplike.get("test2"), 2, "Should be able to create and use maplike/setlike across compartments");
|
|
var test = Components.utils.evalInSandbox("m.get('test2');", sandbox);
|
|
is(test, 2, "Maplike/setlike should still work in original compartment");
|
|
is(maplike.size, 1, "Testing size retrieval across compartments");
|
|
} catch(e) {
|
|
ok(false, "Shouldn't throw when working with cross-compartment maplike/setlike interfaces " + e)
|
|
};
|
|
try {
|
|
var setlike = Components.utils.evalInSandbox("var m = new TestInterfaceSetlikeNode(); m.add(document.documentElement); m;", sandbox);
|
|
is(TestInterfaceSetlikeNode.prototype.has.call(setlike, win.document.documentElement), true,
|
|
"Cross-compartment unwrapping/comparison has works");
|
|
// TODO: Should throw until iterators are handled by Xrays, Bug 1023984
|
|
try {
|
|
var e = TestInterfaceSetlikeNode.prototype.keys.call(setlike);
|
|
ok(false, "Calling iterators via xrays should fail");
|
|
} catch(e) {
|
|
ok(true, "Calling iterators via xrays should fail");
|
|
}
|
|
|
|
setlike.forEach((v,k,t) => { is(v, win.document.documentElement, "Cross-compartment forEach works"); });
|
|
TestInterfaceSetlikeNode.prototype.forEach.call(setlike,
|
|
(v,k,t) => { is(v, win.document.documentElement, "Cross-compartment forEach works"); });
|
|
is(TestInterfaceSetlikeNode.prototype.delete.call(setlike, win.document.documentElement), true,
|
|
"Cross-compartment unwrapping/comparison delete works");
|
|
} catch(e) {
|
|
ok(false, "Shouldn't throw when working with cross-compartment maplike/setlike interfaces " + e)
|
|
};
|
|
SimpleTest.finish();
|
|
});
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(doTest);
|
|
]]>
|
|
</script>
|
|
</window>
|