Skip to content

Commit

Permalink
Merge pull request #1556 from cloudflare/jsnell/remove-importscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell authored Jan 22, 2024
2 parents 84417dd + f2485d8 commit 4e41cd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/workerd/api/global-scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ class WorkerGlobalScope: public EventTarget, public jsg::ContextGlobal {
public:
jsg::Unimplemented importScripts(kj::String s) { return {}; };

JSG_RESOURCE_TYPE(WorkerGlobalScope) {
JSG_RESOURCE_TYPE(WorkerGlobalScope, CompatibilityFlags::Reader flags) {
JSG_INHERIT(EventTarget);

JSG_NESTED_TYPE(EventTarget);

JSG_METHOD(importScripts);
if (!flags.getNoImportScripts()) {
JSG_METHOD(importScripts);
}

JSG_TS_DEFINE(type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
Expand Down
6 changes: 6 additions & 0 deletions src/workerd/io/compatibility-date.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,10 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef {
# The client stub is currently guarded by the experimental flag, however, we don't want to let
# experimental clients call JS methods over RPC if the Worker receiving the request hasn't
# explicitly exposed its methods to RPC.

noImportScripts @40 :Bool
$compatEnableFlag("no_global_importscripts")
$compatDisableFlag("global_importscripts")
$compatEnableDate("2024-03-04");
# Removes the non-implemented importScripts() function from the global scope.
}

0 comments on commit 4e41cd4

Please sign in to comment.