mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 769273 - part3: Cu.nukeSandbox. r=bholley
This commit is contained in:
parent
34d1b84073
commit
9a3f0c40b0
@ -118,7 +118,7 @@ interface ScheduledGCCallback : nsISupports
|
||||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(9e43a260-5db2-11e1-b86c-0800200c9a66)]
|
||||
[scriptable, uuid(fc26b9e9-87a1-44a4-b774-53781b7df16b)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
@ -339,6 +339,9 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
|
||||
[implicit_jscontext]
|
||||
void setGCZeal(in long zeal);
|
||||
|
||||
[implicit_jscontext]
|
||||
void nukeSandbox(in jsval obj);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4389,6 +4389,20 @@ nsXPCComponents_Utils::SetGCZeal(PRInt32 aValue, JSContext* cx)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::NukeSandbox(const JS::Value &obj, JSContext *cx)
|
||||
{
|
||||
NS_ENSURE_TRUE(obj.isObject(), NS_ERROR_INVALID_ARG);
|
||||
JSObject *wrapper = &obj.toObject();
|
||||
NS_ENSURE_TRUE(IsWrapper(wrapper), NS_ERROR_INVALID_ARG);
|
||||
JSObject *sb = UnwrapObject(wrapper);
|
||||
NS_ENSURE_TRUE(GetObjectJSClass(sb) == &SandboxClass, NS_ERROR_INVALID_ARG);
|
||||
NukeCrossCompartmentWrappers(cx, AllCompartments(),
|
||||
SingleCompartment(GetObjectCompartment(sb)),
|
||||
NukeForGlobalObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
27
js/xpconnect/tests/unit/test_nuke_sandbox.js
Normal file
27
js/xpconnect/tests/unit/test_nuke_sandbox.js
Normal file
@ -0,0 +1,27 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* See https://bugzilla.mozilla.org/show_bug.cgi?id=769273 */
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var sb = Components.utils.Sandbox("http://www.blah.com");
|
||||
sb.prop = "prop"
|
||||
var refToObjFromSb = Components.utils.evalInSandbox("var a = {prop2:'prop2'}; a", sb);
|
||||
Components.utils.nukeSandbox(sb);
|
||||
try{
|
||||
sb.prop;
|
||||
do_check_true(false);
|
||||
} catch (e) {
|
||||
do_check_true(e.toString().indexOf("can't access dead object") > -1);
|
||||
}
|
||||
|
||||
try{
|
||||
refToObjFromSb.prop2;
|
||||
do_check_true(false);
|
||||
} catch (e) {
|
||||
do_check_true(e.toString().indexOf("can't access dead object") > -1);
|
||||
}
|
||||
|
||||
}
|
@ -29,3 +29,4 @@ fail-if = os == "android"
|
||||
[test_components.js]
|
||||
[test_allowedDomains.js]
|
||||
[test_allowedDomainsXHR.js]
|
||||
[test_nuke_sandbox.js]
|
||||
|
Loading…
Reference in New Issue
Block a user