Ways to detect a site is running GWT?

231 views
Skip to first unread message

Joseph Lust

unread,
Nov 9, 2012, 10:16:06 AM11/9/12
to google-we...@googlegroups.com
I really enjoy the extension Library Detector for Chrome since I can see what JS libs a site is running at a glance. However, it does not support GWT. I've forked it to add this functionality and have been trying to think of a good method for testing that a site is using GWT since in reality it is not a library but a framework.

So far I've got:
  1. Look for *.nocache.js files in body - but this could trigger on non GWT sites if someone likes that name/scheme
  2. Check for the __gwt_historyFrame iFrame - sounder
I think method 2 should be sufficient, but know there must be a more robust way. Thanks.


Sincerely,
Joseph

Thomas Broyer

unread,
Nov 9, 2012, 10:51:29 AM11/9/12
to google-we...@googlegroups.com

On Friday, November 9, 2012 4:16:06 PM UTC+1, Joseph Lust wrote:
I really enjoy the extension Library Detector for Chrome since I can see what JS libs a site is running at a glance. However, it does not support GWT. I've forked it to add this functionality and have been trying to think of a good method for testing that a site is using GWT since in reality it is not a library but a framework.

So far I've got:
  1. Look for *.nocache.js files in body - but this could trigger on non GWT sites if someone likes that name/scheme
  2. Check for the __gwt_historyFrame iFrame - sounder
I think method 2 should be sufficient,

Google Groups or Blogger have neither of them.
 
but know there must be a more robust way. Thanks.

