|
| 1 | +"use strict"; |
| 2 | +// RegExps used to be special-cased in Web IDL, but that was removed in |
| 3 | +// https://github.com/heycam/webidl/commit/bbb2bde. These tests check that implementations no longer |
| 4 | +// do any such special-casing. |
| 5 | + |
| 6 | +test(() => { |
| 7 | + const regExp = new RegExp(); |
| 8 | + regExp.message = "some message"; |
| 9 | + |
| 10 | + const errorEvent = new ErrorEvent("type", regExp); |
| 11 | + |
| 12 | + assert_equals(errorEvent.message, "some message"); |
| 13 | +}, "Conversion to a dictionary works"); |
| 14 | + |
| 15 | +test(() => { |
| 16 | + const messageChannel = new MessageChannel(); |
| 17 | + const regExp = new RegExp(); |
| 18 | + regExp[Symbol.iterator] = function* () { |
| 19 | + yield messageChannel.port1; |
| 20 | + }; |
| 21 | + |
| 22 | + const messageEvent = new MessageEvent("type", { ports: regExp }); |
| 23 | + |
| 24 | + assert_array_equals(messageEvent.ports, [messageChannel.port1]); |
| 25 | +}, "Conversion to a sequence works"); |
| 26 | + |
| 27 | +promise_test(async () => { |
| 28 | + const regExp = new RegExp(); |
| 29 | + |
| 30 | + const response = new Response(regExp); |
| 31 | + |
| 32 | + assert_equals(await response.text(), "/(?:)/"); |
| 33 | +}, "Can convert a RegExp to a USVString"); |
| 34 | + |
| 35 | +test(() => { |
| 36 | + let functionCalled = false; |
| 37 | + |
| 38 | + const regExp = new RegExp(); |
| 39 | + regExp.handleEvent = () => { |
| 40 | + functionCalled = true; |
| 41 | + }; |
| 42 | + |
| 43 | + self.addEventListener("testevent", regExp); |
| 44 | + self.dispatchEvent(new Event("testevent")); |
| 45 | + |
| 46 | + assert_true(functionCalled); |
| 47 | +}, "Can be used as an object implementing a callback interface"); |
0 commit comments