opal 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +17 -0
  3. data/CHANGELOG.md +35 -1
  4. data/Gemfile +1 -0
  5. data/HACKING.md +47 -26
  6. data/benchmark/benchmarks +415 -103
  7. data/benchmark/bm_call_overhead.yml +28 -0
  8. data/benchmark/run.rb +61 -40
  9. data/docs/cdp_common.json +3364 -0
  10. data/docs/cdp_common.md +18 -0
  11. data/docs/{headless_chrome.md → headless_browsers.md} +31 -12
  12. data/lib/opal/ast/builder.rb +1 -1
  13. data/lib/opal/builder.rb +6 -1
  14. data/lib/opal/builder_processors.rb +5 -3
  15. data/lib/opal/cache.rb +1 -7
  16. data/lib/opal/cli_options.rb +72 -58
  17. data/lib/opal/cli_runners/chrome.rb +47 -9
  18. data/lib/opal/cli_runners/chrome_cdp_interface.rb +238 -112
  19. data/lib/opal/cli_runners/compiler.rb +146 -13
  20. data/lib/opal/cli_runners/deno.rb +32 -0
  21. data/lib/opal/cli_runners/firefox.rb +350 -0
  22. data/lib/opal/cli_runners/firefox_cdp_interface.rb +212 -0
  23. data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.cmd +17 -0
  24. data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.ps1 +28 -0
  25. data/lib/opal/cli_runners/node_modules/.package-lock.json +41 -0
  26. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/LICENSE +1 -1
  27. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/README.md +322 -182
  28. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/bin/client.js +99 -114
  29. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/chrome-remote-interface.js +1 -11
  30. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/index.js +16 -11
  31. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/api.js +41 -33
  32. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/chrome.js +224 -214
  33. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/devtools.js +71 -191
  34. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/external-request.js +26 -6
  35. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/protocol.json +20788 -9049
  36. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +10 -3
  37. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/package.json +59 -123
  38. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/webpack.config.js +25 -32
  39. data/lib/opal/cli_runners/node_modules/commander/History.md +298 -0
  40. data/lib/opal/cli_runners/node_modules/commander/LICENSE +22 -0
  41. data/lib/opal/cli_runners/node_modules/commander/Readme.md +217 -61
  42. data/lib/opal/cli_runners/node_modules/commander/index.js +431 -145
  43. data/lib/opal/cli_runners/node_modules/commander/package.json +16 -79
  44. data/lib/opal/cli_runners/node_modules/ws/README.md +334 -98
  45. data/lib/opal/cli_runners/node_modules/ws/browser.js +8 -0
  46. data/lib/opal/cli_runners/node_modules/ws/index.js +5 -10
  47. data/lib/opal/cli_runners/node_modules/ws/lib/buffer-util.js +129 -0
  48. data/lib/opal/cli_runners/node_modules/ws/lib/constants.js +10 -0
  49. data/lib/opal/cli_runners/node_modules/ws/lib/event-target.js +184 -0
  50. data/lib/opal/cli_runners/node_modules/ws/lib/extension.js +223 -0
  51. data/lib/opal/cli_runners/node_modules/ws/lib/limiter.js +55 -0
  52. data/lib/opal/cli_runners/node_modules/ws/lib/permessage-deflate.js +518 -0
  53. data/lib/opal/cli_runners/node_modules/ws/lib/receiver.js +607 -0
  54. data/lib/opal/cli_runners/node_modules/ws/lib/sender.js +409 -0
  55. data/lib/opal/cli_runners/node_modules/ws/lib/stream.js +180 -0
  56. data/lib/opal/cli_runners/node_modules/ws/lib/validation.js +104 -0
  57. data/lib/opal/cli_runners/node_modules/ws/lib/websocket-server.js +447 -0
  58. data/lib/opal/cli_runners/node_modules/ws/lib/websocket.js +1195 -0
  59. data/lib/opal/cli_runners/node_modules/ws/package.json +40 -106
  60. data/lib/opal/cli_runners/package-lock.json +62 -0
  61. data/lib/opal/cli_runners/package.json +1 -1
  62. data/lib/opal/cli_runners.rb +26 -4
  63. data/lib/opal/nodes/args/prepare_post_args.rb +2 -2
  64. data/lib/opal/nodes/def.rb +8 -8
  65. data/lib/opal/nodes/iter.rb +12 -12
  66. data/lib/opal/nodes/logic.rb +1 -1
  67. data/lib/opal/nodes/masgn.rb +2 -2
  68. data/lib/opal/parser/with_ruby_lexer.rb +1 -1
  69. data/lib/opal/paths.rb +14 -0
  70. data/lib/opal/rewriter.rb +2 -0
  71. data/lib/opal/rewriters/forward_args.rb +52 -4
  72. data/lib/opal/rewriters/targeted_patches.rb +94 -0
  73. data/lib/opal/version.rb +1 -1
  74. data/opal/corelib/basic_object.rb +1 -1
  75. data/opal/corelib/boolean.rb +2 -2
  76. data/opal/corelib/class.rb +11 -0
  77. data/opal/corelib/constants.rb +3 -3
  78. data/opal/corelib/enumerable.rb +4 -0
  79. data/opal/corelib/enumerator.rb +1 -1
  80. data/opal/corelib/hash.rb +2 -2
  81. data/opal/corelib/helpers.rb +1 -1
  82. data/opal/corelib/kernel.rb +3 -3
  83. data/opal/corelib/method.rb +1 -1
  84. data/opal/corelib/module.rb +29 -8
  85. data/opal/corelib/proc.rb +7 -5
  86. data/opal/corelib/runtime.js +141 -78
  87. data/opal/corelib/set.rb +252 -0
  88. data/opal/corelib/string.rb +2 -1
  89. data/opal/corelib/time.rb +2 -2
  90. data/opal/opal.rb +1 -0
  91. data/opal.gemspec +1 -0
  92. data/spec/filters/bugs/array.rb +22 -13
  93. data/spec/filters/bugs/base64.rb +5 -5
  94. data/spec/filters/bugs/basicobject.rb +16 -8
  95. data/spec/filters/bugs/bigdecimal.rb +161 -160
  96. data/spec/filters/bugs/binding.rb +10 -10
  97. data/spec/filters/bugs/class.rb +8 -8
  98. data/spec/filters/bugs/complex.rb +2 -1
  99. data/spec/filters/bugs/date.rb +79 -81
  100. data/spec/filters/bugs/datetime.rb +29 -29
  101. data/spec/filters/bugs/delegate.rb +1 -3
  102. data/spec/filters/bugs/encoding.rb +69 -69
  103. data/spec/filters/bugs/enumerable.rb +22 -20
  104. data/spec/filters/bugs/enumerator.rb +88 -85
  105. data/spec/filters/bugs/exception.rb +46 -40
  106. data/spec/filters/bugs/file.rb +32 -32
  107. data/spec/filters/bugs/float.rb +26 -21
  108. data/spec/filters/bugs/freeze.rb +88 -0
  109. data/spec/filters/bugs/hash.rb +39 -38
  110. data/spec/filters/bugs/integer.rb +57 -44
  111. data/spec/filters/bugs/io.rb +1 -1
  112. data/spec/filters/bugs/kernel.rb +349 -269
  113. data/spec/filters/bugs/language.rb +220 -188
  114. data/spec/filters/bugs/main.rb +5 -3
  115. data/spec/filters/bugs/marshal.rb +38 -38
  116. data/spec/filters/bugs/math.rb +2 -1
  117. data/spec/filters/bugs/method.rb +73 -62
  118. data/spec/filters/bugs/module.rb +163 -143
  119. data/spec/filters/bugs/numeric.rb +6 -6
  120. data/spec/filters/bugs/objectspace.rb +16 -16
  121. data/spec/filters/bugs/openstruct.rb +1 -1
  122. data/spec/filters/bugs/pack_unpack.rb +51 -51
  123. data/spec/filters/bugs/pathname.rb +7 -7
  124. data/spec/filters/bugs/proc.rb +63 -63
  125. data/spec/filters/bugs/random.rb +7 -6
  126. data/spec/filters/bugs/range.rb +12 -9
  127. data/spec/filters/bugs/rational.rb +8 -7
  128. data/spec/filters/bugs/regexp.rb +49 -48
  129. data/spec/filters/bugs/ruby-32.rb +56 -0
  130. data/spec/filters/bugs/set.rb +30 -30
  131. data/spec/filters/bugs/singleton.rb +4 -4
  132. data/spec/filters/bugs/string.rb +187 -99
  133. data/spec/filters/bugs/stringio.rb +7 -0
  134. data/spec/filters/bugs/stringscanner.rb +68 -68
  135. data/spec/filters/bugs/struct.rb +11 -9
  136. data/spec/filters/bugs/symbol.rb +1 -1
  137. data/spec/filters/bugs/time.rb +78 -63
  138. data/spec/filters/bugs/trace_point.rb +4 -4
  139. data/spec/filters/bugs/unboundmethod.rb +32 -17
  140. data/spec/filters/bugs/warnings.rb +8 -12
  141. data/spec/filters/unsupported/array.rb +24 -107
  142. data/spec/filters/unsupported/basicobject.rb +12 -12
  143. data/spec/filters/unsupported/bignum.rb +27 -52
  144. data/spec/filters/unsupported/class.rb +1 -2
  145. data/spec/filters/unsupported/delegator.rb +3 -3
  146. data/spec/filters/unsupported/enumerable.rb +2 -9
  147. data/spec/filters/unsupported/enumerator.rb +2 -11
  148. data/spec/filters/unsupported/file.rb +1 -1
  149. data/spec/filters/unsupported/float.rb +28 -47
  150. data/spec/filters/unsupported/hash.rb +8 -14
  151. data/spec/filters/unsupported/integer.rb +75 -91
  152. data/spec/filters/unsupported/kernel.rb +17 -35
  153. data/spec/filters/unsupported/language.rb +11 -19
  154. data/spec/filters/unsupported/marshal.rb +22 -41
  155. data/spec/filters/unsupported/matchdata.rb +28 -52
  156. data/spec/filters/unsupported/math.rb +1 -1
  157. data/spec/filters/unsupported/privacy.rb +229 -285
  158. data/spec/filters/unsupported/range.rb +1 -5
  159. data/spec/filters/unsupported/regexp.rb +40 -66
  160. data/spec/filters/unsupported/set.rb +2 -2
  161. data/spec/filters/unsupported/singleton.rb +4 -4
  162. data/spec/filters/unsupported/string.rb +305 -508
  163. data/spec/filters/unsupported/struct.rb +3 -4
  164. data/spec/filters/unsupported/symbol.rb +15 -18
  165. data/spec/filters/unsupported/thread.rb +1 -7
  166. data/spec/filters/unsupported/time.rb +159 -202
  167. data/spec/filters/unsupported/usage_of_files.rb +170 -259
  168. data/spec/lib/builder_spec.rb +4 -4
  169. data/spec/lib/rewriters/forward_args_spec.rb +32 -12
  170. data/spec/mspec-opal/runner.rb +2 -0
  171. data/spec/ruby_specs +4 -0
  172. data/stdlib/deno/base.rb +28 -0
  173. data/stdlib/deno/file.rb +340 -0
  174. data/stdlib/{headless_chrome.rb → headless_browser/base.rb} +1 -1
  175. data/stdlib/headless_browser/file.rb +15 -0
  176. data/stdlib/headless_browser.rb +4 -0
  177. data/stdlib/native.rb +1 -1
  178. data/stdlib/nodejs/file.rb +5 -0
  179. data/stdlib/opal/platform.rb +8 -6
  180. data/stdlib/opal-platform.rb +14 -8
  181. data/stdlib/set.rb +1 -258
  182. data/tasks/benchmarking.rake +62 -19
  183. data/tasks/performance.rake +1 -1
  184. data/tasks/testing.rake +5 -3
  185. data/test/nodejs/test_file.rb +29 -10
  186. data/test/opal/http_server.rb +28 -11
  187. data/test/opal/unsupported_and_bugs.rb +2 -1
  188. metadata +89 -50
  189. data/lib/opal/cli_runners/node_modules/ultron/LICENSE +0 -22
  190. data/lib/opal/cli_runners/node_modules/ultron/index.js +0 -138
  191. data/lib/opal/cli_runners/node_modules/ultron/package.json +0 -112
  192. data/lib/opal/cli_runners/node_modules/ws/SECURITY.md +0 -33
  193. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.fallback.js +0 -56
  194. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.js +0 -15
  195. data/lib/opal/cli_runners/node_modules/ws/lib/ErrorCodes.js +0 -28
  196. data/lib/opal/cli_runners/node_modules/ws/lib/EventTarget.js +0 -158
  197. data/lib/opal/cli_runners/node_modules/ws/lib/Extensions.js +0 -69
  198. data/lib/opal/cli_runners/node_modules/ws/lib/PerMessageDeflate.js +0 -339
  199. data/lib/opal/cli_runners/node_modules/ws/lib/Receiver.js +0 -520
  200. data/lib/opal/cli_runners/node_modules/ws/lib/Sender.js +0 -438
  201. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.fallback.js +0 -9
  202. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.js +0 -17
  203. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocket.js +0 -705
  204. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocketServer.js +0 -336
  205. data/spec/filters/bugs/boolean.rb +0 -3
  206. data/spec/filters/bugs/matrix.rb +0 -3
  207. data/spec/filters/unsupported/fixnum.rb +0 -15
  208. data/spec/filters/unsupported/freeze.rb +0 -102
  209. data/spec/filters/unsupported/pathname.rb +0 -4
  210. data/spec/filters/unsupported/proc.rb +0 -4
  211. data/spec/filters/unsupported/random.rb +0 -5
  212. data/spec/filters/unsupported/taint.rb +0 -162
