Thomas Broyer has submitted this change and it was merged.

Change subject: Make sure JUnit's host page run in UTF-8.
......................................................................


Make sure JUnit's host page run in UTF-8.

Bug: issue 8171
Change-Id: Iede26ae4928600473f56e11387e433565486e4e0
---
M user/src/com/google/gwt/junit/public/junit-standards.html
M user/src/com/google/gwt/junit/public/junit.html
M user/test/com/google/gwt/core/client/ScriptInjectorTest.java
A user/test/com/google/gwt/core/public/script_injector_test_utf8.js
M user/test/com/google/gwt/module/ModuleSuite.java
A user/test/com/google/gwt/module/ScriptInjectionEncodingTest.gwt.xml
A user/test/com/google/gwt/module/client/ScriptInjectionEncodingTest.java
A user/test/com/google/gwt/module/public/script-encoding/ScriptInjectionEncodingTest.js
8 files changed, 106 insertions(+), 0 deletions(-)

Approvals:
  Leeroy Jenkins: Verified
  Goktug Gokdogan: Looks good to me, approved



diff --git a/user/src/com/google/gwt/junit/public/junit-standards.html b/user/src/com/google/gwt/junit/public/junit-standards.html
index 3a7f301..406447f 100644
--- a/user/src/com/google/gwt/junit/public/junit-standards.html
+++ b/user/src/com/google/gwt/junit/public/junit-standards.html
@@ -16,6 +16,7 @@
 -->
 <html>
 <head>
+<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
 <meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
 <meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
 <meta http-equiv="X-UA-Compatible" content="IE=9;">
diff --git a/user/src/com/google/gwt/junit/public/junit.html b/user/src/com/google/gwt/junit/public/junit.html
index 77e0b75..155ce90 100644
--- a/user/src/com/google/gwt/junit/public/junit.html
+++ b/user/src/com/google/gwt/junit/public/junit.html
@@ -15,6 +15,7 @@
 -->
 <html>
 <head>
+<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
 <meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
 <meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
 </head>
diff --git a/user/test/com/google/gwt/core/client/ScriptInjectorTest.java b/user/test/com/google/gwt/core/client/ScriptInjectorTest.java
index f245a1c..f25347c 100644
--- a/user/test/com/google/gwt/core/client/ScriptInjectorTest.java
+++ b/user/test/com/google/gwt/core/client/ScriptInjectorTest.java
@@ -336,6 +336,39 @@
     assertNotNull(injectedElement);
   }

+  /**
+   * Tests encoding of the injected script (UTF-8)
+   */
+  public void testInjectUrlUtf8() {
+    delayTestFinish(TEST_DELAY);
+    final String scriptUrl = "script_injector_test_utf8.js";
+    assertEquals("", nativeGetTestUtf8Var());
+ JavaScriptObject injectedElement = ScriptInjector.fromUrl(scriptUrl).setRemoveTag(false)
+        .setWindow(ScriptInjector.TOP_WINDOW).setCallback(
+            new Callback<Void, Exception>() {
+
+              @Override
+              public void onFailure(Exception reason) {
+                assertNotNull(reason);
+                fail("Injection failed: " + reason.toString());
+              }
+
+              @Override
+              public void onSuccess(Void result) {
+                String testVar = nativeGetTestUtf8Var();
+ JavaScriptObject scriptElement = findScriptUrlInTopWindow(scriptUrl);
+                if (!isIE()) {
+                  cleanupTopWindow("__ti_utf8_var__", scriptElement);
+ assertEquals("cleanup failed", "", nativeGetTestUtf8Var());
+                }
+ assertEquals("__ti_utf8_var not set in top window", "à", testVar);
+                assertNotNull("script element not found", scriptElement);
+                finishTest();
+              }
+            }).inject();
+    assertNotNull(injectedElement);
+  }
+
private void cleanupThisWindow(String property, JavaScriptObject scriptElement) {
     cleanupWindow(nativeThisWindow(), property, scriptElement);
   }
@@ -427,6 +460,10 @@
     return !!$wnd["__ti7_var__"] && $wnd["__ti7_var__"] == 7;
   }-*/;

+  private native String nativeGetTestUtf8Var() /*-{
+    return $wnd["__ti_utf8_var__"] || "";
+  }-*/;
+
   private native JavaScriptObject nativeThisWindow() /*-{
     return window;
   }-*/;
