diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/navigator.rs | 4 | ||||
-rw-r--r-- | components/script/dom/navigatorinfo.rs | 8 | ||||
-rw-r--r-- | components/script/dom/webidls/Navigator.webidl | 2 | ||||
-rw-r--r-- | components/script/dom/workernavigator.rs | 4 |
4 files changed, 17 insertions, 1 deletions
diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 9810c67a877..957abd558ec 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -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 { diff --git a/components/script/dom/navigatorinfo.rs b/components/script/dom/navigatorinfo.rs index 8832aca8697..d8081ef134a 100644 --- a/components/script/dom/navigatorinfo.rs +++ b/components/script/dom/navigatorinfo.rs @@ -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(), + } + } } diff --git a/components/script/dom/webidls/Navigator.webidl b/components/script/dom/webidls/Navigator.webidl index 16d96d53470..0ce509f4c04 100644 --- a/components/script/dom/webidls/Navigator.webidl +++ b/components/script/dom/webidls/Navigator.webidl @@ -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; }; diff --git a/components/script/dom/workernavigator.rs b/components/script/dom/workernavigator.rs index 2265b23c6bc..2d3c496048c 100644 --- a/components/script/dom/workernavigator.rs +++ b/components/script/dom/workernavigator.rs @@ -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 { |