@@ -1,336 +0,0 @@
1
- /*!
2
- * ws: a node.js websocket client
3
- * Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
4
- * MIT Licensed
5
- */
6
-
7
- 'use strict';
8
-
9
- const EventEmitter = require('events');
10
- const crypto = require('crypto');
11
- const Ultron = require('ultron');
12
- const http = require('http');
13
- const url = require('url');
14
-
15
- const PerMessageDeflate = require('./PerMessageDeflate');
16
- const Extensions = require('./Extensions');
17
- const WebSocket = require('./WebSocket');
18
-
19
- const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
20
-
21
- /**
22
- * Class representing a WebSocket server.
23
- *
24
- * @extends EventEmitter
25
- */
26
- class WebSocketServer extends EventEmitter {
27
- /**
28
- * Create a `WebSocketServer` instance.
29
- *
30
- * @param {Object} options Configuration options
31
- * @param {String} options.host The hostname where to bind the server
32
- * @param {Number} options.port The port where to bind the server
33
- * @param {http.Server} options.server A pre-created HTTP/S server to use
34
- * @param {Function} options.verifyClient An hook to reject connections
35
- * @param {Function} options.handleProtocols An hook to handle protocols
36
- * @param {String} options.path Accept only connections matching this path
37
- * @param {Boolean} options.noServer Enable no server mode
38
- * @param {Boolean} options.clientTracking Specifies whether or not to track clients
39
- * @param {(Boolean|Object)} options.perMessageDeflate Enable/disable permessage-deflate
40
- * @param {Number} options.maxPayload The maximum allowed message size
41
- * @param {Function} callback A listener for the `listening` event
42
- */
43
- constructor (options, callback) {
44
- super();
45
-
46
- options = Object.assign({
47
- maxPayload: 100 * 1024 * 1024,
48
- perMessageDeflate: true,
49
- handleProtocols: null,
50
- clientTracking: true,
51
- verifyClient: null,
52
- noServer: false,
53
- backlog: null, // use default (511 as implemented in net.js)
54
- server: null,
55
- host: null,
56
- path: null,
57
- port: null
58
- }, options);
59
-
60
- if (options.port == null && !options.server && !options.noServer) {
61
- throw new TypeError('missing or invalid options');
62
- }
63
-
64
- if (options.port != null) {
65
- this._server = http.createServer((req, res) => {
66
- const body = http.STATUS_CODES[426];
67
-
68
- res.writeHead(426, {
69
- 'Content-Length': body.length,
70
- 'Content-Type': 'text/plain'
71
- });
72
- res.end(body);
73
- });
74
- this._server.allowHalfOpen = false;
75
- this._server.listen(options.port, options.host, options.backlog, callback);
76
- } else if (options.server) {
77
- this._server = options.server;
78
- }
79
-
80
- if (this._server) {
81
- this._ultron = new Ultron(this._server);
82
- this._ultron.on('listening', () => this.emit('listening'));
83
- this._ultron.on('error', (err) => this.emit('error', err));
84
- this._ultron.on('upgrade', (req, socket, head) => {
85
- this.handleUpgrade(req, socket, head, (client) => {
86
- this.emit(`connection${req.url}`, client);
87
- this.emit('connection', client);
88
- });
89
- });
90
- }
91
-
92
- if (options.clientTracking) this.clients = new Set();
93
- this.options = options;
94
- this.path = options.path;
95
- }
96
-
97
- /**
98
- * Close the server.
99
- *
100
- * @param {Function} cb Callback
101
- * @public
102
- */
103
- close (cb) {
104
- //
105
- // Terminate all associated clients.
106
- //
107
- if (this.clients) {
108
- for (const client of this.clients) client.terminate();
109
- }
110
-
111
- const server = this._server;
112
-
113
- if (server) {
114
- this._ultron.destroy();
115
- this._ultron = this._server = null;
116
-
117
- //
118
- // Close the http server if it was internally created.
119
- //
120
- if (this.options.port != null) return server.close(cb);
121
- }
122
-
123
- if (cb) cb();
124
- }
125
-
126
- /**
127
- * See if a given request should be handled by this server instance.
128
- *
129
- * @param {http.IncomingMessage} req Request object to inspect
130
- * @return {Boolean} `true` if the request is valid, else `false`
131
- * @public
132
- */
133
- shouldHandle (req) {
134
- if (this.options.path && url.parse(req.url).pathname !== this.options.path) {
135
- return false;
136
- }
137
-
138
- return true;
139
- }
140
-
141
- /**
142
- * Handle a HTTP Upgrade request.
143
- *
144
- * @param {http.IncomingMessage} req The request object
145
- * @param {net.Socket} socket The network socket between the server and client
146
- * @param {Buffer} head The first packet of the upgraded stream
147
- * @param {Function} cb Callback
148
- * @public
149
- */
150
- handleUpgrade (req, socket, head, cb) {
151
- socket.on('error', socketError);
152
-
153
- const version = +req.headers['sec-websocket-version'];
154
-
155
- if (
156
- !this.shouldHandle(req) ||
157
- !req.headers.upgrade ||
158
- req.headers.upgrade.toLowerCase() !== 'websocket' ||
159
- !req.headers['sec-websocket-key'] ||
160
- version !== 8 && version !== 13
161
- ) {
162
- return abortConnection(socket, 400);
163
- }
164
-
165
- var protocol = (req.headers['sec-websocket-protocol'] || '').split(/, */);
166
-
167
- //
168
- // Optionally call external protocol selection handler.
169
- //
170
- if (this.options.handleProtocols) {
171
- protocol = this.options.handleProtocols(protocol);
172
- if (protocol === false) return abortConnection(socket, 401);
173
- } else {
174
- protocol = protocol[0];
175
- }
176
-
177
- //
178
- // Optionally call external client verification handler.
179
- //
180
- if (this.options.verifyClient) {
181
- const info = {
182
- origin: req.headers[`${version === 8 ? 'sec-websocket-origin' : 'origin'}`],
183
- secure: !!(req.connection.authorized || req.connection.encrypted),
184
- req
185
- };
186
-
187
- if (this.options.verifyClient.length === 2) {
188
- this.options.verifyClient(info, (verified, code, message) => {
189
- if (!verified) return abortConnection(socket, code || 401, message);
190
-
191
- this.completeUpgrade(protocol, version, req, socket, head, cb);
192
- });
193
- return;
194
- } else if (!this.options.verifyClient(info)) {
195
- return abortConnection(socket, 401);
196
- }
197
- }
198
-
199
- this.completeUpgrade(protocol, version, req, socket, head, cb);
200
- }
201
-
202
- /**
203
- * Upgrade the connection to WebSocket.
204
- *
205
- * @param {String} protocol The chosen subprotocol
206
- * @param {Number} version The WebSocket protocol version
207
- * @param {http.IncomingMessage} req The request object
208
- * @param {net.Socket} socket The network socket between the server and client
209
- * @param {Buffer} head The first packet of the upgraded stream
210
- * @param {Function} cb Callback
211
- * @private
212
- */
213
- completeUpgrade (protocol, version, req, socket, head, cb) {
214
- //
215
- // Destroy the socket if the client has already sent a FIN packet.
216
- //
217
- if (!socket.readable || !socket.writable) return socket.destroy();
218
-
219
- const key = crypto.createHash('sha1')
220
- .update(req.headers['sec-websocket-key'] + GUID, 'binary')
221
- .digest('base64');
222
-
223
- const headers = [
224
- 'HTTP/1.1 101 Switching Protocols',
225
- 'Upgrade: websocket',
226
- 'Connection: Upgrade',
227
- `Sec-WebSocket-Accept: ${key}`
228
- ];
229
-
230
- if (protocol) headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
231
-
232
- const offer = Extensions.parse(req.headers['sec-websocket-extensions']);
233
- var extensions;
234
-
235
- try {
236
- extensions = acceptExtensions(this.options, offer);
237
- } catch (err) {
238
- return abortConnection(socket, 400);
239
- }
240
-
241
- const props = Object.keys(extensions);
242
-
243
- if (props.length) {
244
- const serverExtensions = props.reduce((obj, key) => {
245
- obj[key] = [extensions[key].params];
246
- return obj;
247
- }, {});
248
-
249
- headers.push(`Sec-WebSocket-Extensions: ${Extensions.format(serverExtensions)}`);
250
- }
251
-
252
- //
253
- // Allow external modification/inspection of handshake headers.
254
- //
255
- this.emit('headers', headers);
256
-
257
- socket.write(headers.concat('', '').join('\r\n'));
258
-
259
- const client = new WebSocket([req, socket, head], {
260
- maxPayload: this.options.maxPayload,
261
- protocolVersion: version,
262
- extensions,
263
- protocol
264
- });
265
-
266
- if (this.clients) {
267
- this.clients.add(client);
268
- client.on('close', () => this.clients.delete(client));
269
- }
270
-
271
- socket.removeListener('error', socketError);
272
- cb(client);
273
- }
274
- }
275
-
276
- module.exports = WebSocketServer;
277
-
278
- /**
279
- * Handle premature socket errors.
280
- *
281
- * @private
282
- */
283
- function socketError () {
284
- this.destroy();
285
- }
286
-
287
- /**
288
- * Accept WebSocket extensions.
289
- *
290
- * @param {Object} options The `WebSocketServer` configuration options
291
- * @param {Object} offer The parsed value of the `sec-websocket-extensions` header
292
- * @return {Object} Accepted extensions
293
- * @private
294
- */
295
- function acceptExtensions (options, offer) {
296
- const pmd = options.perMessageDeflate;
297
- const extensions = {};
298
-
299
- if (pmd && offer[PerMessageDeflate.extensionName]) {
300
- const perMessageDeflate = new PerMessageDeflate(
301
- pmd !== true ? pmd : {},
302
- true,
303
- options.maxPayload
304
- );
305
-
306
- perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]);
307
- extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
308
- }
309
-
310
- return extensions;
311
- }
312
-
313
- /**
314
- * Close the connection when preconditions are not fulfilled.
315
- *
316
- * @param {net.Socket} socket The socket of the upgrade request
317
- * @param {Number} code The HTTP response status code
318
- * @param {String} [message] The HTTP response body
319
- * @private
320
- */
321
- function abortConnection (socket, code, message) {
322
- if (socket.writable) {
323
- message = message || http.STATUS_CODES[code];
324
- socket.write(
325
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` +
326
- 'Connection: close\r\n' +
327
- 'Content-type: text/html\r\n' +
328
- `Content-Length: ${Buffer.byteLength(message)}\r\n` +
329
- '\r\n' +
330
- message
331
- );
332
- }
333
-
334
- socket.removeListener('error', socketError);
335
- socket.destroy();
336
- }
@@ -1,3 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_filter "Boolean" do
3
- end
@@ -1,3 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_filter "Matrix" do
3
- end
@@ -1,15 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_unsupported_filter "Fixnum" do
3
- fails "Fixnum#+ overflows to Bignum when the result does not fit in Fixnum"
4
- fails "Fixnum#- returns a Bignum only if the result is too large to be a Fixnum"
5
- fails "Fixnum#<< with n << m returns -1 when n < 0, m < 0 and n > -(2**-m)"
6
- fails "Fixnum#<< with n << m returns 0 when m < 0 and m is a Bignum"
7
- fails "Fixnum#<< with n << m returns 0 when n > 0, m < 0 and n < 2**-m"
8
- fails "Fixnum#<< with n << m returns a Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0"
9
- fails "Fixnum#<< with n << m returns a Bignum == fixnum_min * 2 when fixnum_min << 1 and n < 0"
10
- fails "Fixnum#>> with n >> m returns -1 when n < 0, m > 0 and n > -(2**m)"
11
- fails "Fixnum#>> with n >> m returns 0 when m is a Bignum"
12
- fails "Fixnum#>> with n >> m returns 0 when n > 0, m > 0 and n < 2**m"
13
- fails "Fixnum#>> with n >> m returns a Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0"
14
- fails "Fixnum#>> with n >> m returns a Bignum == fixnum_min * 2 when fixnum_min >> -1 and n < 0"
15
- end
@@ -1,102 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_unsupported_filter "freezing" do
3
- fails "Date constants freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES"
4
- fails "FalseClass#to_s returns a frozen string" # Expected "false".frozen? to be truthy but was false
5
- fails "File.basename returns a new unfrozen String" # Expected "foo.rb" not to be identical to "foo.rb"
6
- fails "FrozenError#receiver should return frozen object that modification was attempted on" # RuntimeError: RuntimeError
7
- fails "Hash literal does not change encoding of literal string keys during creation"
8
- fails "Hash literal freezes string keys on initialization"
9
- fails "Hash#== compares keys with matching hash codes via eql?"
10
- fails "Hash#[]= doesn't duplicate and freeze already frozen string keys"
11
- fails "Hash#eql? compares keys with matching hash codes via eql?"
12
- fails "Hash#store doesn't duplicate and freeze already frozen string keys"
13
- fails "Kernel#clone with freeze: anything else raises ArgumentError when passed not true/false/nil" # Expected ArgumentError (/unexpected value for freeze: Integer/) but got: ArgumentError (unexpected value for freeze: Number)
14
- fails "Kernel#clone with freeze: false calls #initialize_clone with kwargs freeze: false even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but got: ArgumentError ([Clone#initialize_clone] wrong number of arguments (given 2, expected 1))
15
- fails "Kernel#clone with freeze: nil copies frozen?" # Fails because of "".freeze.clone(freeze: nil)
16
- fails "Kernel#clone with freeze: true calls #initialize_clone with kwargs freeze: true even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but got: ArgumentError ([Clone#initialize_clone] wrong number of arguments (given 2, expected 1))
17
- fails "Kernel#freeze causes mutative calls to raise RuntimeError" # Setting the value fails, but no Exception is raised
18
- fails "Kernel#freeze on a Symbol has no effect since it is already frozen" # currently cant destinguish between Symbol and String as Symbol = String
19
- fails "Kernel#frozen? on a Symbol returns true" # currently cant destinguish between Symbol and String as Symbol = String
20
- fails "Literal Ranges is frozen" # Expected 42...frozen? to be truthy but was false
21
- fails "Literal Regexps is frozen" # Expected /Hello/.frozen? to be truthy but was false
22
- fails "Marshal.load when called with freeze: true does not freeze classes" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
23
- fails "Marshal.load when called with freeze: true does not freeze modules" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
24
- fails "Marshal.load when called with freeze: true returns frozen arrays" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
25
- fails "Marshal.load when called with freeze: true returns frozen hashes" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
26
- fails "Marshal.load when called with freeze: true returns frozen objects" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
27
- fails "Marshal.load when called with freeze: true returns frozen regexps" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
28
- fails "Marshal.load when called with freeze: true returns frozen strings" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
29
- fails "Marshal.load when called with freeze: true when called with a proc call the proc with frozen objects" # ArgumentError: [Marshal.load] wrong number of arguments(3 for 1)
30
- fails "Marshal.load when called with freeze: true when called with a proc does not freeze the object returned by the proc" # ArgumentError: [Marshal.load] wrong number of arguments(3 for 1)
31
- fails "MatchData#string returns a frozen copy of the match string"
32
- fails "Module#name returns a frozen String" # Expected "ModuleSpecs".frozen? to be truthy but was false due to Javascript automatic conversion of primitives into String 'object' when calling methods on the primitive
33
- fails "NilClass#to_s returns a frozen string" # Expected "".frozen? to be truthy but was false
34
- fails "OpenStruct#method_missing when called with a method name ending in '=' raises a TypeError when self is frozen"
35
- fails "Proc#[] with frozen_string_literals doesn't duplicate frozen strings" # Expected false to be true
36
- fails "Regexp#initialize raises a FrozenError on a Regexp literal" # Expected FrozenError but no exception was raised (nil was returned)
37
- fails "String#+@ returns an unfrozen copy of a frozen String"
38
- fails "String#+@ returns self if the String is not frozen"
39
- fails "String#-@ deduplicates frozen strings" # Expected "this string is frozen" not to be identical to "this string is frozen"
40
- fails "String#-@ interns the provided string if it is frozen" # NoMethodError: undefined method `-@' for "this string is unique and frozen 0.5421131713191049"
41
- fails "String#-@ returns a frozen copy if the String is not frozen"
42
- fails "String#-@ returns self if the String is frozen"
43
- fails "String#<< raises a FrozenError when self is frozen" # NotImplementedError: String#<< not supported. Mutable String methods are not supported in Opal.
44
- fails "String#<< with Integer raises a FrozenError when self is frozen" # NotImplementedError: String#<< not supported. Mutable String methods are not supported in Opal.
45
- fails "String#[]= with Fixnum index raises a FrozenError when self is frozen" # NoMethodError: undefined method `[]=' for "hello":String
46
- fails "String#capitalize! raises a FrozenError when self is frozen" # NotImplementedError: String#capitalize! not supported. Mutable String methods are not supported in Opal.
47
- fails "String#chomp! raises a FrozenError on a frozen instance when it is modified" # NotImplementedError: String#chomp! not supported. Mutable String methods are not supported in Opal.
48
- fails "String#chomp! raises a FrozenError on a frozen instance when it would not be modified" # NotImplementedError: String#chomp! not supported. Mutable String methods are not supported in Opal.
49
- fails "String#chop! raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#chop! not supported. Mutable String methods are not supported in Opal.
50
- fails "String#chop! raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#chop! not supported. Mutable String methods are not supported in Opal.
51
- fails "String#clear raises a FrozenError if self is frozen" # NoMethodError: undefined method `clear' for "Jolene":String
52
- fails "String#clone copies frozen state"
53
- fails "String#concat raises a FrozenError when self is frozen" # NoMethodError: undefined method `concat' for "hello":String
54
- fails "String#concat with Integer raises a FrozenError when self is frozen" # NoMethodError: undefined method `concat' for "hello":String
55
- fails "String#delete! raises a FrozenError when self is frozen" # NoMethodError: undefined method `delete!' for "hello":String
56
- fails "String#delete_prefix! raises a FrozenError when self is frozen" # NoMethodError: undefined method `delete_prefix!' for "hello":String
57
- fails "String#delete_suffix! raises a FrozenError when self is frozen" # NoMethodError: undefined method `delete_suffix!' for "hello":String
58
- fails "String#downcase! raises a FrozenError when self is frozen" # NotImplementedError: String#downcase! not supported. Mutable String methods are not supported in Opal.
59
- fails "String#encode! raises a FrozenError when called on a frozen String when it's a no-op" # NoMethodError: undefined method `default_internal' for Encoding
60
- fails "String#encode! raises a FrozenError when called on a frozen String" # NoMethodError: undefined method `default_internal' for Encoding
61
- fails "String#force_encoding raises a FrozenError if self is frozen" # Expected FrozenError but no exception was raised ("abcd" was returned)
62
- fails "String#freeze doesn't produce the same object for different instances of literals in the source"
63
- fails "String#gsub! with pattern and block raises a FrozenError when self is frozen" # NotImplementedError: String#gsub! not supported. Mutable String methods are not supported in Opal.
64
- fails "String#gsub! with pattern and replacement raises a FrozenError when self is frozen" # NotImplementedError: String#gsub! not supported. Mutable String methods are not supported in Opal.
65
- fails "String#initialize with an argument raises a FrozenError on a frozen instance that is modified" # NotImplementedError: Mutable strings are not supported in Opal.
66
- fails "String#initialize with an argument raises a FrozenError on a frozen instance when self-replacing" # NotImplementedError: Mutable strings are not supported in Opal.
67
- fails "String#initialize with no arguments does not raise an exception when frozen"
68
- fails "String#insert with index, other raises a FrozenError if self is frozen" # NoMethodError: undefined method `insert' for "abcd":String
69
- fails "String#lstrip! raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#lstrip! not supported. Mutable String methods are not supported in Opal.
70
- fails "String#lstrip! raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#lstrip! not supported. Mutable String methods are not supported in Opal.
71
- fails "String#next! raises a FrozenError if self is frozen" # NotImplementedError: String#next! not supported. Mutable String methods are not supported in Opal.
72
- fails "String#prepend raises a FrozenError when self is frozen" # NoMethodError: undefined method `prepend' for "hello":String
73
- fails "String#replace raises a FrozenError on a frozen instance that is modified" # NoMethodError: undefined method `replace' for "hello":String
74
- fails "String#replace raises a FrozenError on a frozen instance when self-replacing" # NoMethodError: undefined method `replace' for "hello":String
75
- fails "String#reverse! raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#reverse! not supported. Mutable String methods are not supported in Opal.
76
- fails "String#reverse! raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#reverse! not supported. Mutable String methods are not supported in Opal.
77
- fails "String#rstrip! raises a FrozenError on a frozen instance that is modified" # NoMethodError: undefined method `rstrip!' for " hello ":String
78
- fails "String#rstrip! raises a FrozenError on a frozen instance that would not be modified" # NoMethodError: undefined method `rstrip!' for "hello":String
79
- fails "String#setbyte raises a FrozenError if self is frozen" # Expected false to be true
80
- fails "String#slice! Range raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
81
- fails "String#slice! Range raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
82
- fails "String#slice! with Regexp raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
83
- fails "String#slice! with Regexp raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
84
- fails "String#slice! with Regexp, index raises a FrozenError if self is frozen" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
85
- fails "String#slice! with String raises a FrozenError if self is frozen" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
86
- fails "String#slice! with index raises a FrozenError if self is frozen" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
87
- fails "String#slice! with index, length raises a FrozenError if self is frozen" # NotImplementedError: String#slice! not supported. Mutable String methods are not supported in Opal.
88
- fails "String#squeeze! raises a FrozenError when self is frozen" # NotImplementedError: String#squeeze! not supported. Mutable String methods are not supported in Opal.
89
- fails "String#strip! raises a FrozenError on a frozen instance that is modified" # NotImplementedError: String#strip! not supported. Mutable String methods are not supported in Opal.
90
- fails "String#strip! raises a FrozenError on a frozen instance that would not be modified" # NotImplementedError: String#strip! not supported. Mutable String methods are not supported in Opal.
91
- fails "String#sub! with pattern and block raises a FrozenError when self is frozen" # NotImplementedError: String#sub! not supported. Mutable String methods are not supported in Opal.
92
- fails "String#sub! with pattern, replacement raises a FrozenError when self is frozen" # NotImplementedError: String#sub! not supported. Mutable String methods are not supported in Opal.
93
- fails "String#succ! raises a FrozenError if self is frozen" # NotImplementedError: String#succ! not supported. Mutable String methods are not supported in Opal.
94
- fails "String#swapcase! raises a FrozenError when self is frozen" # NotImplementedError: String#swapcase! not supported. Mutable String methods are not supported in Opal.
95
- fails "String#tr! raises a FrozenError if self is frozen" # NotImplementedError: String#tr! not supported. Mutable String methods are not supported in Opal.
96
- fails "String#tr_s! raises a FrozenError if self is frozen" # NotImplementedError: String#tr_s! not supported. Mutable String methods are not supported in Opal.
97
- fails "String#upcase! raises a FrozenError when self is frozen" # NotImplementedError: String#upcase! not supported. Mutable String methods are not supported in Opal.
98
- fails "StringScanner#initialize returns an instance of StringScanner"
99
- fails "Time#localtime on a frozen time does not raise an error if already in the right time zone"
100
- fails "Time#localtime on a frozen time raises a RuntimeError if the time has a different time zone"
101
- fails "TrueClass#to_s returns a frozen string" # Expected "true".frozen? to be truthy but was false
102
- end
@@ -1,4 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_unsupported_filter "Pathname" do
3
- fails "Pathname.new is tainted if path is tainted"
4
- end
@@ -1,4 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_unsupported_filter "Proc" do
3
- fails "Proc#hash returns an Integer"
4
- end
@@ -1,5 +0,0 @@
1
- # NOTE: run bin/format-filters after changing this file
2
- opal_unsupported_filter "Random" do
3
- fails "Random#bytes returns the same numeric output for a given huge seed accross all implementations and platforms"
4
- fails "Random#bytes returns the same numeric output for a given seed accross all implementations and platforms"
5
- end