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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library WebSocketTest; 1 library WebSocketTest;
2 import 'package:unittest/unittest.dart'; 2 import 'package:unittest/unittest.dart';
3 import 'package:unittest/html_individual_config.dart'; 3 import 'package:unittest/html_individual_config.dart';
4 import 'dart:html'; 4 import 'dart:html';
5 5
6 main() { 6 main() {
7 7
8 useHtmlIndividualConfiguration(); 8 useHtmlIndividualConfiguration();
9 9
10 group('supported', () { 10 group('supported', () {
(...skipping 17 matching lines...) Expand all
28 if (WebSocket.supported) { 28 if (WebSocket.supported) {
29 test('echo', () { 29 test('echo', () {
30 var socket = new WebSocket('ws://${window.location.host}/ws'); 30 var socket = new WebSocket('ws://${window.location.host}/ws');
31 31
32 socket.onOpen.first.then((_) { 32 socket.onOpen.first.then((_) {
33 socket.send('hello!'); 33 socket.send('hello!');
34 }); 34 });
35 35
36 return socket.onMessage.first.then((MessageEvent e) { 36 return socket.onMessage.first.then((MessageEvent e) {
37 expect(e.data, 'hello!'); 37 expect(e.data, 'hello!');
38 socket.close();
39 });
40 });
41
42 test('regression for 19137', () {
43 // The server supports ws, but not wss, this will yield an error that we
44 // expect to catch below.
45 var socket = new WebSocket('wss://${window.location.host}/ws');
46 socket.onOpen.first.then((_) => socket.send('hello!'));
47 return socket.onError.first.then((e) {
48 // This test is modeled after a comment in issue #19137. We haven't
49 // verified that this is the casue, but the theory is that on Safari
50 // we will reach this point correctly, we then try to get an
51 // interceptor for `e` to call `.toString` on it, but our
52 // get-interceptor logic crashes. This is because the process of
53 // finding the interceptor may ask to extract the constructor name,
54 // and that code assumes that the name matches a specific regular
55 // expression. Apparently that regular expression doesn't match on
56 // Safari 7 and the line below would ends up throwing and error of the
57 // form:
58 //
59 // TypeError: null is not an object (evaluating
60 // 'String(a.constructor).match(/^\s*function\s*([\w$]*)\s*\(/)')
61 // at ...
62 //
63 print('$e was caught');
64 socket.close();
38 }); 65 });
39 }); 66 });
40 } 67 }
41 }); 68 });
42 } 69 }
OLDNEW
« 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