Change-Id: Ic4342171ecbdae4b6e6075fa9ed6d4eebe399a87tags/7.6.0.alpha5
@@ -606,7 +606,7 @@ public class ApplicationConfiguration implements EntryPoint { | |||
* | |||
* @param c | |||
*/ | |||
static void runWhenDependenciesLoaded(Command c) { | |||
public static void runWhenDependenciesLoaded(Command c) { | |||
if (dependenciesLoading == 0) { | |||
c.execute(); | |||
} else { |
@@ -64,7 +64,7 @@ public class JavaScriptConnectorHelper { | |||
/** | |||
* The id of the previous response for which state changes have been | |||
* processed. If this is the same as the | |||
* {@link ApplicationConnection#getLastResponseId()}, it means that the | |||
* {@link ApplicationConnection#getLastSeenServerSyncId()}, it means that the | |||
* state change has already been handled and should not be done again. | |||
*/ | |||
private int processedResponseId = -1; | |||
@@ -93,7 +93,7 @@ public class JavaScriptConnectorHelper { | |||
} | |||
private void processStateChanges() { | |||
int lastResponseId = connector.getConnection().getLastResponseId(); | |||
int lastResponseId = connector.getConnection().getLastSeenServerSyncId(); | |||
if (processedResponseId == lastResponseId) { | |||
return; | |||
} |
@@ -252,7 +252,7 @@ public class LayoutManager { | |||
"Can't start a new layout phase before the previous layout phase ends."); | |||
} | |||
if (connection.isUpdatingState()) { | |||
if (connection.getServerMessageHandler().isUpdatingState()) { | |||
// If assertions are enabled, throw an exception | |||
assert false : STATE_CHANGE_MESSAGE; | |||
@@ -1793,7 +1793,7 @@ public class LayoutManager { | |||
/** | |||
* Clean measured sizes which are no longer needed. Only for IE8. | |||
*/ | |||
protected void cleanMeasuredSizes() { | |||
public void cleanMeasuredSizes() { | |||
} | |||
private static Logger getLogger() { |
@@ -67,7 +67,7 @@ public class LayoutManagerIE8 extends LayoutManager { | |||
} | |||
@Override | |||
protected void cleanMeasuredSizes() { | |||
public void cleanMeasuredSizes() { | |||
Profiler.enter("LayoutManager.cleanMeasuredSizes"); | |||
// #12688: IE8 was leaking memory when adding&removing components. |
@@ -108,12 +108,12 @@ public final class ValueMap extends JavaScriptObject { | |||
return this[name]; | |||
}-*/; | |||
native String getAsString(String name) | |||
public native String getAsString(String name) | |||
/*-{ | |||
return '' + this[name]; | |||
}-*/; | |||
native JavaScriptObject getJavaScriptObject(String name) | |||
public native JavaScriptObject getJavaScriptObject(String name) | |||
/*-{ | |||
return this[name]; | |||
}-*/; |
@@ -201,10 +201,10 @@ public class AtmospherePushConnection implements PushConnection { | |||
String extraParams = UIConstants.UI_ID_PARAMETER + "=" | |||
+ connection.getConfiguration().getUIId(); | |||
if (!connection.getCsrfToken().equals( | |||
ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) { | |||
String csrfToken = connection.getServerMessageHandler().getCsrfToken(); | |||
if (!csrfToken.equals(ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) { | |||
extraParams += "&" + ApplicationConstants.CSRF_TOKEN_PARAMETER | |||
+ "=" + connection.getCsrfToken(); | |||
+ "=" + csrfToken; | |||
} | |||
// uri is needed to identify the right connection when closing |
@@ -226,7 +226,7 @@ public abstract class AbstractOrderedLayoutConnector extends | |||
/** | |||
* The id of the previous response for which state changes have been | |||
* processed. If this is the same as the | |||
* {@link ApplicationConnection#getLastResponseId()}, it means that we can | |||
* {@link ApplicationConnection#getLastSeenServerSyncId()}, it means that we can | |||
* skip some quite expensive calculations because we know that the state | |||
* hasn't changed since the last time the values were calculated. | |||
*/ | |||
@@ -422,7 +422,7 @@ public abstract class AbstractOrderedLayoutConnector extends | |||
*/ | |||
private void updateInternalState() { | |||
// Avoid updating again for the same data | |||
int lastResponseId = getConnection().getLastResponseId(); | |||
int lastResponseId = getConnection().getLastSeenServerSyncId(); | |||
if (processedResponseId == lastResponseId) { | |||
return; | |||
} |
@@ -15,11 +15,7 @@ | |||
*/ | |||
package com.vaadin.tests.widgetset.client; | |||
import java.util.Date; | |||
import java.util.logging.Logger; | |||
import com.vaadin.client.ApplicationConnection; | |||
import com.vaadin.client.ValueMap; | |||
import com.vaadin.shared.ApplicationConstants; | |||
import com.vaadin.tests.widgetset.server.csrf.ui.CsrfTokenDisabled; | |||
@@ -34,15 +30,20 @@ import elemental.json.JsonValue; | |||
*/ | |||
public class MockApplicationConnection extends ApplicationConnection { | |||
private static final Logger LOGGER = Logger | |||
.getLogger(MockApplicationConnection.class.getName()); | |||
// The last token received from the server. | |||
private String lastCsrfTokenReceiver; | |||
public MockApplicationConnection() { | |||
super(); | |||
serverMessageHandler = new MockServerMessageHandler(); | |||
serverMessageHandler.setConnection(this); | |||
} | |||
// The last token sent to the server. | |||
private String lastCsrfTokenSent; | |||
@Override | |||
public MockServerMessageHandler getServerMessageHandler() { | |||
return (MockServerMessageHandler) super.getServerMessageHandler(); | |||
} | |||
/** | |||
* Provide the last token received from the server. <br/> | |||
* We added this to test the change done on CSRF token. | |||
@@ -50,7 +51,7 @@ public class MockApplicationConnection extends ApplicationConnection { | |||
* @see CsrfTokenDisabled | |||
*/ | |||
public String getLastCsrfTokenReceiver() { | |||
return lastCsrfTokenReceiver; | |||
return getServerMessageHandler().lastCsrfTokenReceiver; | |||
} | |||
/** | |||
@@ -63,14 +64,6 @@ public class MockApplicationConnection extends ApplicationConnection { | |||
return lastCsrfTokenSent; | |||
} | |||
@Override | |||
protected void handleUIDLMessage(Date start, String jsonText, ValueMap json) { | |||
lastCsrfTokenReceiver = json | |||
.getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); | |||
super.handleUIDLMessage(start, jsonText, json); | |||
} | |||
@Override | |||
public void doUidlRequest(String uri, JsonObject payload, boolean retry) { | |||
JsonValue jsonValue = payload.get(ApplicationConstants.CSRF_TOKEN); |
@@ -0,0 +1,37 @@ | |||
/* | |||
* Copyright 2000-2014 Vaadin Ltd. | |||
* | |||
* 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.vaadin.tests.widgetset.client; | |||
import java.util.Date; | |||
import com.vaadin.client.ValueMap; | |||
import com.vaadin.client.communication.ServerMessageHandler; | |||
import com.vaadin.shared.ApplicationConstants; | |||
public class MockServerMessageHandler extends ServerMessageHandler { | |||
// The last token received from the server. | |||
protected String lastCsrfTokenReceiver; | |||
@Override | |||
public void handleUIDLMessage(Date start, String jsonText, ValueMap json) { | |||
lastCsrfTokenReceiver = json | |||
.getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); | |||
super.handleUIDLMessage(start, jsonText, json); | |||
} | |||
} |
@@ -70,8 +70,8 @@ public class CsrfButtonConnector extends AbstractComponentConnector { | |||
} | |||
private String csrfTokenInfo() { | |||
return getMockConnection().getCsrfToken() + ", " | |||
+ getMockConnection().getLastCsrfTokenReceiver() + ", " | |||
return getMockConnection().getServerMessageHandler().getCsrfToken() | |||
+ ", " + getMockConnection().getLastCsrfTokenReceiver() + ", " | |||
+ getMockConnection().getLastCsrfTokenSent(); | |||
} | |||