Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: !debug
- Manifest: dom/bindings/test/chrome.toml
<?xml version="1.0"?>
<!--
-->
<iframe id="t"></iframe>
<!-- test results are displayed in the html:body -->
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/* global TestInterfaceSetlikeNode */
function doTest() {
var win = $("t").contentWindow;
var sandbox = Cu.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 = Cu.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 = Cu.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 = Cu.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");
try {
TestInterfaceSetlikeNode.prototype.keys.call(setlike);
ok(false, "Calling iterators via xrays should fail");
/* eslint-disable-next-line no-shadow */
} catch(e) {
ok(true, "Calling iterators via xrays should fail");
}
setlike.forEach((v) => { is(v, win.document.documentElement, "Cross-compartment forEach works"); });
TestInterfaceSetlikeNode.prototype.forEach.call(setlike,
(v) => { 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");
/* eslint-disable-next-line no-shadow */
} catch(e) {
ok(false, "Shouldn't throw when working with cross-compartment maplike/setlike interfaces " + e)
};
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
</window>