My method is to search for $gwt_version somewhere in the resources, but I have no idea if/how that could be done in this extension. Just try it on Google Groups, Blogger and your own GWT app (assuming you're using a built-in primary linker) and you'll find 3 different things.

Another method is to look for the gwt_uid (generated by Document#createUniqueId(), itself used extensively by UiBinder and CellTable), __gwt_activeModules, __gwt_stylesLoaded or __gwt_scriptsLoaded (all three set by *.nocache.js, unless a custom linker has been used).
You'll find out none of Groups or Blogger has the former (which I must say is a bit strange), Groups has activeModules and stylesLoaded, while Blogger has stylesLoaded and scriptsLoaded (uses a custom linker; Groups looks like it uses the xsiframe linker).

Jens

unread,
Nov 9, 2012, 10:53:14 AM11/9/12
to google-we...@googlegroups.com
  1. Look for *.nocache.js files in body - but this could trigger on non GWT sites if someone likes that name/scheme
Can produce false positive as well as false negatives. I think you can rename "nocache" to anything and, like in Google Groups, you don't have to use the *.nocache.js file at all if you have a dynamic index.jsp that can detect the correct permutation right away. In that case you only have a <script> tag that contains the permutation file.
 
  1. Check for the __gwt_historyFrame iFrame - sounder
This iFrame is optional. If you don't want/have History support you don't need it.


A good way to detect GWT apps is to check if window.__gwt_activeModules has been set. Additionally, If it is set, you could read its data and check if an iFrame exists whose id attribute holds the name of the module you check.

Google Groups has an iFrame whose id is "standalone" and if you open up Chroms JS console and you execute 

window.alert(JSON.stringify(window.__gwt_activeModules))

you get:

{"standalone":{"moduleName":"standalone","moduleBase":"https://groups.google.com/forum/"}}

So this should help you a lot.

-- J.

Joseph Lust

unread,
Nov 9, 2012, 11:11:11 AM11/9/12
to google-we...@googlegroups.com
Thanks guys. My apologies as I know my initial suggestions were very superficial an fragile depending on the linker used and implementer preferences, but I knew you would have some robust suggestions.

After looking at hotelme.com, Blogger, Google Groups, and Orkut, all are using two or more of the following:
  • __gwtModuleFunction
  • __gwtInstallCode
  • __getStartLoadingFragment
  • __gwt_activeModules
  • __gwt_stylesLoaded
  • __gwt_scriptsLoaded
I had wondered how GWT InspectorWidget worked and I suspect it is the same mechanism. I'll search for these values on the window object. I'll let you know when the extension is updated for this. Thanks again.

Sincerely,
Joseph

Joseph Lust

unread,
Nov 9, 2012, 12:05:44 PM11/9/12
to google-we...@googlegroups.com
Oh, but one other question, that I'm totally stumped on. Is there any way to get the version of GWT something was compiled with? I'm doubtful that it is even in the compiled output, and would prefer not to come up with a list of objects that changed with different releases to try to guess the version.

Any ideas? Thanks.


Sincerely,
Joseph

Thomas Broyer

unread,
Nov 9, 2012, 12:21:33 PM11/9/12
to google-we...@googlegroups.com


On Friday, November 9, 2012 6:05:44 PM UTC+1, Joseph Lust wrote:
Oh, but one other question, that I'm totally stumped on. Is there any way to get the version of GWT something was compiled with? I'm doubtful that it is even in the compiled output, and would prefer not to come up with a list of objects that changed with different releases to try to guess the version.

It *is* in every compiled permutation (the $gwt_version variable I was talking about), but it's a "private" variable in many cases (in some cases –e.g. Groups– it's even in a String literal that'll then be injected in a <script>, but still private when evaluated, as it uses the so-called "module pattern"). FYI, all Google products are built from "trunk" so they use the default, hard-coded 0.0.999 version.

Joseph Lust

unread,
Nov 9, 2012, 1:10:35 PM11/9/12
to google-we...@googlegroups.com
That was the ticket Thomase. Too bad Google sites don't bother to present the version, but perhaps it is an obscurity/security justification. Still, my point in doing this is to raise GWT awareness, so advertising the presence of GWT is more important than a precise version number.

var gwtVersion = null;
var frames = document.getElementsByTagName('iframe');
for (var i=0; i<frames.length; i++) {
    // prevent security access errors
    try {
        if(frames[i].contentWindow.$gwt_version) {
            gwtVersion = frames[i].contentWindow.$gwt_version;
            break;
        }
    }
    catch(e) {}
}

Sincerely,
Joseph

Thomas Broyer

unread,
Nov 11, 2012, 6:06:16 AM11/11/12
to google-we...@googlegroups.com
There's no version to advertise: Google is known to build everything from "trunk" (the exact revision then depends on when they push changes on production; Groups used to deploy at least once a day for instance)

Joseph Lust

unread,
Nov 11, 2012, 6:41:08 AM11/11/12
to google-we...@googlegroups.com
My apologies for being unclear. Given that the revision number they built with is potentially available, that could be used in some form in $gwt_version such as "0.0.11367". There are plenty of sites where you can find this rev number in their release JS/CSS/etc. Given that information and the historic release tags one could make a simple lookup table to determine approximately what version was used for that Google internal application.

Still, thanks for clarifying my ambiguous statement.

Sincerely,
Joseph

Thomas Broyer

unread,
Nov 11, 2012, 10:14:24 AM11/11/12
to google-we...@googlegroups.com


On Sunday, November 11, 2012 12:41:08 PM UTC+1, Joseph Lust wrote:
My apologies for being unclear. Given that the revision number they built with is potentially available, that could be used in some form in $gwt_version such as "0.0.11367".

Except that (for now at least) the canonical VCS is Perforce, which is then sync'd to SVN (and then to Git). A Perforce revision number wouldn't tell you much things about what's in it.
 
There are plenty of sites where you can find this rev number in their release JS/CSS/etc. Given that information and the historic release tags one could make a simple lookup table to determine approximately what version was used for that Google internal application.

Better assume the version is "trunk" I think, and possibly look at the Last-Modified HTTP header, or document.lastModified in JS (e.g. Moderator tells me it was last modified on Oct. 20th, and the Checkout/Wallet gadget –in-app payment– on Nov. 9th) to get a better view on the "version" of GWT (even though that doesn't mean that much either: I suppose apps pass QA before being deployed to the public, and the lastModified can possibly reflect that last step only; at least you know what revisions it's *not*)

Reply all
Reply to author
Forward
0 new messages