Bug 614757 - Properly deep wrap via call/construct. r=gal

--HG--
extra : rebase_source : a46e4a24a62d3738f8161f1623bb619cc28bdb79
This commit is contained in:
Blake Kaplan 2010-12-03 19:00:23 -08:00
parent 0d7dcbae06
commit 75e4df25b0
4 changed files with 56 additions and 0 deletions

View File

@ -59,6 +59,7 @@ _CHROME_FILES = \
test_bug571849.xul \
test_bug601803.xul \
test_bug610390.xul \
test_bug614757.xul \
$(NULL)
# Disabled until this test gets updated to test the new proxy based

View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=614757
-->
<window title="Mozilla Bug 601803"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- 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=614757"
target="_blank">Mozilla Bug 614757</a>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 614757 **/
function go() {
is($('ifr').contentDocument.wrappedJSObject.getElementsByTagName('body')[0].toString().indexOf('Xray'),
-1, "Properly deep wrap");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]></script>
<iframe type="content" src="http://mochi.test:8888/tests/js/src/xpconnect/tests/mochitest/file_evalInSandbox.html" onload="go()" id="ifr" />
</body>
</window>

View File

@ -84,6 +84,21 @@ CrossOriginWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, js
WrapperFactory::WaiveXrayAndWrap(cx, js::Jsvalify(vp));
}
bool
CrossOriginWrapper::call(JSContext *cx, JSObject *wrapper, uintN argc, js::Value *vp)
{
return JSCrossCompartmentWrapper::call(cx, wrapper, argc, vp) &&
WrapperFactory::WaiveXrayAndWrap(cx, js::Jsvalify(vp));
}
bool
CrossOriginWrapper::construct(JSContext *cx, JSObject *wrapper,
uintN argc, js::Value *argv, js::Value *rval)
{
return JSCrossCompartmentWrapper::construct(cx, wrapper, argc, argv, rval) &&
WrapperFactory::WaiveXrayAndWrap(cx, js::Jsvalify(rval));
}
bool
CrossOriginWrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act)
{

View File

@ -57,6 +57,10 @@ class CrossOriginWrapper : public JSCrossCompartmentWrapper {
virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
js::Value *vp);
virtual bool call(JSContext *cx, JSObject *wrapper, uintN argc, js::Value *vp);
virtual bool construct(JSContext *cx, JSObject *wrapper,
uintN argc, js::Value *argv, js::Value *rval);
virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act);
virtual void leave(JSContext *cx, JSObject *wrapper);