From 58c4eb836099904fc9130e039f85ae4d7a3353ca Mon Sep 17 00:00:00 2001 From: Rahul Sharma Date: Tue, 15 Mar 2016 20:25:23 +0530 Subject: [PATCH] implements NavigatorLanguage --- components/script/dom/navigator.rs | 5 +++++ components/script/dom/navigatorinfo.rs | 4 ++++ components/script/dom/webidls/Navigator.webidl | 9 ++++++++- tests/wpt/metadata/html/dom/interfaces.html.ini | 3 --- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 5fa0465d3618..0c255b3a923f 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -65,4 +65,9 @@ impl NavigatorMethods for Navigator { fn AppVersion(&self) -> DOMString { navigatorinfo::AppVersion() } + + // https://html.spec.whatwg.org/multipage/#navigatorlanguage + fn GetLanguage(&self) -> Option { + Some(navigatorinfo::Language()) + } } diff --git a/components/script/dom/navigatorinfo.rs b/components/script/dom/navigatorinfo.rs index 1d86deb45adf..f27e46ed91b7 100644 --- a/components/script/dom/navigatorinfo.rs +++ b/components/script/dom/navigatorinfo.rs @@ -43,3 +43,7 @@ pub fn UserAgent() -> DOMString { pub fn AppVersion() -> DOMString { DOMString::from("4.0") } + +pub fn Language() -> DOMString { + DOMString::from("en-US") +} diff --git a/components/script/dom/webidls/Navigator.webidl b/components/script/dom/webidls/Navigator.webidl index 869eaab9debb..6258900ca49a 100644 --- a/components/script/dom/webidls/Navigator.webidl +++ b/components/script/dom/webidls/Navigator.webidl @@ -8,7 +8,7 @@ interface Navigator { // objects implementing this interface also implement the interfaces given below }; Navigator implements NavigatorID; -//Navigator implements NavigatorLanguage; +Navigator implements NavigatorLanguage; //Navigator implements NavigatorOnLine; //Navigator implements NavigatorContentUtils; //Navigator implements NavigatorStorageUtils; @@ -25,3 +25,10 @@ interface NavigatorID { boolean taintEnabled(); // constant false readonly attribute DOMString userAgent; }; + +// https://html.spec.whatwg.org/multipage/#navigatorlanguage +[NoInterfaceObject/*, Exposed=Window,Worker*/] +interface NavigatorLanguage { + readonly attribute DOMString? language; + //readonly attribute DOMString[] languages; +}; diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 7969f4095d5c..0460b8b57fdb 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -7131,9 +7131,6 @@ [EventTarget interface: calling dispatchEvent(Event) on window.applicationCache with too few arguments must throw TypeError] expected: FAIL - [Navigator interface: attribute language] - expected: FAIL - [Navigator interface: attribute languages] expected: FAIL