Index: sdk/lib/_internal/js_runtime/lib/js_helper.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart |
index 7cd2c69d7300d5143bbe7e3412e1698208c5b41e..4c0ca1bb6c31b4072f782e2476dec64a4f1dc3c3 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart |
@@ -20,7 +20,8 @@ import 'dart:_js_embedded_names' show |
JsGetName, |
LEAF_TAGS, |
NATIVE_SUPERCLASS_TAG_NAME, |
- STATIC_FUNCTION_NAME_PROPERTY_NAME; |
+ STATIC_FUNCTION_NAME_PROPERTY_NAME, |
+ TRACE_BUFFER; |
import 'dart:collection'; |
@@ -260,7 +261,7 @@ void throwInvalidReflectionError(String memberName) { |
/// Helper to print the given method information to the console the first |
/// time it is called with it. |
@NoInline() |
-void traceHelper(String method) { |
+void consoleTraceHelper(String method) { |
if (JS('bool', '!this.cache')) { |
JS('', 'this.cache = Object.create(null)'); |
} |
@@ -270,6 +271,29 @@ void traceHelper(String method) { |
} |
} |
+List _traceBuffer; |
+ |
+/// Helper to send coverage information as a POST request to a server. |
+@NoInline() |
+void postTraceHelper(int id, String name) { |
+ // Note: we can't move this initialization to the declaration of |
+ // [_traceBuffer] because [postTraceHelper] is called very early on functions |
+ // that define constants, this happens before getters and setters are expanded |
+ // and before main starts executing. This initialization here allows us to |
+ // skip the lazy field initialization logic. |
+ if (_traceBuffer == null) _traceBuffer = JS('JSArray', '[]'); |
+ if (JS('bool', '#.length == 0', _traceBuffer)) { |
+ JS('', r''' |
+ window.setTimeout(function () { |
+ var xhr = new XMLHttpRequest(); |
+ xhr.open("POST", "/coverage_uri_to_amend_by_server"); |
+ xhr.send(JSON.stringify(#)); |
+ #.length = 0; |
+ }, 1000)''', _traceBuffer, _traceBuffer); |
sra1
2015/08/13 22:27:26
Don't use # inside a JS function.
Use the a surrou
Siggi Cherem (dart-lang)
2015/08/13 23:40:21
Done.
|
+ } |
+ JS('', '#.push([#, #])', _traceBuffer, id, name); |
+} |
+ |
class JSInvocationMirror implements Invocation { |
static const METHOD = 0; |
static const GETTER = 1; |