| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 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(); | 38 socket.close(); |
| 39 }); | 39 }); |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 test('regression for 19137', () { | 42 test('error handling', () { |
| 43 // The server supports ws, but not wss, this will yield an error that we | 43 var socket = new WebSocket('ws://${window.location.host}/ws'); |
| 44 // expect to catch below. | 44 socket.onOpen.first.then((_) => socket.send('close-with-error')); |
| 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) { | 45 return socket.onError.first.then((e) { |
| 48 // This test is modeled after a comment in issue #19137. We haven't | 46 print('$e was caught, yay!'); |
| 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(); | 47 socket.close(); |
| 65 }); | 48 }); |
| 66 }); | 49 }); |
| 67 } | 50 } |
| 68 }); | 51 }); |
| 69 } | 52 } |
| OLD | NEW |