diff --git a/user/test/com/google/gwt/core/public/script_injector_test_utf8.js b/user/test/com/google/gwt/core/public/script_injector_test_utf8.js
new file mode 100644
index 0000000..028b4eb
--- /dev/null
+++ b/user/test/com/google/gwt/core/public/script_injector_test_utf8.js
@@ -0,0 +1 @@
+__ti_utf8_var__ = "à";
\ No newline at end of file
diff --git a/user/test/com/google/gwt/module/ModuleSuite.java b/user/test/com/google/gwt/module/ModuleSuite.java
index ab4852b..b88a8ad 100644
--- a/user/test/com/google/gwt/module/ModuleSuite.java
+++ b/user/test/com/google/gwt/module/ModuleSuite.java
@@ -19,6 +19,7 @@
 import com.google.gwt.module.client.ConfigurationPropertiesTest;
 import com.google.gwt.module.client.DoubleScriptInjectionTest;
 import com.google.gwt.module.client.NoDeployTest;
+import com.google.gwt.module.client.ScriptInjectionEncodingTest;
 import com.google.gwt.module.client.SingleScriptInjectionTest;

 import junit.framework.Test;
@@ -33,6 +34,7 @@
     suite.addTestSuite(ConfigurationPropertiesTest.class);
     suite.addTestSuite(SingleScriptInjectionTest.class);
     suite.addTestSuite(DoubleScriptInjectionTest.class);
+    suite.addTestSuite(ScriptInjectionEncodingTest.class);
     suite.addTestSuite(NoDeployTest.class);

     return suite;
diff --git a/user/test/com/google/gwt/module/ScriptInjectionEncodingTest.gwt.xml b/user/test/com/google/gwt/module/ScriptInjectionEncodingTest.gwt.xml
new file mode 100644
index 0000000..6879465
--- /dev/null
+++ b/user/test/com/google/gwt/module/ScriptInjectionEncodingTest.gwt.xml
@@ -0,0 +1,19 @@
+<!-- --> +<!-- Copyright 2007 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 --> +<!-- 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. License for the specific language governing permissions and --> +<!-- limitations under the License. -->
+
+<module>
+  <inherits name="com.google.gwt.core.Core"/>
+
+  <script src="script-encoding/ScriptInjectionEncodingTest.js"/>
+</module>
diff --git a/user/test/com/google/gwt/module/client/ScriptInjectionEncodingTest.java b/user/test/com/google/gwt/module/client/ScriptInjectionEncodingTest.java
new file mode 100644
index 0000000..396cd81
--- /dev/null
+++ b/user/test/com/google/gwt/module/client/ScriptInjectionEncodingTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2007 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.module.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests encoding with an external script.
+ */
+public class ScriptInjectionEncodingTest extends GWTTestCase {
+
+  public String getModuleName() {
+    return "com.google.gwt.module.ScriptInjectionEncodingTest";
+  }
+
+  /**
+   * Ensure the script is loaded with the correct encoding (UTF-8).
+   */
+  public void testScriptExists() {
+    assertEquals("à", scriptEncoding());
+  }
+
+  /**
+ * The native method called here is defined in ScriptInjectionEncodingTest.js.
+   */
+  public static native String scriptEncoding() /*-{
+    return $wnd.scriptEncoding();
+  }-*/;
+}
diff --git a/user/test/com/google/gwt/module/public/script-encoding/ScriptInjectionEncodingTest.js b/user/test/com/google/gwt/module/public/script-encoding/ScriptInjectionEncodingTest.js
new file mode 100644
index 0000000..6483b27
--- /dev/null
+++ b/user/test/com/google/gwt/module/public/script-encoding/ScriptInjectionEncodingTest.js
@@ -0,0 +1,3 @@
+function scriptEncoding() {
+  return "à";
+}
\ No newline at end of file

--
To view, visit https://gwt-review.googlesource.com/3170
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iede26ae4928600473f56e11387e433565486e4e0
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Thomas Broyer <t.bro...@gmail.com>
Gerrit-Reviewer: Goktug Gokdogan <gok...@google.com>
Gerrit-Reviewer: Leeroy Jenkins <jenk...@gwtproject.org>
Gerrit-Reviewer: Thomas Broyer <t.bro...@gmail.com>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to