Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: tests/html/websocket_test.dart

Issue 1510763006: Fix #19137: handle when regexp doesn't match in constructorNameFallback (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/websocket_test.dart
diff --git a/tests/html/websocket_test.dart b/tests/html/websocket_test.dart
index f8ba1baed37cf4c889306c71dd129f12ba1b6788..9241d214c0bf0da18d225988de93c524a0d41793 100644
--- a/tests/html/websocket_test.dart
+++ b/tests/html/websocket_test.dart
@@ -35,6 +35,33 @@ main() {
return socket.onMessage.first.then((MessageEvent e) {
expect(e.data, 'hello!');
+ socket.close();
+ });
+ });
+
+ test('regression for 19137', () {
+ // The server supports ws, but not wss, this will yield an error that we
+ // expect to catch below.
+ var socket = new WebSocket('wss://${window.location.host}/ws');
+ socket.onOpen.first.then((_) => socket.send('hello!'));
+ return socket.onError.first.then((e) {
+ // This test is modeled after a comment in issue #19137. We haven't
+ // verified that this is the casue, but the theory is that on Safari
+ // we will reach this point correctly, we then try to get an
+ // interceptor for `e` to call `.toString` on it, but our
+ // get-interceptor logic crashes. This is because the process of
+ // finding the interceptor may ask to extract the constructor name,
+ // and that code assumes that the name matches a specific regular
+ // expression. Apparently that regular expression doesn't match on
+ // Safari 7 and the line below would ends up throwing and error of the
+ // form:
+ //
+ // TypeError: null is not an object (evaluating
+ // 'String(a.constructor).match(/^\s*function\s*([\w$]*)\s*\(/)')
+ // at ...
+ //
+ print('$e was caught');
+ socket.close();
});
});
}
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698