diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index ee0291429cc..c44f2448a48 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -43,6 +43,7 @@ msg = {path = "../msg"} net_traits = {path = "../net_traits"} num-traits = "0.1.32" offscreen_gl_context = "0.1.2" +open = "1.1.1" phf = "0.7.13" phf_macros = "0.7.13" plugins = {path = "../plugins"} diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 73d9f7f3ed0..0caeddb3dfa 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2390,6 +2390,7 @@ Root::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': crea create = CreateBindingJSObject(self.descriptor) return CGGeneric("""\ %(createObject)s +(*raw).init_reflector(obj.ptr); let _ac = JSAutoCompartment::new(cx, obj.ptr); let mut proto = RootedObject::new(cx, ptr::null_mut()); @@ -2397,7 +2398,6 @@ GetProtoObject(cx, obj.handle(), proto.handle_mut()); JS_SetPrototype(cx, obj.handle(), proto.handle()); %(copyUnforgeable)s -(*raw).init_reflector(obj.ptr); Root::from_ref(&*raw)\ """ % {'copyUnforgeable': unforgeable, 'createObject': create}) diff --git a/components/script/dom/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl index 8ee6296bfe3..9bb34b90a95 100644 --- a/components/script/dom/webidls/BrowserElement.webidl +++ b/components/script/dom/webidls/BrowserElement.webidl @@ -146,24 +146,16 @@ interface BrowserElementPrivileged { // unsigned long count, // unsigned long modifiers); - [Throws, - Pref="dom.mozbrowser.enabled", - CheckAnyPermissions="browser"] + [Throws] void goBack(); - [Throws, - Pref="dom.mozbrowser.enabled", - CheckAnyPermissions="browser"] + [Throws] void goForward(); - [Throws, - Pref="dom.mozbrowser.enabled", - CheckAnyPermissions="browser"] + [Throws] void reload(optional boolean hardReload = false); - [Throws, - Pref="dom.mozbrowser.enabled", - CheckAnyPermissions="browser"] + [Throws] void stop(); //[Throws, diff --git a/components/script/dom/webidls/Window.webidl b/components/script/dom/webidls/Window.webidl index c75def477da..b263d53bb7b 100644 --- a/components/script/dom/webidls/Window.webidl +++ b/components/script/dom/webidls/Window.webidl @@ -159,6 +159,8 @@ partial interface Window { void debug(DOMString arg); void gc(); void trap(); + [Func="Window::global_is_mozbrowser", Throws] + void openURLInDefaultBrowser(DOMString href); }; // WebDriver extensions diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index a7d2dc608df..2ec36e2793c 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNo 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::error::{Error, ErrorResult, Fallible, report_pending_exception}; use dom::bindings::global::{GlobalRef, global_root_from_object}; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root}; @@ -52,6 +52,7 @@ use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; use net_traits::storage_thread::StorageType; use net_traits::{ResourceThreads, CustomResponseSender}; use num_traits::ToPrimitive; +use open; use profile_traits::mem; use profile_traits::time::{ProfilerCategory, TimerMetadata, TimerMetadataFrameType}; use profile_traits::time::{ProfilerChan, TimerMetadataReflowType, profile}; @@ -839,6 +840,17 @@ impl WindowMethods for Window { fn SetStatus(&self, status: DOMString) { *self.status.borrow_mut() = status } + + // check-tidy: no specs after this line + fn OpenURLInDefaultBrowser(&self, href: DOMString) -> ErrorResult { + let url = try!(Url::parse(&href).map_err(|e| { + Error::Type(format!("Couldn't parse URL: {}", e)) + })); + match open::that(url.as_str()) { + Ok(_) => Ok(()), + Err(e) => Err(Error::Type(format!("Couldn't open URL: {}", e))), + } + } } pub trait ScriptHelpers { diff --git a/components/script/lib.rs b/components/script/lib.rs index e647003e860..af6d3b2a9c0 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -59,6 +59,7 @@ extern crate msg; extern crate net_traits; extern crate num_traits; extern crate offscreen_gl_context; +extern crate open; extern crate phf; #[macro_use] extern crate profile_traits; diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 8f2d799739a..c27228c2cc2 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1566,6 +1566,11 @@ dependencies = [ "x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "open" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl" version = "0.7.13" @@ -1878,6 +1883,7 @@ dependencies = [ "net_traits 0.0.1", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index f75bfa0d065..5c20ab160e1 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1444,6 +1444,11 @@ dependencies = [ "x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "open" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl" version = "0.7.13" @@ -1736,6 +1741,7 @@ dependencies = [ "net_traits 0.0.1", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 092445335dc..056f2c398fd 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -1432,6 +1432,11 @@ dependencies = [ "x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "open" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl" version = "0.7.13" @@ -1724,6 +1729,7 @@ dependencies = [ "net_traits 0.0.1", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1",