| 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..7f099b8ccf18d01041c85d3aef5c7f4fe4f618a8 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,31 @@ 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(buffer) {
|
| + return function() {
|
| + var xhr = new XMLHttpRequest();
|
| + xhr.open("POST", "/coverage_uri_to_amend_by_server");
|
| + xhr.send(JSON.stringify(buffer));
|
| + buffer.length = 0;
|
| + };
|
| + })(#), 1000)''', _traceBuffer);
|
| + }
|
| + JS('', '#.push([#, #])', _traceBuffer, id, name);
|
| +}
|
| +
|
| class JSInvocationMirror implements Invocation {
|
| static const METHOD = 0;
|
| static const GETTER = 1;
|
|
|