implement navigator.platform

This commit is contained in:
Paul Rouget 2015-09-09 16:19:10 +02:00
parent e68bd8d4ff
commit 132724be2b
3 changed files with 36 additions and 3 deletions

View file

@ -22,8 +22,19 @@ pub fn AppCodeName() -> DOMString {
"Mozilla".to_owned() "Mozilla".to_owned()
} }
#[cfg(target_os = "windows")]
pub fn Platform() -> DOMString { pub fn Platform() -> DOMString {
"".to_owned() "Win32".to_owned()
}
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn Platform() -> DOMString {
"Linux".to_owned()
}
#[cfg(target_os = "macos")]
pub fn Platform() -> DOMString {
"Mac".to_owned()
} }
pub fn UserAgent() -> DOMString { pub fn UserAgent() -> DOMString {

View file

@ -0,0 +1,12 @@
[navigator.html]
type: testharness
[navigator.platform linux]
expected:
if os != "linux": FAIL
PASS
[navigator.platform mac]
expected:
if os != "mac": FAIL
PASS

View file

@ -15,9 +15,19 @@ test(function() {
assert_equals(nav.taintEnabled(), false); assert_equals(nav.taintEnabled(), false);
assert_equals(nav.appName, "Netscape"); assert_equals(nav.appName, "Netscape");
assert_equals(nav.appCodeName, "Mozilla"); assert_equals(nav.appCodeName, "Mozilla");
assert_equals(nav.platform, "");
assert_equals(nav.appVersion, "4.0"); assert_equals(nav.appVersion, "4.0");
}); }, "navigator");
test(function() {
assert_equals(navigator.platform, "Linux");
}, "navigator.platform linux");
test(function() {
assert_equals(navigator.platform, "Mac");
}, "navigator.platform mac");
</script> </script>
</body> </body>
</html> </html>