[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
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 @@
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)
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 @@
@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 @@
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 @@
@userData.interval = interval
after: (receiver, args, result) ->
+ return if !@userData
+
code = @userData.code
return unless typeof(code) is "function"
@@ -247,6 +254,8 @@
@userData.interval = interval
after: (receiver, args, result) ->
+ return if !@userData
+
code = @userData.code
return unless typeof(code) is "function"