diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul')
-rw-r--r-- | dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul b/dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul new file mode 100644 index 000000000..4bc45cddd --- /dev/null +++ b/dom/bindings/test/test_bug1123516_maplikesetlikechrome.xul @@ -0,0 +1,68 @@ +<?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> |