Fix permissions of mozbrowser and BrowserElementPrivileged (fixes #11498)

This commit is contained in:
Anthony Ramine 2016-05-30 11:23:42 +02:00
parent b11648903b
commit 704646698f
3 changed files with 16 additions and 10 deletions

View file

@ -437,8 +437,12 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(&self) -> bool {
if window_from_node(self).is_mozbrowser() {
let element = self.upcast::<Element>();
element.has_attribute(&atom!("mozbrowser"))
} else {
false
}
}
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser

View file

@ -146,16 +146,16 @@ interface BrowserElementPrivileged {
// unsigned long count,
// unsigned long modifiers);
[Throws]
[Func="Window::global_is_mozbrowser", Throws]
void goBack();
[Throws]
[Func="Window::global_is_mozbrowser", Throws]
void goForward();
[Throws]
[Func="Window::global_is_mozbrowser", Throws]
void reload(optional boolean hardReload = false);
[Throws]
[Func="Window::global_is_mozbrowser", Throws]
void stop();
//[Throws,

View file

@ -1459,15 +1459,17 @@ impl Window {
})
}
/// Returns whether this window is mozbrowser.
pub fn is_mozbrowser(&self) -> bool {
mozbrowser_enabled() && self.parent_info().is_none()
}
/// Returns whether mozbrowser is enabled and `obj` has been created
/// in a top-level `Window` global.
#[allow(unsafe_code)]
pub unsafe fn global_is_mozbrowser(_: *mut JSContext, obj: HandleObject) -> bool {
if !mozbrowser_enabled() {
return false;
}
match global_root_from_object(obj.get()).r() {
GlobalRef::Window(window) => window.parent_info().is_none(),
GlobalRef::Window(window) => window.is_mozbrowser(),
_ => false,
}
}