You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/07/08 20:12:54 UTC

svn commit: r1144410 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/resources/org/apache/tapestry5/ test/java/org/apache/tapestry5/integration/app1/pages/ test/resources/org/apache/tapestry5/integration/app1/pages/

Author: hlship
Date: Fri Jul  8 18:12:54 2011
New Revision: 1144410

URL: http://svn.apache.org/viewvc?rev=1144410&view=rev
Log:
TAP5-1571: t5-console.js throws exception in Chrome for debug, info, and warn

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.tml
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js?rev=1144410&r1=1144409&r2=1144410&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js Fri Jul  8 18:12:54 2011
@@ -14,68 +14,74 @@
 
 T5.define("console", function() {
 
-  // FireFox throws an exception is you reference the console when it is not enabled.
+    // FireFox throws an exception is you reference the console when it is not enabled.
 
-  var nativeConsoleExists = false, nativeConsole = {}, floatingConsole;
+    var nativeConsoleExists = false, nativeConsole = {}, floatingConsole;
 
-  try {
-    if (console) {
-      nativeConsole = console;
-      nativeConsoleExists = true;
+    try {
+        if (console) {
+            nativeConsole = console;
+            nativeConsoleExists = true;
+        }
     }
-  }
-  catch (e) {
-  }
-
-  function display(className, message) {
-    if (!floatingConsole) {
-      floatingConsole = new Element("div", { "class" : "t-console" });
-
-      $(document.body).insert({top: floatingConsole});
+    catch (e) {
     }
 
-    var div = new Element("div", { 'class' : "t-console-entry " + className }).update(message).hide();
+    function display(className, message) {
+        if (!floatingConsole) {
+            floatingConsole = new Element("div", { "class" : "t-console" });
+
+            $(document.body).insert({top: floatingConsole});
+        }
+
+        var div = new Element("div", { 'class' : "t-console-entry " + className }).update(message).hide();
 
-    floatingConsole.insert({ top: div });
+        floatingConsole.insert({ top: div });
 
-    new Effect.Appear(div, { duration: .25 });
+        new Effect.Appear(div, { duration: .25 });
 
-    var effect = new Effect.Fade(div, { delay:  T5.console.DURATION,
-      afterFinish: function () {
-        T5.dom.remove(div);
-      }
-    });
+        var effect = new Effect.Fade(div, { delay:  T5.console.DURATION,
+            afterFinish: function () {
+                T5.dom.remove(div);
+            }
+        });
 
-    div.observe("click", function() {
-      effect.cancel();
-      T5.dom.remove(div);
-    });
-  }
+        div.observe("click", function() {
+            effect.cancel();
+            T5.dom.remove(div);
+        });
+    }
 
-  function level(className, consolefn) {
-    return function (message) {
-      display(className, message);
+    function level(className, consolefn) {
+        return function (message) {
+            display(className, message);
 
-      consolefn && consolefn(message);
+            consolefn && consolefn.call(console, message);
+        }
     }
-  }
 
-  function error(message) {
-    display("t-err", message);
+    function error(message) {
+        display("t-err", message);
+
+        if (nativeConsoleExists) {
+            console.error(message);
+
+            // Chrome doesn't automatically output a trace with the error message.
+            // FireFox does.
 
-    if (nativeConsoleExists) {
-      console.error(message);
-      console.trace();
+            if (! Prototype.Browser.Gecko) {
+                console.trace();
+            }
+        }
     }
-  }
 
-  return {
-    /** Time, in seconds, that floating console messages are displayed to the user. */
-    DURATION  : 10,
-
-    debug : level("t-debug", nativeConsole.debug),
-    info : level("t-info", nativeConsole.info),
-    warn : level("t-warn", nativeConsole.warn),
-    error : error
-  };
+    return {
+        /** Time, in seconds, that floating console messages are displayed to the user. */
+        DURATION  : 10,
+
+        debug : level("t-debug", nativeConsole.debug),
+        info : level("t-info", nativeConsole.info),
+        warn : level("t-warn", nativeConsole.warn),
+        error : error
+    };
 });
\ No newline at end of file

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.java?rev=1144410&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.java Fri Jul  8 18:12:54 2011
@@ -0,0 +1,24 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// 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 org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Import;
+
+/**
+ * @since 5.3
+ */
+@Import(library = "ClientConsoleDemo.js")
+public class ClientConsoleDemo {
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=1144410&r1=1144409&r2=1144410&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java Fri Jul  8 18:12:54 2011
@@ -53,6 +53,8 @@ public class Index {
     private static final List<Item> ITEMS = CollectionFactory
             .newList(
 
+                    new Item("ClientConsoleDemo", "Client Console Demo", "Demo for the JavaScript client-side console"),
+
                     new Item("InvalidFormalParameterDemo", "Unmatched Formal Parameter with @Component", "Parameters specified with @Component annotation must match formal parameters"),
 
                     new Item("NullBindingToPrimitive", "Null Bound to Primitive Demo", "Correct exception when a primitive parameter is bound to null"),

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js?rev=1144410&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js Fri Jul  8 18:12:54 2011
@@ -0,0 +1,14 @@
+Tapestry.onDOMLoaded(function() {
+
+    function execute(level) {
+        T5.console[level]($(level).value);
+        $(level).select();
+    }
+
+    function wire(level) {
+        $(level).observe("change", function() { execute(level); });
+
+    }
+
+    T5.arrays.each(wire, ["debug", "info", "warn", "error"]);
+});

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.tml?rev=1144410&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.tml Fri Jul  8 18:12:54 2011
@@ -0,0 +1,18 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
+<h1>Client Console Demo</h1>
+
+<div>
+    <label for="debug">Debug:</label> <input id="debug" size="50"/>
+</div>
+<div>
+    <label for="info">Info:</label> <input id="info" size="50"/>
+</div>
+<div>
+    <label for="warn">Warn:</label> <input id="warn" size="50"/>
+</div>
+<div>
+    <label for="error">Error:</label> <input id="error" size="50"/>
+</div>
+
+</html>
+