diff options
author | bors-servo <metajack+bors@gmail.com> | 2014-10-13 15:21:44 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2014-10-13 15:21:44 -0600 |
commit | 81620d6bce12819db5b97330e48be52674b39ffb (patch) | |
tree | 92ac686ce0e26b763c55c5515f89606c6ad11237 /components/script/dom | |
parent | 6e3c77638723894d5c133bcaec85b442634662f1 (diff) | |
parent | eb5532c781e12382ecdf4db75b2def1f29b82834 (diff) | |
download | servo-81620d6bce12819db5b97330e48be52674b39ffb.tar.gz servo-81620d6bce12819db5b97330e48be52674b39ffb.zip |
auto merge of #3608 : glennw/servo/user-agent-navigator, r=Ms2ger
This also makes command line options available as a global. If we're happy with that change I will go through the rest of the code and update it to avoid passing and cloning the Opts structure.
Diffstat (limited to 'components/script/dom')
-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 { |