Expose user agent option to DOM navigator interface.

This commit is contained in:
Glenn Watson 2014-10-08 12:02:13 +10:00
parent 6317905342
commit eb5532c781
6 changed files with 38 additions and 12 deletions

View file

@ -51,6 +51,10 @@ impl<'a> NavigatorMethods for JSRef<'a, Navigator> {
fn Platform(self) -> DOMString {
NavigatorInfo::Platform()
}
fn UserAgent(self) -> DOMString {
NavigatorInfo::UserAgent()
}
}
impl Reflectable for Navigator {

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use servo_util::str::DOMString;
use servo_util::opts;
pub struct NavigatorInfo;
@ -26,4 +27,11 @@ impl NavigatorInfo {
pub fn Platform() -> DOMString {
"".to_string()
}
pub fn UserAgent() -> DOMString {
match opts::get().user_agent {
Some(ref user_agent) => user_agent.clone(),
None => "".to_string(),
}
}
}

View file

@ -23,5 +23,5 @@ interface NavigatorID {
readonly attribute DOMString platform;
readonly attribute DOMString product; // constant "Gecko"
boolean taintEnabled(); // constant false
//readonly attribute DOMString userAgent;
readonly attribute DOMString userAgent;
};

View file

@ -51,6 +51,10 @@ impl<'a> WorkerNavigatorMethods for JSRef<'a, WorkerNavigator> {
fn Platform(self) -> DOMString {
NavigatorInfo::Platform()
}
fn UserAgent(self) -> DOMString {
NavigatorInfo::UserAgent()
}
}
impl Reflectable for WorkerNavigator {