Give WindowProxy objects an innerObject hook.

This ensures that UncheckedUnwrap(obj, /* stopAtOuter = */ true) will indeed
stop at the WindowProxy ("outer window", in older SpiderMonkey jargon), which
is necessary to prevent raw Window ("inner window") objects becoming visible
to JavaScript code, or tripping assertions that we don't do that.
This commit is contained in:
Ms2ger 2016-02-09 16:35:38 +01:00
parent 70423154b9
commit d79660e989
4 changed files with 5 additions and 9 deletions

View file

@ -12,7 +12,7 @@ use dom::document::Document;
use dom::element::Element; use dom::element::Element;
use dom::window::Window; use dom::window::Window;
use js::JSCLASS_IS_GLOBAL; use js::JSCLASS_IS_GLOBAL;
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, WrapperNew}; use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
use js::glue::{GetProxyPrivate, SetProxyExtra}; use js::glue::{GetProxyPrivate, SetProxyExtra};
use js::jsapi::{Handle, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue}; use js::jsapi::{Handle, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue};
use js::jsapi::{HandleId, HandleObject, MutableHandle, MutableHandleValue}; use js::jsapi::{HandleId, HandleObject, MutableHandle, MutableHandleValue};
@ -56,11 +56,7 @@ impl BrowsingContext {
assert!(((*JS_GetClass(parent.get())).flags & JSCLASS_IS_GLOBAL) != 0); assert!(((*JS_GetClass(parent.get())).flags & JSCLASS_IS_GLOBAL) != 0);
let _ac = JSAutoCompartment::new(cx, parent.get()); let _ac = JSAutoCompartment::new(cx, parent.get());
let window_proxy = RootedObject::new(cx, let window_proxy = RootedObject::new(cx,
WrapperNew(cx, NewWindowProxy(cx, parent, handler));
parent,
handler,
ptr::null(),
true));
assert!(!window_proxy.ptr.is_null()); assert!(!window_proxy.ptr.is_null());
let object = box BrowsingContext::new_inherited(document, frame_element); let object = box BrowsingContext::new_inherited(document, frame_element);

View file

@ -928,7 +928,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/servo/rust-mozjs#b96675b217534c7742cbfda8150ea0536aedbdfb" source = "git+https://github.com/servo/rust-mozjs#6b53c4937b67dc71414d37dd3f4ad5cf407b2c2b"
dependencies = [ dependencies = [
"heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/cef/Cargo.lock generated
View file

@ -859,7 +859,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/servo/rust-mozjs#b96675b217534c7742cbfda8150ea0536aedbdfb" source = "git+https://github.com/servo/rust-mozjs#6b53c4937b67dc71414d37dd3f4ad5cf407b2c2b"
dependencies = [ dependencies = [
"heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/gonk/Cargo.lock generated
View file

@ -841,7 +841,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/servo/rust-mozjs#b96675b217534c7742cbfda8150ea0536aedbdfb" source = "git+https://github.com/servo/rust-mozjs#6b53c4937b67dc71414d37dd3f4ad5cf407b2c2b"
dependencies = [ dependencies = [
"heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",