fune/testing/web-platform/tests/webidl/ecmascript-binding/no-regexp-special-casing.any.js
Weizhong Xia 0108376e76 Bug 1730216 [wpt PR 30551] - Rename WebIDL to webidl, a=testonly
Automatic update from web-platform-tests
Rename WebIDL to webidl

WebIDL is renamed to webidl at up stream. Do this also in chromium to
unblock wpt-importer. Wpt-importer should be able to handle such cases
in future.

Bug: 1247327
Change-Id: Ib9c4ca3f4da55c6a25e56bc730a846b6fa95563b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3151416
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Weizhong Xia <weizhong@google.com>
Cr-Commit-Position: refs/heads/main@{#920025}

--

wpt-commits: a370aad338d6ed743abb4d2c6ae84a7f1058558c
wpt-pr: 30551
2021-09-29 09:23:56 +00:00

47 lines
1.3 KiB
JavaScript

"use strict";
// RegExps used to be special-cased in Web IDL, but that was removed in
// https://github.com/heycam/webidl/commit/bbb2bde. These tests check that implementations no longer
// do any such special-casing.
test(() => {
const regExp = new RegExp();
regExp.message = "some message";
const errorEvent = new ErrorEvent("type", regExp);
assert_equals(errorEvent.message, "some message");
}, "Conversion to a dictionary works");
test(() => {
const messageChannel = new MessageChannel();
const regExp = new RegExp();
regExp[Symbol.iterator] = function* () {
yield messageChannel.port1;
};
const messageEvent = new MessageEvent("type", { ports: regExp });
assert_array_equals(messageEvent.ports, [messageChannel.port1]);
}, "Conversion to a sequence works");
promise_test(async () => {
const regExp = new RegExp();
const response = new Response(regExp);
assert_equals(await response.text(), "/(?:)/");
}, "Can convert a RegExp to a USVString");
test(() => {
let functionCalled = false;
const regExp = new RegExp();
regExp.handleEvent = () => {
functionCalled = true;
};
self.addEventListener("testevent", regExp);
self.dispatchEvent(new Event("testevent"));
assert_true(functionCalled);
}, "Can be used as an object implementing a callback interface");