You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pm...@apache.org on 2012/06/14 16:37:58 UTC

weinre commit: [CB-873] [weinre] setTimeout/Interval() problems

Updated Branches:
  refs/heads/master dd3e15617 -> f277c2e25


[CB-873] [weinre] setTimeout/Interval() problems

weinre.web/modules/weinre/target/Target.coffee

- removed the "error" handler on window, since it
  doesn't seem to actually work, and generates
  bogus messages at least in the test case
  provided.

weinre.web/modules/weinre/target/Timeline.coffee

- change the after- bits of the setTimeout/Interval()
  hooks to check that the before- bits ran

- also changed the way contentLength and contentType
  are retrieved in the XHR hook to catch DOM errors,
  which Chrome recently started throwing


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/commit/f277c2e2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/tree/f277c2e2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/diff/f277c2e2

Branch: refs/heads/master
Commit: f277c2e2503b1ccac9bed1a456775c14066932a1
Parents: dd3e156
Author: Patrick Mueller <pm...@apache.org>
Authored: Thu Jun 14 10:32:57 2012 -0400
Committer: Patrick Mueller <pm...@apache.org>
Committed: Thu Jun 14 10:32:57 2012 -0400

----------------------------------------------------------------------
 weinre.web/modules/weinre/target/Target.coffee   |   12 ------------
 weinre.web/modules/weinre/target/Timeline.coffee |   17 +++++++++++++----
 2 files changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f277c2e2/weinre.web/modules/weinre/target/Target.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Target.coffee b/weinre.web/modules/weinre/target/Target.coffee
index 460ece1..70e7099 100644
--- a/weinre.web/modules/weinre/target/Target.coffee
+++ b/weinre.web/modules/weinre/target/Target.coffee
@@ -162,21 +162,9 @@ module.exports = class Target
         Weinre.nodeStore = new NodeStore()
         Weinre.cssStore  = new CSSStore()
 
-        window.addEventListener "error", ((e) ->
-            Target.handleError e
-        ), false
-
         NetworkRequest.installNativeHooks()
 
     #---------------------------------------------------------------------------
-    @handleError: (event) ->
-        filename = event.filename or "[unknown filename]"
-        lineno   = event.lineno   or "[unknown lineno]"
-        message  = event.message  or "[unknown message]"
-
-        console.error "error occurred: #{filename}:#{lineno}: #{message}"
-
-    #---------------------------------------------------------------------------
     cb_webSocketOpened: () ->
         Weinre.WeinreTargetCommands.registerTarget window.location.href, Binding(this, @cb_registerTarget)
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f277c2e2/weinre.web/modules/weinre/target/Timeline.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Timeline.coffee b/weinre.web/modules/weinre/target/Timeline.coffee
index fdf93d5..e774a1e 100644
--- a/weinre.web/modules/weinre/target/Timeline.coffee
+++ b/weinre.web/modules/weinre/target/Timeline.coffee
@@ -150,13 +150,18 @@ module.exports = class Timeline
     @addRecord_XHRReadyStateChange: (method, url, id, xhr) ->
         return unless Timeline.isRunning()
 
+        try 
+            contentLength = xhr.getResponseHeader("Content-Length")
+            contentLength = parseInt(contentLength)
+            contentType   = xhr.getResponseHeader("Content-Type")
+        catch e
+            contentLength = 0
+            contentType   = "unknown"
+
         record = {}
         record.startTime = Date.now()
         record.category  = name: "loading"
 
-        contentLength = xhr.getResponseHeader("Content-Length")
-        contentLength = parseInt(contentLength)
-
         if xhr.readyState == XMLHttpRequest.OPENED
             record.type = TimelineRecordType.ResourceSendRequest
             record.data =
@@ -169,7 +174,7 @@ module.exports = class Timeline
             record.data =
                 identifier:            id
                 statusCode:            xhr.status
-                mimeType:              xhr.getResponseHeader("Content-Type")
+                mimeType:              contentType
                 url:                   url
 
             record.data.expectedContentLength = contentLength if !isNaN(contentLength)
@@ -217,6 +222,8 @@ module.exports = class Timeline
                 @userData.interval = interval
 
             after: (receiver, args, result) ->
+                return if !@userData
+                
                 code = @userData.code
                 return unless typeof(code) is "function"
 
@@ -247,6 +254,8 @@ module.exports = class Timeline
                 @userData.interval = interval
 
             after: (receiver, args, result) ->
+                return if !@userData
+                
                 code = @userData.code
                 return unless typeof(code) is "function"