diff options
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 23 | ||||
-rw-r--r-- | components/script/dom/webidls/HTMLIFrameElement.webidl | 4 | ||||
-rw-r--r-- | components/script/dom/window.rs | 21 |
3 files changed, 24 insertions, 24 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index a2d6d4bac5a..d9d6f624f16 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -433,29 +433,16 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { // Experimental mozbrowser implementation is based on the webidl // present in the gecko source tree, and the documentation here: // https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API - - // TODO(gw): Use experimental codegen when it is available to avoid - // exposing these APIs. See https://github.com/servo/servo/issues/5264. - // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser fn Mozbrowser(&self) -> bool { - // We don't want to allow mozbrowser iframes within iframes - let is_root_pipeline = window_from_node(self).parent_info().is_none(); - if mozbrowser_enabled() && is_root_pipeline { - let element = self.upcast::<Element>(); - element.has_attribute(&atom!("mozbrowser")) - } else { - false - } + let element = self.upcast::<Element>(); + element.has_attribute(&atom!("mozbrowser")) } // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser - fn SetMozbrowser(&self, value: bool) -> ErrorResult { - if mozbrowser_enabled() { - let element = self.upcast::<Element>(); - element.set_bool_attribute(&atom!("mozbrowser"), value); - } - Ok(()) + fn SetMozbrowser(&self, value: bool) { + let element = self.upcast::<Element>(); + element.set_bool_attribute(&atom!("mozbrowser"), value); } // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack diff --git a/components/script/dom/webidls/HTMLIFrameElement.webidl b/components/script/dom/webidls/HTMLIFrameElement.webidl index 20bb563e908..0d78b56fb98 100644 --- a/components/script/dom/webidls/HTMLIFrameElement.webidl +++ b/components/script/dom/webidls/HTMLIFrameElement.webidl @@ -32,8 +32,8 @@ partial interface HTMLIFrameElement { }; partial interface HTMLIFrameElement { - [ChromeOnly,SetterThrows,Pref="dom.mozbrowser.enabled"] - attribute boolean mozbrowser; + [Func="Window::global_is_mozbrowser"] + attribute boolean mozbrowser; }; HTMLIFrameElement implements BrowserElement; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 63a0ca2a36e..a46cac12296 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::FunctionBinding::Function; use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions}; use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods}; use dom::bindings::error::{Error, Fallible, report_pending_exception}; -use dom::bindings::global::GlobalRef; +use dom::bindings::global::{GlobalRef, global_root_from_object}; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::num::Finite; @@ -37,9 +37,8 @@ use dom::storage::Storage; use euclid::{Point2D, Rect, Size2D}; use gfx_traits::LayerId; use ipc_channel::ipc::{self, IpcSender}; -use js::jsapi::{Evaluate2, MutableHandleValue}; -use js::jsapi::{HandleValue, JSContext}; -use js::jsapi::{JSAutoCompartment, JS_GC, JS_GetRuntime, SetWindowProxy}; +use js::jsapi::{Evaluate2, HandleObject, HandleValue, JSAutoCompartment, JSContext}; +use js::jsapi::{JS_GetRuntime, JS_GC, MutableHandleValue, SetWindowProxy}; use js::rust::CompileOptionsWrapper; use js::rust::Runtime; use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; @@ -93,6 +92,7 @@ use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers use tinyfiledialogs::{self, MessageBoxIcon}; use url::Url; use util::geometry::{self, MAX_RECT}; +use util::prefs::mozbrowser_enabled; use util::str::HTML_SPACE_CHARACTERS; use util::{breakpoint, opts}; use webdriver_handlers::jsval_to_webdriver; @@ -1432,6 +1432,19 @@ impl Window { context.active_window() }) } + + /// 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(), + _ => false, + } + } } impl Window { |