aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/Cargo.toml1
-rw-r--r--components/script/dom/webidls/BrowserElement.webidl8
-rw-r--r--components/script/dom/webidls/Window.webidl2
-rw-r--r--components/script/dom/window.rs14
-rw-r--r--components/script/lib.rs1
5 files changed, 21 insertions, 5 deletions
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/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl
index 2767fa15071..9bb34b90a95 100644
--- a/components/script/dom/webidls/BrowserElement.webidl
+++ b/components/script/dom/webidls/BrowserElement.webidl
@@ -146,16 +146,16 @@ interface BrowserElementPrivileged {
// unsigned long count,
// unsigned long modifiers);
- [Func="Window::global_is_mozbrowser", Throws]
+ [Throws]
void goBack();
- [Func="Window::global_is_mozbrowser", Throws]
+ [Throws]
void goForward();
- [Func="Window::global_is_mozbrowser", Throws]
+ [Throws]
void reload(optional boolean hardReload = false);
- [Func="Window::global_is_mozbrowser", Throws]
+ [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 38c2588749c..dbcd9063aca 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;