Re: [gwt-contrib] Re: Give a better error message when RunAsyncCode.runAsyncCode is passed something
Yeah.. just remember someone might also do funky things with the passed-in class literal, like .getName() or == Foo.class. So most likely it needs to wrap the real class object and generate "unbox" code if you use the literal itself. On Thu, Mar 11, 2010 at 2:28 AM, Ray Cromwell wrote: > On Wed, Mar 10, 2010 at 9:48 PM, Scott Blum wrote: > > > Well, you could conservatively throw out these cases and require the > > annotation to carry forward. But to me the real problem in our current > > compiler is > > makeIt(Foo.class); > > makeIf(Bar.class); > > public Type makeIt(@IsLiteral Class clazzLiteral) { > > <200 lines of code> > > Type x = GWT.create(clazzLiteral); // How to implement? Runtime > switch > > based on all possible call sites? > > <203 lines of code> > > return x; > > } > > > > Huh, I guess that would work. Maybe I answered the question in asking > it. > > My proposal for doing this, at least in WebMode, is based on my > @GwtCreate idea, which is that a method invoking GWT.create() on > non-literals would itself be recognized as a GWT.create() method, if > so, then there are two possible transformations to implement this > (other than runtime switch) > > #1 Rewrite makeIt(Foo.class) into > Type x = GWT.create(Foo.class); > makeIt(x); // change makeIt's first parameter from Class literal to > instance > public Type makeIt(Type instance); > > change body assignment from > Type x = GWT.create(clazzLiteral); > to > Type x = instance; > > This however has a subtle difference in semantics, in that the call to > GWT.create() has essentially been hoisted out of the method, and > therefore, the order of execution has been changed. Won't matter if > the return object's clinit/init doesn't depend on anything that > makeIt() does. > > Proposal #2 (Matt Mastracci's suggestion): Use a factory > Type x = makeIt(Foo.class); > > rewritten as: > interace Factory { > Type create(); > } > > makeIt(new Factory() { > public Type create() { > return GWT.create(Foo.class); > } > }); > > public Type makeIt(Factory factory) { > // ... code > Type x = factory.create(); > } > > These have the benefit of being understood as syntactic sugar, and > working within the existing compiler infrastructure with few changes. > > -Ray > > -- > http://groups.google.com/group/Google-Web-Toolkit-Contributors > -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: allow skipping unit tests in development or production mode
On Wed, Mar 10, 2010 at 7:17 PM, wrote: > LGTM on this quick and dirty solution. Eventually, we do want something > like John suggests -- it is mostly up to you to either go with this or > the general solution. I feel the same way. A quick and dirty solution would be very valuable so that I can add tests for the cross-site linker. However, it looks like we ultimately want to support an or of a bunch of ands. Did you review the implementation, Amit? So far everyone is okay with the API as something to work with for now. Lex -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: allow skipping unit tests in development or production mode
yeah the implementation looks fine On Mar 11, 2010 8:32 AM, "Lex Spoon" wrote: On Wed, Mar 10, 2010 at 7:17 PM, wrote: > > LGTM on this quick and dirty sol... I feel the same way. A quick and dirty solution would be very valuable so that I can add tests for the cross-site linker. However, it looks like we ultimately want to support an or of a bunch of ands. Did you review the implementation, Amit? So far everyone is okay with the API as something to work with for now. Lex -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Date adds an hour to the day before Daylight Saving
Reviewers: Dan Rice, Description: The emul version of java.util.Date can add an extra hour to the day before daylight savings time if setMinutes() or setSeconds is called. The problem is that we compare the new javascript hours to the expected hours to see if the hours are equal, but the expected hours is a double instead of an int so they are never equal. Fix: We now truncate the expected hours to an int. Testing: I added a unit test. Please review this at http://gwt-code-reviews.appspot.com/174801 Affected files: user/super/com/google/gwt/emul/java/util/Date.java user/test/com/google/gwt/emultest/java/util/DateTest.java Index: user/test/com/google/gwt/emultest/java/util/DateTest.java === --- user/test/com/google/gwt/emultest/java/util/DateTest.java (revision 7701) +++ user/test/com/google/gwt/emultest/java/util/DateTest.java (working copy) @@ -143,6 +143,39 @@ } } + /** + * Tests that if daylight savings time occurs tomorrow, the current date isn't + * affected. + */ + public void testClockForwardNextDay() { +int[] monthDayHour = new int[3]; +if (!findClockForwardTime(2009, monthDayHour)) { + return; +} + +int month = monthDayHour[0]; +int day = monthDayHour[1] - 1; // Day before. +int hour = 12; // Noon. +Date d = new Date(2009 - 1900, month, day, hour, 0, 0); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the minutes, which triggers fixDaylightSavings. +d.setMinutes(10); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the seconds, which triggers fixDaylightSavings. +d.setSeconds(10); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the minutes by more than an hour. +d.setMinutes(80); +assertEquals(day, d.getDate()); +assertEquals(hour + 1, d.getHours()); + } + /** Testing for public java.lang.Object java.util.Date.clone(). */ public void testClone() { Index: user/super/com/google/gwt/emul/java/util/Date.java === --- user/super/com/google/gwt/emul/java/util/Date.java (revision 7701) +++ user/super/com/google/gwt/emul/java/util/Date.java (working copy) @@ -229,7 +229,8 @@ public native void setMinutes(int minutes) /*-{ th...@java.util.date::checkJsDate()(); -var hours = th...@java.util.date::jsdate.getHours() + minutes / 60; +// Truncate minutes to int. +var hours = th...@java.util.date::jsdate.getHours() + ~~(minutes / 60); th...@java.util.date::jsdate.setMinutes(minutes); th...@java.util.date::fixDaylightSavings(I)(hours); }-*/; @@ -243,7 +244,8 @@ public native void setSeconds(int seconds) /*-{ th...@java.util.date::checkJsDate()(); -var hours = th...@java.util.date::jsdate.getHours() + seconds / (60 * 60); +// Truncate seconds to int. +var hours = th...@java.util.date::jsdate.getHours() + ~~(seconds / (60 * 60)); th...@java.util.date::jsdate.setSeconds(seconds); th...@java.util.date::fixDaylightSavings(I)(hours); }-*/; -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] DO NOT SUBMIT
Reviewers: fabbott, Description: DO NOT SUBMIT Please review this at http://gwt-code-reviews.appspot.com/175801 Affected files: A hello.txt Index: hello.txt === --- hello.txt (revision 0) +++ hello.txt (revision 0) @@ -0,0 +1 @@ +hello -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Changes for crawling:
http://gwt-code-reviews.appspot.com/161801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Changes for crawling:
On 2010/03/11 16:45:34, kathrin wrote: Hi Amit, after a lengthy discussion with Joel, we decided to get rid of the CrawlableHyperlink widget. The issue is that it doesn't add enough useful functionality, because the app writer still needs to handle the "!" when actually "navigating" the app to a history state. For this reason, we will recommend that people do this process manually, which is the same amount of work. I got rid of the widget and made the necessary changes to Showcase - could you have another look? Thanks! kathrin http://gwt-code-reviews.appspot.com/161801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Changes for crawling:
LGTM -- I assume you have checked that it still works correctly. The only minor comment I have is extracting out the string constant "!" used at two places. http://gwt-code-reviews.appspot.com/161801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
Re: [gwt-contrib] Re: Changes for crawling:
On Thu, Mar 11, 2010 at 11:48 AM, wrote: > after a lengthy discussion with Joel, we decided to get rid of the > CrawlableHyperlink widget. The issue is that it doesn't add enough > useful functionality, because the app writer still needs to handle the > "!" when actually "navigating" the app to a history state. For this > reason, we will recommend that people do this process manually, which is > the same amount of work. > I think eventually we want to have more structured history support built on top of the basic solution to getting/storing the hash fragment, such as support for tag/values and/or hierarchical history values. At that point, we should consider crawlable history states and revisit making Hyperlink smarter about supporting them (either directly or via CrawlableHyperlink). -- John A. Tamplin Software Engineer (GWT), Google -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Adding missing package descriptions to javadoc
Reviewers: cramsdale, doog, Description: Some packages appear in JavaDoc but do not have descriptions. This patch adds descriptions. Please review this at http://gwt-code-reviews.appspot.com/176801 Affected files: dev/core/src/com/google/gwt/core/linker/package.html user/src/com/google/gwt/i18n/client/constants/package.html user/src/com/google/gwt/i18n/rebind/package.html user/src/com/google/gwt/i18n/server/package.html user/src/com/google/gwt/i18n/shared/package.html user/src/com/google/gwt/jsonp/client/package.html user/src/com/google/gwt/resources/client/package.html user/src/com/google/gwt/resources/ext/package.html user/src/com/google/gwt/rpc/client/package.html user/src/com/google/gwt/rpc/server/package.html user/src/com/google/gwt/uibinder/client/package-info.java -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] RR : Add check for permutation header to RemoteServiceServlet
Reviewers: Ray Ryan, Message: Review requested. Description: Re-add the check that was removed in r5731, but allow the behavior to be overridden. Please review this at http://gwt-code-reviews.appspot.com/179801 Affected files: M user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java Index: user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java diff --git a/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java b/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java index 86c39b5a328f496ccf2bbd3a638767f283f9b373..9e8036debe497c488cb24c277384cff5df509bfe 100644 --- a/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java +++ b/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java @@ -181,6 +181,9 @@ public class RemoteServiceServlet extends AbstractRemoteServiceServlet * exception (the exception will be the one thrown by the service) */ public String processCall(String payload) throws SerializationException { +// First, check for possible XSRF situation +checkPermutationStrongName(); + try { RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this); onAfterRequestDeserialized(rpcRequest); @@ -232,6 +235,24 @@ public class RemoteServiceServlet extends AbstractRemoteServiceServlet } /** + * This method is called by {...@link #processCall(String)} and will throw a + * SecurityException if {...@link #getPermutationStrongName()} returns + * null. This method can be overridden to be a no-op if there are + * clients that are not expected to provide the + * {...@value com.google.gwt.user.client.rpc.RpcRequestBuilder#STRONG_NAME_HEADER} + * header. + * + * @throws SecurityException if {...@link #getPermutationStrongName()} returns + * null + */ + protected void checkPermutationStrongName() throws SecurityException { +if (getPermutationStrongName() == null) { + throw new SecurityException( + "Blocked request without GWT permutation header (XSRF attack?)"); +} + } + + /** * Gets the {...@link SerializationPolicy} for given module base URL and strong * name if there is one. * -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: RR : Add check for permutation header to RemoteServiceServlet
LGTM http://gwt-code-reviews.appspot.com/179801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Adding missing package descriptions to javadoc
LGTM http://gwt-code-reviews.appspot.com/176801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] gflow nested switch statements
Reviewers: Lex, Description: Fixing gflow nested switch CFG generation Added couple of tostrings to aid in debugging. Please review this at http://gwt-code-reviews.appspot.com/180801 Affected files: dev/core/src/com/google/gwt/dev/jjs/impl/gflow/AnalysisSolver.java dev/core/src/com/google/gwt/dev/jjs/impl/gflow/cfg/CfgBuilder.java dev/core/src/com/google/gwt/dev/jjs/impl/gflow/constants/ConstantConditionTransformation.java dev/core/src/com/google/gwt/dev/jjs/impl/gflow/constants/FoldConstantsTransformation.java dev/core/src/com/google/gwt/dev/jjs/impl/gflow/unreachable/DeleteNodeTransformation.java dev/core/test/com/google/gwt/dev/jjs/impl/OptimizerTestBase.java dev/core/test/com/google/gwt/dev/jjs/impl/gflow/DataflowOptimizerTest.java dev/core/test/com/google/gwt/dev/jjs/impl/gflow/cfg/CfgBuilderTest.java -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Fixes polymorphic native methods appearing twice
LGTM http://gwt-code-reviews.appspot.com/177801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Reimplement java.util.Date in Java
Reviewers: Dan Rice, jat, jlabanca, Message: This also fixes the division-resulting-in-float issues. Please review this at http://gwt-code-reviews.appspot.com/181801 Affected files: M user/super/com/google/gwt/emul/java/util/Date.java -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: gflow nested switch statements
LGTM http://gwt-code-reviews.appspot.com/180801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
LGTM with nits. Thanks for doing this! http://gwt-code-reviews.appspot.com/181801/diff/1/2 File user/super/com/google/gwt/emul/java/util/Date.java (right): http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode285 Line 285: return (int) (time ^ (getTime() >>> 32)); 'getTime()' can be changed to 'time' http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode343 Line 343: String hourOffset = (offset >= 0) ? "+" : "" + (offset / 60); Parens around the ?: expression would be nice http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
http://gwt-code-reviews.appspot.com/181801/diff/1/2 File user/super/com/google/gwt/emul/java/util/Date.java (right): http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode27 Line 27: static class JsDate extends JavaScriptObject { This would be a handy public type. Especially if I could do something like this without resorting to the violator pattern like I do now (in code you're about to break, sigh): Date d = JsDate.create(123456.78).asJavaDate(); I suppose that's a bit circular, but I won't tell if you don't. http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
Sorry for the patch spam. v4 should be good to go! http://gwt-code-reviews.appspot.com/181801/diff/1/2 File user/super/com/google/gwt/emul/java/util/Date.java (right): http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode27 Line 27: static class JsDate extends JavaScriptObject { Hehe, let's consider this in a follow-up. http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode285 Line 285: return (int) (time ^ (getTime() >>> 32)); Whoops, good call. I forgot I unchecked the 'replace all occurrences' when pulling out locals. http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode343 Line 343: String hourOffset = (offset >= 0) ? "+" : "" + (offset / 60); On 2010/03/11 19:35:23, Dan Rice wrote: Parens around the ?: expression would be nice Done. http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
Can you add the new test in DateTest from this patch: http://gwt-code-reviews.appspot.com/174801/show http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
Just submit yours first. I'll merge in your changes. On Thu, Mar 11, 2010 at 3:05 PM, wrote: > Can you add the new test in DateTest from this patch: > http://gwt-code-reviews.appspot.com/174801/show > > > > http://gwt-code-reviews.appspot.com/181801 > -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
http://gwt-code-reviews.appspot.com/181801/diff/1/2 File user/super/com/google/gwt/emul/java/util/Date.java (right): http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode27 Line 27: static class JsDate extends JavaScriptObject { On 2010/03/11 19:38:08, Ray Ryan wrote: This would be a handy public type. Especially if I could do something like this without resorting to the violator pattern like I do now (in code you're about to break, sigh): Date d = JsDate.create(123456.78).asJavaDate(); I suppose that's a bit circular, but I won't tell if you don't. You would have to move it to someplace outside the JRE, and it would have to only use the public Date API to construct the j.u.Date instance. As it would be a new API, you would have the fun of convincing everyone it was a good idea. All told, I don't think the benefit would be commensurate with the effort. http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
Actually, I'm at an impasse Right now, I'm getting a security exception in hosted mode trying to load up java.util.Date$JsDate. So either I need to move this to a new package, or else make some kind of infrastructure fix Thoughts? On Thu, Mar 11, 2010 at 3:16 PM, wrote: > > http://gwt-code-reviews.appspot.com/181801/diff/1/2 > File user/super/com/google/gwt/emul/java/util/Date.java (right): > > http://gwt-code-reviews.appspot.com/181801/diff/1/2#newcode27 > Line 27: static class JsDate extends JavaScriptObject { > On 2010/03/11 19:38:08, Ray Ryan wrote: > >> This would be a handy public type. Especially if I could do something >> > like this > >> without resorting to the violator pattern like I do now (in code >> > you're about to > >> break, sigh): >> > > Date d = JsDate.create(123456.78).asJavaDate(); >> > > I suppose that's a bit circular, but I won't tell if you don't. >> > > You would have to move it to someplace outside the JRE, and it would > have to only use the public Date API to construct the j.u.Date instance. > > As it would be a new API, you would have the fun of convincing everyone > it was a good idea. > > All told, I don't think the benefit would be commensurate with the > effort. > > > http://gwt-code-reviews.appspot.com/181801 > -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
On Thu, Mar 11, 2010 at 3:21 PM, Scott Blum wrote: > Actually, I'm at an impasse > > Right now, I'm getting a security exception in hosted mode trying to load > up java.util.Date$JsDate. So either I need to move this to a new package, > or else make some kind of infrastructure fix > > Thoughts? > Why is JsDate even being referenced in devmode? In that case, you should be running the stock JRE j.u.Date which has no such reference (nor the nested class). -- John A. Tamplin Software Engineer (GWT), Google -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
LGTM http://gwt-code-reviews.appspot.com/181801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Reimplement java.util.Date in Java
On Thu, Mar 11, 2010 at 3:29 PM, John Tamplin wrote: > Why is JsDate even being referenced in devmode? In that case, you should > be running the stock JRE j.u.Date which has no such reference (nor the > nested class). > It's just has to do with how JSOs are implemented in hosted mode. However, it's a moot point. Joel has convinced me to implement this as: com.google.gwt.core.client.JsDate Review coming shortly. -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Implements a native JsDate
Reviewers: jgw, Ray Ryan, Message: Okay, I went ahead and did the grunge work. :D Please review this at http://gwt-code-reviews.appspot.com/182801 Affected files: A user/src/com/google/gwt/core/client/JsDate.java -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Fixes polymorphic native methods appearing twice
Yikes, weird how it passes we mode tests. I guess I never ran it with emulation turned on. On 2010/03/11 19:07:31, Lex wrote: LGTM http://gwt-code-reviews.appspot.com/177801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Implements a native JsDate
Thank you! But…I think I'm supposed to ask you for a unit test of this thing. Especially one that would have caught the problem below. http://gwt-code-reviews.appspot.com/182801/diff/1/2 File user/src/com/google/gwt/core/client/JsDate.java (right): http://gwt-code-reviews.appspot.com/182801/diff/1/2#newcode396 Line 396: return this.setDate(dayOfMonth); Shouldn't this and below be setUTCDate, etc.? http://gwt-code-reviews.appspot.com/182801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: Implements a native JsDate
http://gwt-code-reviews.appspot.com/182801/diff/1/2 File user/src/com/google/gwt/core/client/JsDate.java (right): http://gwt-code-reviews.appspot.com/182801/diff/1/2#newcode396 Line 396: return this.setDate(dayOfMonth); Oops, yeah. Will fix. As far as testing, it will get somewhat testing by a new implementation of java.util.Date. But jgw said if I add a bug, he'll go back and finish up later. http://gwt-code-reviews.appspot.com/182801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] One-line fix to SelectionScript's fallback logic for
Reviewers: cromwellian, Description: One-line fix to SelectionScript's fallback logic for non-shardable subclasses. Please review this at http://gwt-code-reviews.appspot.com/183801 Affected files: M dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java Index: dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java === --- dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java (revision 7701) +++ dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java (working copy) @@ -117,7 +117,7 @@ public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException { ArtifactSet toReturn = link(logger, context, artifacts, true); -toReturn = link(logger, context, artifacts, false); +toReturn = link(logger, context, toReturn, false); return toReturn; } -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: One-line fix to SelectionScript's fallback logic for
Can you review this, Ray? The second call to link() should start with the results of the first call to link(). http://gwt-code-reviews.appspot.com/183801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: One-line fix to SelectionScript's fallback logic for
LGTM http://gwt-code-reviews.appspot.com/183801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] Re: One-line fix to SelectionScript's fallback logic for
LGTM. On a side note, is there a way to write a test case for this? http://gwt-code-reviews.appspot.com/183801 -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
Re: [gwt-contrib] Re: One-line fix to SelectionScript's fallback logic for
+1 to Ray's question. I know that you were simply doing a fix Lex, but we need to think about how we test these "features". On Thu, Mar 11, 2010 at 9:49 PM, wrote: > > LGTM. On a side note, is there a way to write a test case for this? > > > http://gwt-code-reviews.appspot.com/183801 > > -- > http://groups.google.com/group/Google-Web-Toolkit-Contributors > -- Miguel -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] [google-web-toolkit] r7702 committed - Checkpoint
Revision: 7702 Author: r...@google.com Date: Thu Mar 11 03:44:25 2010 Log: Checkpoint http://code.google.com/p/google-web-toolkit/source/detail?r=7702 Added: /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/ProfitLossCell.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/ChangeCell.java Modified: /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java /trunk/bikeshed/src/com/google/gwt/bikeshed/list/client/Header.java /trunk/bikeshed/src/com/google/gwt/bikeshed/list/client/TextHeader.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/Columns.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/TransactionTreeViewModel.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/PlayerStatus.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/StockServiceImpl.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuote.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockResponse.java /trunk/bikeshed/src/com/google/gwt/bikeshed/tree/client/SideBySideTreeView.java /trunk/bikeshed/src/com/google/gwt/bikeshed/tree/client/StandardTreeView.java /trunk/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNode.java /trunk/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java /trunk/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeView.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/domain/Storage.java /trunk/bikeshed/test/com/google/gwt/sample/expenses/domain/EntityTester.java === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/ProfitLossCell.java Thu Mar 11 03:44:25 2010 @@ -0,0 +1,50 @@ +/* + * Copyright 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.bikeshed.cells.client; + +/** + * A {...@link Cell} used to render currency. Positive values are shown in green + * with a "+" sign and negative values are shown in red with a "-" sign. + */ +public class ProfitLossCell extends Cell { + + @Override + public void render(Integer priceDelta, StringBuilder sb) { +boolean negative = priceDelta < 0; +if (negative) { + priceDelta = -priceDelta; +} +int dollars = priceDelta / 100; +int cents = priceDelta % 100; + +sb.append(" "); +} else if (negative) { + sb.append("red\">-"); +} else { + sb.append("green\">+"); +} +sb.append("$"); +sb.append(dollars); +sb.append('.'); +if (cents < 10) { + sb.append('0'); +} +sb.append(cents); +sb.append(""); + } +} === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/ChangeCell.java Thu Mar 11 03:44:25 2010 @@ -0,0 +1,36 @@ +/* + * Copyright 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.bikeshed.sample.stocks.client; + +import com.google.gwt.bikeshed.cells.client.Cell; + +/** + * A cell that represents a {...@link StockQuote}. + */ +public class ChangeCell extends Cell { + + @Override + public void render(String value, StringBuilder sb) { +sb.append(""); +} else { + sb.append("green\">"); +} +sb.append(value); +sb.append(""); + } +} === --- /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java Fri Feb 26 09:32:06 2010 +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java Thu Mar 11 03:44:25 2010 @@ -22,10 +22,17 @@ @Override public void render(Integer price, StringBuilder sb) { +boolean negative = price < 0; +if (negative) { + price = -price; +} int dollars = price / 100; int
[gwt-contrib] [google-web-toolkit] r7703 committed - Re-add the checkt that was removed in r5731, but allow the behavior to...
Revision: 7703 Author: b...@google.com Date: Thu Mar 11 08:37:52 2010 Log: Re-add the checkt that was removed in r5731, but allow the behavior to be overridden. http://gwt-code-reviews.appspot.com/179801/show Review by: rj...@google.com http://code.google.com/p/google-web-toolkit/source/detail?r=7703 Modified: /trunk/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java === --- /trunk/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java Tue Dec 22 09:01:01 2009 +++ /trunk/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java Thu Mar 11 08:37:52 2010 @@ -181,6 +181,9 @@ * exception (the exception will be the one thrown by the service) */ public String processCall(String payload) throws SerializationException { +// First, check for possible XSRF situation +checkPermutationStrongName(); + try { RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this); onAfterRequestDeserialized(rpcRequest); @@ -230,6 +233,24 @@ // writeResponse(request, response, responsePayload); } + + /** + * This method is called by {...@link #processCall(String)} and will throw a + * SecurityException if {...@link #getPermutationStrongName()} returns + * null. This method can be overridden to be a no-op if there are + * clients that are not expected to provide the + * {...@value com.google.gwt.user.client.rpc.RpcRequestBuilder#STRONG_NAME_HEADER} + * header. + * + * @throws SecurityException if {...@link #getPermutationStrongName()} returns + * null + */ + protected void checkPermutationStrongName() throws SecurityException { +if (getPermutationStrongName() == null) { + throw new SecurityException( + "Blocked request without GWT permutation header (XSRF attack?)"); +} + } /** * Gets the {...@link SerializationPolicy} for given module base URL and strong -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
[gwt-contrib] [google-web-toolkit] r7704 committed - Lots of prettier styles for the stock sample.
Revision: 7704 Author: j...@google.com Date: Thu Mar 11 08:39:56 2010 Log: Lots of prettier styles for the stock sample. http://code.google.com/p/google-web-toolkit/source/detail?r=7704 Added: /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/EllipsisCell.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/FavoritesWidget.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/FavoritesWidget.ui.xml /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQueryWidget.ui.xml /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.ui.xml /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/common.css /trunk/bikeshed/war/bg.png /trunk/bikeshed/war/blueborder.png /trunk/bikeshed/war/border.png Modified: /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/StockSample.gwt.xml /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/Columns.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQueryWidget.java /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.java /trunk/bikeshed/war/Stocks.css === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/cells/client/EllipsisCell.java Thu Mar 11 08:39:56 2010 @@ -0,0 +1,26 @@ +/* + * Copyright 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.bikeshed.cells.client; + +public class EllipsisCell extends Cell { + + @Override + public void render(String value, StringBuilder sb) { +sb.append(""); +sb.append(value); +sb.append(""); + } +} === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/FavoritesWidget.java Thu Mar 11 08:39:56 2010 @@ -0,0 +1,55 @@ +/* + * Copyright 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.bikeshed.sample.stocks.client; + +import com.google.gwt.bikeshed.list.client.PagingTableListView; +import com.google.gwt.bikeshed.list.client.TextHeader; +import com.google.gwt.bikeshed.list.shared.ListModel; +import com.google.gwt.bikeshed.sample.stocks.shared.StockQuote; +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiFactory; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +public class FavoritesWidget extends Composite { + + interface Binder extends UiBinder { } + private static final Binder binder = GWT.create(Binder.class); + + @UiField PagingTableListView listView; + + private final ListModel model; + + public FavoritesWidget(ListModel model) { +this.model = model; +initWidget(binder.createAndBindUi(this)); + +listView.addColumn(Columns.tickerColumn, new TextHeader("ticker")); +listView.addColumn(Columns.priceColumn, new TextHeader("price")); +listView.addColumn(Columns.changeColumn, new TextHeader("change")); +listView.addColumn(Columns.sharesColumn, new TextHeader("shares")); +listView.addColumn(Columns.dollarsColumn, new TextHeader("value")); +listView.addColumn(Columns.buyColumn); +listView.addColumn(Columns.sellColumn); + } + + @UiFactory + PagingTableListView createListView() { +return new PagingTableListView(model, 10); + } +} === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/FavoritesWidget.ui.xml Thu Mar 11 08:39:56 2010 @@ -0,0 +1,19 @@ + + + + + + + Portfolio / Favorites + + + + styleName='{common.table}'/> + + + === --- /dev/null +++ /trunk/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQueryWidget.ui.xml Th
[gwt-contrib] [google-web-toolkit] r7705 committed - Date can add an hour to the day before Daylight Saving....
Revision: 7705 Author: jlaba...@google.com Date: Thu Mar 11 09:27:25 2010 Log: Date can add an hour to the day before Daylight Saving. http://gwt-code-reviews.appspot.com/174801 Review by: r...@google.com http://code.google.com/p/google-web-toolkit/source/detail?r=7705 Modified: /trunk/user/super/com/google/gwt/emul/java/util/Date.java /trunk/user/test/com/google/gwt/emultest/java/util/DateTest.java === --- /trunk/user/super/com/google/gwt/emul/java/util/Date.java Wed Nov 4 13:53:54 2009 +++ /trunk/user/super/com/google/gwt/emul/java/util/Date.java Thu Mar 11 09:27:25 2010 @@ -229,7 +229,8 @@ public native void setMinutes(int minutes) /*-{ th...@java.util.date::checkJsDate()(); -var hours = th...@java.util.date::jsdate.getHours() + minutes / 60; +// Truncate (minutes / 60) to int. +var hours = th...@java.util.date::jsdate.getHours() + ~~(minutes / 60); th...@java.util.date::jsdate.setMinutes(minutes); th...@java.util.date::fixDaylightSavings(I)(hours); }-*/; @@ -243,7 +244,8 @@ public native void setSeconds(int seconds) /*-{ th...@java.util.date::checkJsDate()(); -var hours = th...@java.util.date::jsdate.getHours() + seconds / (60 * 60); +// Truncate (seconds / (60 * 60)) to int. +var hours = th...@java.util.date::jsdate.getHours() + ~~(seconds / (60 * 60)); th...@java.util.date::jsdate.setSeconds(seconds); th...@java.util.date::fixDaylightSavings(I)(hours); }-*/; @@ -348,7 +350,9 @@ d.setDate(d.getDate() + 1); var loff = d.getTimezoneOffset(); var timeDiff = noff - loff; - + var timeDiffHours = ~~(timeDiff / 60); + var timeDiffMinutes = timeDiff % 60; + // If the time zone offset is changing, advance the hours and // minutes from the initially requested time by the change amount if (timeDiff > 0) { @@ -358,12 +362,12 @@ var badHours = th...@java.util.date::jsdate.getHours(); var minute = th...@java.util.date::jsdate.getMinutes(); var second = th...@java.util.date::jsdate.getSeconds(); -if (badHours + timeDiff / 60 >= 24) { +if (badHours + timeDiffHours >= 24) { day++; } var newTime = new Date(year, month, day, -hours + timeDiff / 60, -minute + timeDiff % 60, second); +hours + timeDiffHours, +minute + timeDiffMinutes, second); th...@java.util.date::jsdate.setTime(newTime.getTime()); } } === --- /trunk/user/test/com/google/gwt/emultest/java/util/DateTest.java Wed Nov 4 13:53:54 2009 +++ /trunk/user/test/com/google/gwt/emultest/java/util/DateTest.java Thu Mar 11 09:27:25 2010 @@ -142,6 +142,39 @@ } } } + + /** + * Tests that if daylight savings time occurs tomorrow, the current date isn't + * affected. + */ + public void testClockForwardNextDay() { +int[] monthDayHour = new int[3]; +if (!findClockForwardTime(2009, monthDayHour)) { + return; +} + +int month = monthDayHour[0]; +int day = monthDayHour[1] - 1; // Day before. +int hour = monthDayHour[2]; +Date d = new Date(2009 - 1900, month, day, hour, 0, 0); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the minutes, which triggers fixDaylightSavings. +d.setMinutes(10); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the seconds, which triggers fixDaylightSavings. +d.setSeconds(10); +assertEquals(day, d.getDate()); +assertEquals(hour, d.getHours()); + +// Change the minutes by more than an hour. +d.setMinutes(80); +assertEquals(day, d.getDate()); +assertEquals(hour + 1, d.getHours()); + } /** Testing for public java.lang.Object java.util.Date.clone(). */ public void testClone() { -- http://groups.google.com/group/Google-Web-Toolkit-Contributors