Bug 27351 - [Qt] navigator.platform returns an empty string in Symbian and in Linux platforms
Summary: [Qt] navigator.platform returns an empty string in Symbian and in Linux platf...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: S60 Emulator Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-16 12:24 PDT by Yael
Modified: 2009-07-17 19:09 PDT (History)
1 user (show)

See Also:


Attachments
Patch (1.05 KB, patch)
2009-07-16 12:27 PDT, Yael
staikos: review-
Details | Formatted Diff | Diff
Patch (1.72 KB, patch)
2009-07-16 19:43 PDT, Yael
zecke: review-
Details | Formatted Diff | Diff
Patch (1.79 KB, patch)
2009-07-17 18:23 PDT, Yael
staikos: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yael 2009-07-16 12:24:49 PDT
WEBCORE_NAVIGATOR_PLATFORM is not defined for Symbian and for Linux platforms. the following javascript would fail

<html>
<body >
The name of the operating system of the current browser should be displayed below:<br>
<script type="text/javascript">
document.write(navigator.platform+"<br/>");
</script>
</body>
</html>
Comment 1 Yael 2009-07-16 12:27:27 PDT
Created attachment 32887 [details]
Patch
Comment 2 George Staikos 2009-07-16 12:43:11 PDT
Comment on attachment 32887 [details]
Patch

No reason to believe that PLATFORM(LINUX) is "Linux i686"
Comment 3 Yael 2009-07-16 13:20:08 PDT
I think navigator.platform is very similar to what is in PluginViewQt.cpp line 275:


static const char* MozillaUserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
Comment 4 Yael 2009-07-16 19:43:23 PDT
Created attachment 32911 [details]
Patch

Add #define for Symbian platform.
Use uname to determine the OS name and CPU , but limit it to Linux platform only.
(I am not able to test other platforms).
Comment 5 Simon Hausmann 2009-07-17 06:55:27 PDT
Comment on attachment 32911 [details]
Patch

r=me. Seems consistent with firefox and chromium on linux, too.
Comment 6 Holger Freyther 2009-07-17 09:10:14 PDT
From my reading uname is POSIX.1 so we should guard it with something like PLATFORM(UNIX).
Comment 7 Yael 2009-07-17 09:30:10 PDT
(In reply to comment #6)
> From my reading uname is POSIX.1 so we should guard it with something like
> PLATFORM(UNIX).

I wanted to be on the safe side, so I limited this to Linux based platforms. Some types of Unix might not be 100% POSIX.1 compatible, and I did not want to take the risk.
Comment 8 Jan Alonzo 2009-07-17 14:00:46 PDT
Comment on attachment 32911 [details]
Patch

>  String NavigatorBase::platform() const
>  {
> +#if PLATFORM(LINUX)
> +    struct utsname osname;
> +    int result = uname(&osname);
> +    String platformName;
> +    if (result >= 0) {
> +        platformName = osname.sysname;
> +        platformName += " ";
> +        platformName += osname.machine;
> +    }
> +    return platformName;

Can we please make use of DEFINE_STATIC_LOCAL here for platformName?
Comment 9 Holger Freyther 2009-07-17 18:00:49 PDT
Comment on attachment 32911 [details]
Patch


>  
>  String NavigatorBase::platform() const
>  {
> +#if PLATFORM(LINUX)
> +    struct utsname osname;
> +    int result = uname(&osname);
> +    String platformName;
> +    if (result >= 0) {
> +        platformName = osname.sysname;
> +        platformName += " ";
> +        platformName += osname.machine;
> +    }
> +    return platformName;
> +#else
>      return WEBCORE_NAVIGATOR_PLATFORM;
> +#endif

Jan is right, we should call uname(&osname) exactly once. Yael could you post an updated version of the patch?
Comment 10 Yael 2009-07-17 18:23:32 PDT
Created attachment 32996 [details]
Patch

Use DEFINE_STATIC_LOCAL as requested in comment #8.
Comment 11 Yael 2009-07-17 19:09:51 PDT
landed in 46078