GenerateWindowOrWorkerInterfaces.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. /*
  2. * Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/ByteString.h>
  7. #include <AK/LexicalPath.h>
  8. #include <AK/SourceGenerator.h>
  9. #include <AK/StringBuilder.h>
  10. #include <LibCore/ArgsParser.h>
  11. #include <LibCore/File.h>
  12. #include <LibIDL/IDLParser.h>
  13. #include <LibIDL/Types.h>
  14. #include <LibMain/Main.h>
  15. static ErrorOr<void> add_to_interface_sets(IDL::Interface&, Vector<IDL::Interface&>& intrinsics, Vector<IDL::Interface&>& window_exposed, Vector<IDL::Interface&>& dedicated_worker_exposed, Vector<IDL::Interface&>& shared_worker_exposed, Vector<IDL::Interface&>& shadow_realm_exposed);
  16. static ByteString s_error_string;
  17. struct LegacyConstructor {
  18. ByteString name;
  19. ByteString constructor_class;
  20. };
  21. static void consume_whitespace(GenericLexer& lexer)
  22. {
  23. bool consumed = true;
  24. while (consumed) {
  25. consumed = lexer.consume_while(is_ascii_space).length() > 0;
  26. if (lexer.consume_specific("//"sv)) {
  27. lexer.consume_until('\n');
  28. lexer.ignore();
  29. consumed = true;
  30. }
  31. }
  32. }
  33. static Optional<LegacyConstructor> const& lookup_legacy_constructor(IDL::Interface& interface)
  34. {
  35. static HashMap<StringView, Optional<LegacyConstructor>> s_legacy_constructors;
  36. if (auto cache = s_legacy_constructors.get(interface.name); cache.has_value())
  37. return cache.value();
  38. auto attribute = interface.extended_attributes.get("LegacyFactoryFunction"sv);
  39. if (!attribute.has_value()) {
  40. s_legacy_constructors.set(interface.name, {});
  41. return s_legacy_constructors.get(interface.name).value();
  42. }
  43. GenericLexer function_lexer(attribute.value());
  44. consume_whitespace(function_lexer);
  45. auto name = function_lexer.consume_until([](auto ch) { return is_ascii_space(ch) || ch == '('; });
  46. auto constructor_class = ByteString::formatted("{}Constructor", name);
  47. s_legacy_constructors.set(interface.name, LegacyConstructor { name, move(constructor_class) });
  48. return s_legacy_constructors.get(interface.name).value();
  49. }
  50. static ErrorOr<void> generate_intrinsic_definitions(StringView output_path, Vector<IDL::Interface&>& exposed_interfaces)
  51. {
  52. StringBuilder builder;
  53. SourceGenerator generator(builder);
  54. generator.append(R"~~~(
  55. #include <LibGC/DeferGC.h>
  56. #include <LibJS/Runtime/Object.h>
  57. #include <LibWeb/Bindings/Intrinsics.h>)~~~");
  58. for (auto& interface : exposed_interfaces) {
  59. auto gen = generator.fork();
  60. gen.set("namespace_class", interface.namespace_class);
  61. gen.set("prototype_class", interface.prototype_class);
  62. gen.set("constructor_class", interface.constructor_class);
  63. if (interface.is_namespace) {
  64. gen.append(R"~~~(
  65. #include <LibWeb/Bindings/@namespace_class@.h>)~~~");
  66. } else {
  67. gen.append(R"~~~(
  68. #include <LibWeb/Bindings/@constructor_class@.h>
  69. #include <LibWeb/Bindings/@prototype_class@.h>)~~~");
  70. if (auto const& legacy_constructor = lookup_legacy_constructor(interface); legacy_constructor.has_value()) {
  71. gen.set("legacy_constructor_class", legacy_constructor->constructor_class);
  72. gen.append(R"~~~(
  73. #include <LibWeb/Bindings/@legacy_constructor_class@.h>)~~~");
  74. }
  75. }
  76. }
  77. generator.append(R"~~~(
  78. namespace Web::Bindings {
  79. )~~~");
  80. auto add_namespace = [&](SourceGenerator& gen, StringView name, StringView namespace_class) {
  81. gen.set("interface_name", name);
  82. gen.set("namespace_class", namespace_class);
  83. gen.append(R"~~~(
  84. template<>
  85. void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
  86. {
  87. auto namespace_object = realm.create<@namespace_class@>(realm);
  88. m_namespaces.set("@interface_name@"_fly_string, namespace_object);
  89. [[maybe_unused]] static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;)~~~");
  90. for (auto& interface : exposed_interfaces) {
  91. if (interface.extended_attributes.get("LegacyNamespace"sv) != name)
  92. continue;
  93. gen.set("owned_interface_name", interface.name);
  94. gen.set("owned_prototype_class", interface.prototype_class);
  95. gen.append(R"~~~(
  96. namespace_object->define_intrinsic_accessor("@owned_interface_name@", attr, [](auto& realm) -> JS::Value { return &Bindings::ensure_web_constructor<@owned_prototype_class@>(realm, "@interface_name@.@owned_interface_name@"_fly_string); });)~~~");
  97. }
  98. gen.append(R"~~~(
  99. }
  100. )~~~");
  101. };
  102. auto add_interface = [](SourceGenerator& gen, StringView name, StringView prototype_class, StringView constructor_class, Optional<LegacyConstructor> const& legacy_constructor, StringView named_properties_class) {
  103. gen.set("interface_name", name);
  104. gen.set("prototype_class", prototype_class);
  105. gen.set("constructor_class", constructor_class);
  106. gen.append(R"~~~(
  107. template<>
  108. void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Realm& realm)
  109. {
  110. auto& vm = realm.vm();
  111. )~~~");
  112. if (!named_properties_class.is_empty()) {
  113. gen.set("named_properties_class", named_properties_class);
  114. gen.append(R"~~~(
  115. auto named_properties_object = realm.create<@named_properties_class@>(realm);
  116. m_prototypes.set("@named_properties_class@"_fly_string, named_properties_object);
  117. )~~~");
  118. }
  119. gen.append(R"~~~(
  120. auto prototype = realm.create<@prototype_class@>(realm);
  121. m_prototypes.set("@interface_name@"_fly_string, prototype);
  122. auto constructor = realm.create<@constructor_class@>(realm);
  123. m_constructors.set("@interface_name@"_fly_string, constructor);
  124. prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable);
  125. constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@interface_name@"_string), JS::Attribute::Configurable);
  126. )~~~");
  127. if (legacy_constructor.has_value()) {
  128. gen.set("legacy_interface_name", legacy_constructor->name);
  129. gen.set("legacy_constructor_class", legacy_constructor->constructor_class);
  130. gen.append(R"~~~(
  131. auto legacy_constructor = realm.create<@legacy_constructor_class@>(realm);
  132. m_constructors.set("@legacy_interface_name@"_fly_string, legacy_constructor);
  133. legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"_string), JS::Attribute::Configurable);)~~~");
  134. }
  135. gen.append(R"~~~(
  136. }
  137. )~~~");
  138. };
  139. for (auto& interface : exposed_interfaces) {
  140. auto gen = generator.fork();
  141. String named_properties_class;
  142. if (interface.extended_attributes.contains("Global") && interface.supports_named_properties()) {
  143. named_properties_class = MUST(String::formatted("{}Properties", interface.name));
  144. }
  145. if (interface.is_namespace)
  146. add_namespace(gen, interface.name, interface.namespace_class);
  147. else
  148. add_interface(gen, interface.namespaced_name, interface.prototype_class, interface.constructor_class, lookup_legacy_constructor(interface), named_properties_class);
  149. }
  150. generator.append(R"~~~(
  151. }
  152. )~~~");
  153. auto generated_intrinsics_path = LexicalPath(output_path).append("IntrinsicDefinitions.cpp"sv).string();
  154. auto generated_intrinsics_file = TRY(Core::File::open(generated_intrinsics_path, Core::File::OpenMode::Write));
  155. TRY(generated_intrinsics_file->write_until_depleted(generator.as_string_view().bytes()));
  156. return {};
  157. }
  158. static ErrorOr<void> generate_exposed_interface_header(StringView class_name, StringView output_path)
  159. {
  160. StringBuilder builder;
  161. SourceGenerator generator(builder);
  162. generator.set("global_object_snake_name", ByteString(class_name).to_snakecase());
  163. generator.append(R"~~~(
  164. #pragma once
  165. #include <LibJS/Forward.h>
  166. namespace Web::Bindings {
  167. void add_@global_object_snake_name@_exposed_interfaces(JS::Object&);
  168. }
  169. )~~~");
  170. auto generated_header_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.h", class_name)).string();
  171. auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write));
  172. TRY(generated_header_file->write_until_depleted(generator.as_string_view().bytes()));
  173. return {};
  174. }
  175. static ErrorOr<void> generate_exposed_interface_implementation(StringView class_name, StringView output_path, Vector<IDL::Interface&>& exposed_interfaces)
  176. {
  177. StringBuilder builder;
  178. SourceGenerator generator(builder);
  179. generator.set("global_object_name", class_name);
  180. generator.set("global_object_snake_name", ByteString(class_name).to_snakecase());
  181. generator.append(R"~~~(
  182. #include <LibJS/Runtime/Object.h>
  183. #include <LibWeb/Bindings/Intrinsics.h>
  184. #include <LibWeb/Bindings/@global_object_name@ExposedInterfaces.h>
  185. )~~~");
  186. for (auto& interface : exposed_interfaces) {
  187. auto gen = generator.fork();
  188. gen.set("namespace_class", interface.namespace_class);
  189. gen.set("prototype_class", interface.prototype_class);
  190. gen.set("constructor_class", interface.constructor_class);
  191. if (interface.is_namespace) {
  192. gen.append(R"~~~(#include <LibWeb/Bindings/@namespace_class@.h>
  193. )~~~");
  194. } else {
  195. gen.append(R"~~~(#include <LibWeb/Bindings/@constructor_class@.h>
  196. #include <LibWeb/Bindings/@prototype_class@.h>
  197. )~~~");
  198. if (auto const& legacy_constructor = lookup_legacy_constructor(interface); legacy_constructor.has_value()) {
  199. gen.set("legacy_constructor_class", legacy_constructor->constructor_class);
  200. gen.append(R"~~~(#include <LibWeb/Bindings/@legacy_constructor_class@.h>
  201. )~~~");
  202. }
  203. }
  204. }
  205. generator.append(R"~~~(
  206. namespace Web::Bindings {
  207. void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
  208. {
  209. static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;
  210. )~~~");
  211. auto add_interface = [](SourceGenerator& gen, StringView name, StringView prototype_class, Optional<LegacyConstructor> const& legacy_constructor, Optional<ByteString const&> legacy_alias_name) {
  212. gen.set("interface_name", name);
  213. gen.set("prototype_class", prototype_class);
  214. gen.append(R"~~~(
  215. global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
  216. // https://webidl.spec.whatwg.org/#LegacyWindowAlias
  217. if (legacy_alias_name.has_value()) {
  218. if (legacy_alias_name->starts_with('(')) {
  219. auto legacy_alias_names = legacy_alias_name->substring_view(1).split_view(',');
  220. for (auto legacy_alias_name : legacy_alias_names) {
  221. gen.set("interface_alias_name", legacy_alias_name.trim_whitespace());
  222. gen.append(R"~~~(
  223. global.define_intrinsic_accessor("@interface_alias_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
  224. }
  225. } else {
  226. gen.set("interface_alias_name", *legacy_alias_name);
  227. gen.append(R"~~~(
  228. global.define_intrinsic_accessor("@interface_alias_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
  229. }
  230. }
  231. if (legacy_constructor.has_value()) {
  232. gen.set("legacy_interface_name", legacy_constructor->name);
  233. gen.append(R"~~~(
  234. global.define_intrinsic_accessor("@legacy_interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"_fly_string); });)~~~");
  235. }
  236. };
  237. auto add_namespace = [](SourceGenerator& gen, StringView name, StringView namespace_class) {
  238. gen.set("interface_name", name);
  239. gen.set("namespace_class", namespace_class);
  240. gen.append(R"~~~(
  241. global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_namespace<@namespace_class@>(realm, "@interface_name@"_fly_string); });)~~~");
  242. };
  243. for (auto& interface : exposed_interfaces) {
  244. auto gen = generator.fork();
  245. if (interface.is_namespace) {
  246. add_namespace(gen, interface.name, interface.namespace_class);
  247. } else if (!interface.extended_attributes.contains("LegacyNamespace"sv)) {
  248. if (class_name == "Window") {
  249. add_interface(gen, interface.namespaced_name, interface.prototype_class, lookup_legacy_constructor(interface), interface.extended_attributes.get("LegacyWindowAlias"sv));
  250. } else {
  251. add_interface(gen, interface.namespaced_name, interface.prototype_class, lookup_legacy_constructor(interface), {});
  252. }
  253. }
  254. }
  255. generator.append(R"~~~(
  256. }
  257. }
  258. )~~~");
  259. auto generated_implementation_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.cpp", class_name)).string();
  260. auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write));
  261. TRY(generated_implementation_file->write_until_depleted(generator.as_string_view().bytes()));
  262. return {};
  263. }
  264. ErrorOr<int> serenity_main(Main::Arguments arguments)
  265. {
  266. Core::ArgsParser args_parser;
  267. StringView output_path;
  268. Vector<ByteString> base_paths;
  269. Vector<ByteString> paths;
  270. args_parser.add_option(output_path, "Path to output generated files into", "output-path", 'o', "output-path");
  271. args_parser.add_option(Core::ArgsParser::Option {
  272. .argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
  273. .help_string = "Path to root of IDL file tree(s)",
  274. .long_name = "base-path",
  275. .short_name = 'b',
  276. .value_name = "base-path",
  277. .accept_value = [&](StringView s) {
  278. base_paths.append(s);
  279. return true;
  280. },
  281. });
  282. args_parser.add_positional_argument(paths, "Paths of every IDL file that could be Exposed", "paths");
  283. args_parser.parse(arguments);
  284. VERIFY(!paths.is_empty());
  285. VERIFY(!base_paths.is_empty());
  286. Vector<ByteString> lexical_bases;
  287. for (auto const& base_path : base_paths) {
  288. VERIFY(!base_path.is_empty());
  289. lexical_bases.append(base_path);
  290. }
  291. // Read in all IDL files, we must own the storage for all of these for the lifetime of the program
  292. Vector<ByteString> file_contents;
  293. for (ByteString const& path : paths) {
  294. auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
  295. if (file_or_error.is_error()) {
  296. s_error_string = ByteString::formatted("Unable to open file {}", path);
  297. return Error::from_string_view(s_error_string.view());
  298. }
  299. auto file = file_or_error.release_value();
  300. auto string = MUST(file->read_until_eof());
  301. file_contents.append(ByteString(ReadonlyBytes(string)));
  302. }
  303. VERIFY(paths.size() == file_contents.size());
  304. Vector<IDL::Parser> parsers;
  305. Vector<IDL::Interface&> intrinsics;
  306. Vector<IDL::Interface&> window_exposed;
  307. Vector<IDL::Interface&> dedicated_worker_exposed;
  308. Vector<IDL::Interface&> shared_worker_exposed;
  309. Vector<IDL::Interface&> shadow_realm_exposed;
  310. // TODO: service_worker_exposed
  311. for (size_t i = 0; i < paths.size(); ++i) {
  312. auto const& path = paths[i];
  313. IDL::Parser parser(path, file_contents[i], lexical_bases);
  314. auto& interface = parser.parse();
  315. if (interface.name.is_empty()) {
  316. s_error_string = ByteString::formatted("Interface for file {} missing", path);
  317. return Error::from_string_view(s_error_string.view());
  318. }
  319. TRY(add_to_interface_sets(interface, intrinsics, window_exposed, dedicated_worker_exposed, shared_worker_exposed, shadow_realm_exposed));
  320. parsers.append(move(parser));
  321. }
  322. TRY(generate_intrinsic_definitions(output_path, intrinsics));
  323. TRY(generate_exposed_interface_header("Window"sv, output_path));
  324. TRY(generate_exposed_interface_header("DedicatedWorker"sv, output_path));
  325. TRY(generate_exposed_interface_header("SharedWorker"sv, output_path));
  326. TRY(generate_exposed_interface_header("ShadowRealm"sv, output_path));
  327. // TODO: ServiceWorkerExposed.h
  328. TRY(generate_exposed_interface_implementation("Window"sv, output_path, window_exposed));
  329. TRY(generate_exposed_interface_implementation("DedicatedWorker"sv, output_path, dedicated_worker_exposed));
  330. TRY(generate_exposed_interface_implementation("SharedWorker"sv, output_path, shared_worker_exposed));
  331. TRY(generate_exposed_interface_implementation("ShadowRealm"sv, output_path, shadow_realm_exposed));
  332. // TODO: ServiceWorkerExposed.cpp
  333. return 0;
  334. }
  335. enum ExposedTo {
  336. Nobody = 0x0,
  337. DedicatedWorker = 0x1,
  338. SharedWorker = 0x2,
  339. ServiceWorker = 0x4,
  340. AudioWorklet = 0x8,
  341. Window = 0x10,
  342. ShadowRealm = 0x20,
  343. Worklet = 0x40,
  344. AllWorkers = DedicatedWorker | SharedWorker | ServiceWorker | AudioWorklet, // FIXME: Is "AudioWorklet" a Worker? We'll assume it is for now (here, and line below)
  345. All = AllWorkers | Window | ShadowRealm | Worklet,
  346. };
  347. AK_ENUM_BITWISE_OPERATORS(ExposedTo);
  348. static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
  349. {
  350. // NOTE: This roughly follows the definitions of https://webidl.spec.whatwg.org/#Exposed
  351. // It does not remotely interpret all the abstract operations therein though.
  352. auto maybe_exposed = interface.extended_attributes.get("Exposed");
  353. if (!maybe_exposed.has_value()) {
  354. s_error_string = ByteString::formatted("Interface {} is missing extended attribute Exposed", interface.name);
  355. return Error::from_string_view(s_error_string.view());
  356. }
  357. auto exposed = maybe_exposed.value().trim_whitespace();
  358. if (exposed == "*"sv)
  359. return ExposedTo::All;
  360. if (exposed == "Nobody"sv)
  361. return ExposedTo::Nobody;
  362. if (exposed == "Window"sv)
  363. return ExposedTo::Window;
  364. if (exposed == "Worker"sv)
  365. return ExposedTo::AllWorkers;
  366. if (exposed == "DedicatedWorker"sv)
  367. return ExposedTo::DedicatedWorker;
  368. if (exposed == "SharedWorker"sv)
  369. return ExposedTo::SharedWorker;
  370. if (exposed == "ServiceWorker"sv)
  371. return ExposedTo::ServiceWorker;
  372. if (exposed == "AudioWorklet"sv)
  373. return ExposedTo::AudioWorklet;
  374. if (exposed == "Worklet"sv)
  375. return ExposedTo::Worklet;
  376. if (exposed == "ShadowRealm"sv)
  377. return ExposedTo::ShadowRealm;
  378. if (exposed[0] == '(') {
  379. ExposedTo whom = Nobody;
  380. for (StringView candidate : exposed.substring_view(1, exposed.length() - 1).split_view(',')) {
  381. candidate = candidate.trim_whitespace();
  382. if (candidate == "Window"sv) {
  383. whom |= ExposedTo::Window;
  384. } else if (candidate == "Worker"sv) {
  385. whom |= ExposedTo::AllWorkers;
  386. } else if (candidate == "DedicatedWorker"sv) {
  387. whom |= ExposedTo::DedicatedWorker;
  388. } else if (candidate == "SharedWorker"sv) {
  389. whom |= ExposedTo::SharedWorker;
  390. } else if (candidate == "ServiceWorker"sv) {
  391. whom |= ExposedTo::ServiceWorker;
  392. } else if (candidate == "AudioWorklet"sv) {
  393. whom |= ExposedTo::AudioWorklet;
  394. } else if (candidate == "Worklet"sv) {
  395. whom |= ExposedTo::Worklet;
  396. } else if (candidate == "ShadowRealm"sv) {
  397. whom |= ExposedTo::ShadowRealm;
  398. } else {
  399. s_error_string = ByteString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name);
  400. return Error::from_string_view(s_error_string.view());
  401. }
  402. }
  403. if (whom == ExposedTo::Nobody) {
  404. s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
  405. return Error::from_string_view(s_error_string.view());
  406. }
  407. return whom;
  408. }
  409. s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
  410. return Error::from_string_view(s_error_string.view());
  411. }
  412. ErrorOr<void> add_to_interface_sets(IDL::Interface& interface, Vector<IDL::Interface&>& intrinsics, Vector<IDL::Interface&>& window_exposed, Vector<IDL::Interface&>& dedicated_worker_exposed, Vector<IDL::Interface&>& shared_worker_exposed, Vector<IDL::Interface&>& shadow_realm_exposed)
  413. {
  414. // TODO: Add service worker exposed and audio worklet exposed
  415. auto whom = TRY(parse_exposure_set(interface));
  416. intrinsics.append(interface);
  417. if (whom & ExposedTo::Window)
  418. window_exposed.append(interface);
  419. if (whom & ExposedTo::DedicatedWorker)
  420. dedicated_worker_exposed.append(interface);
  421. if (whom & ExposedTo::SharedWorker)
  422. shared_worker_exposed.append(interface);
  423. if (whom & ExposedTo::ShadowRealm)
  424. shadow_realm_exposed.append(interface);
  425. return {};
  426. }