Bug 5906 - webkit.org should explain how to detect the latest nightly
Summary: webkit.org should explain how to detect the latest nightly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Website (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P4 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-01 10:22 PST by Eric Seidel (no email)
Modified: 2007-01-08 15:13 PST (History)
1 user (show)

See Also:


Attachments
js library (1.70 KB, patch)
2007-01-06 16:10 PST, Geoffrey Garen
no flags Details | Formatted Diff | Diff
sample code (961 bytes, patch)
2007-01-06 16:10 PST, Geoffrey Garen
darin: review-
Details | Formatted Diff | Diff
js library (1.95 KB, patch)
2007-01-06 16:19 PST, Geoffrey Garen
darin: review-
Details | Formatted Diff | Diff
sample code (949 bytes, patch)
2007-01-07 12:29 PST, Geoffrey Garen
darin: review+
Details | Formatted Diff | Diff
js library (2.30 KB, patch)
2007-01-07 12:30 PST, Geoffrey Garen
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2005-12-01 10:22:48 PST
webkit.opendarwin.org should explain how to detect the latest nightly

Some web authors would like to be able to detect that clients are running a more recent version of Safari 
whereby certain bugs they care about are fixed.  It would be great if we could outline a sancioned method 
for this on webkit.opendarwin.org.
Comment 1 Justin Haygood 2005-12-29 09:15:57 PST
(In reply to comment #0)
> webkit.opendarwin.org should explain how to detect the latest nightly
> 
> Some web authors would like to be able to detect that clients are running a
more recent version of Safari 
> whereby certain bugs they care about are fixed.  It would be great if we could
outline a sancioned method 
> for this on webkit.opendarwin.org.

A system much like Gecko could be useful

Gecko uses Gecko/builddate. Where I work at (an online advertisement firm), we
use this heavily to work around some bugs.

Maybe the versioning of WebKit can include its builddate

AppleWebKit/Version.SubVersion.buildDate

Sits can assume the lack of such a Date means an official release.

Like today for instance:

AppleWebKit/Version.SubVersion.build20051229

Comment 2 Mark Rowe (bdash) 2006-06-26 19:48:33 PDT
One issue with changing the user-agent string in this fashion is that it has the potential to break sites that alread parse the user-agent for version information.  It is definitely desirable to be able to detect the SVN revision or similar, but it should be done in such a way that it doesn't interact negatively with existing functionality.
Comment 3 Geoffrey Garen 2007-01-06 14:15:56 PST
Build date seems like a crazy idea to me. We don't want websites to write custom behavior for versions of WebKit that never ship.
Comment 4 Geoffrey Garen 2007-01-06 15:56:49 PST
There some code for this on the Wiki @ http://trac.webkit.org/projects/webkit/wiki/DetectingWebKit.
Comment 5 Geoffrey Garen 2007-01-06 16:10:12 PST
Created attachment 12266 [details]
js library
Comment 6 Geoffrey Garen 2007-01-06 16:10:52 PST
Created attachment 12267 [details]
sample code
Comment 7 Geoffrey Garen 2007-01-06 16:19:22 PST
Created attachment 12268 [details]
js library

I attached the wrong version. Oops.
Comment 8 Geoffrey Garen 2007-01-06 16:19:58 PST
The code I've attached has a number of advantages over the code currently on trac, including proper namespacing, ability to handle dotted minor revision numbers, independent convenience functions separated by, well, function, and more clear naming and documentation at the API level.
Comment 9 Darin Adler 2007-01-06 16:51:10 PST
Comment on attachment 12268 [details]
js library

I don't think that "AppleWebKit" is the right string to search for. I suggest searching for " AppleWebKit/" instead.

I suggest breaking the version number string into a list separated by "." rather than using floating point. The version would be an array of integers. A good function would be one that compares two period-separated numbers by searching through each of them a period time. That's how I'd like to compare version numbers.
Comment 10 Darin Adler 2007-01-06 17:05:23 PST
Comment on attachment 12267 [details]
sample code

    log("You browser " + (isWebKit ? "uses " : "does not use ") + "WebKit.\n");

Typo here "You" instead of "Your".

I'd like versionIsAtLeast to take a string parameter instead of two integers.
Comment 11 Geoffrey Garen 2007-01-07 12:29:12 PST
Created attachment 12283 [details]
sample code

fixed typo
Comment 12 Geoffrey Garen 2007-01-07 12:30:35 PST
Created attachment 12284 [details]
js library

Changed search to AppleWebKit/, changed version to return an array of "." separated numbers.
Comment 13 Geoffrey Garen 2007-01-07 12:32:00 PST
Also changed versionIsAtLeast to take a string parameter.
Comment 14 Darin Adler 2007-01-07 21:10:21 PST
Comment on attachment 12284 [details]
js library

r=me -- a few small thoughts about refinement

>    return RegExp("AppleWebKit/").test(navigator.userAgent);
>    var webKitFields = RegExp("(.*AppleWebKit/)([^ ]*)").exec(navigator.userAgent);

I think you should require a space before AppleWebKit in both of these regular expressions. Also, I suggest using a + rather than a * in the version number part of the expression.

>        return undefined;

Generally I'd suggest returning null instead of undefined. I think undefined should be reserved for the meaning "this isn't defined at all".

> WebKit.versionIsAtLeast = function versionIsAtLeast(minimumString)

Why do the functions themselves have names as well as the name of the property of the WebKit object? Is this helpful?

>    // Defaults to ""
>    minimumString = String(minimumString);

I don't understand the value of this line of code. Are we trying to make this function work if people call with things that aren't strings?

Are you sure that WebKit is the best name for this object? I think it works well for the WebKit.versionXXX functions, but not as well for the WebKit.isWebKit.
Comment 15 Geoffrey Garen 2007-01-08 13:27:29 PST
> >    return RegExp("AppleWebKit/").test(navigator.userAgent);
> >    var webKitFields = RegExp("(.*AppleWebKit/)([^ ]*)").exec(navigator.userAgent);
> 
> I think you should require a space before AppleWebKit in both of these regular
> expressions. Also, I suggest using a + rather than a * in the version number
> part of the expression.

Done.

> >        return undefined;
> 
> Generally I'd suggest returning null instead of undefined. I think undefined
> should be reserved for the meaning "this isn't defined at all".

Done.

> > WebKit.versionIsAtLeast = function versionIsAtLeast(minimumString)
> 
> Why do the functions themselves have names as well as the name of the property
> of the WebKit object? Is this helpful?

It's a preferred style in JavaScript because named functions help with debugging. Imagine:

     var f = WebKit.versionIsAtLeast;
     ...
     log("About to call function: " + f);

> >    // Defaults to ""
> >    minimumString = String(minimumString);
> 
> I don't understand the value of this line of code. Are we trying to make this
> function work if people call with things that aren't strings?

I was, but now I think that was a bad idea.

> Are you sure that WebKit is the best name for this object?

Changed to WebKitDetect. Really, it's intended to be a namespace, not an object.
Comment 16 Geoffrey Garen 2007-01-08 15:13:13 PST
Marking "fixed" to clear from the review queue. I still need to get privileges before I can upload this to trac.