summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/dynamic_import
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/testdata/dynamic_import')
-rw-r--r--cli/tests/testdata/dynamic_import/b.js2
-rw-r--r--cli/tests/testdata/dynamic_import/c.js2
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_blob_local.ts6
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_blob_local.ts.out5
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_blob_remote.ts4
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_blob_remote.ts.out5
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_data_local.ts5
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_data_local.ts.out5
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_data_remote.ts3
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_data_remote.ts.out5
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_remote_remote.ts3
-rw-r--r--cli/tests/testdata/dynamic_import/permissions_remote_remote.ts.out5
-rw-r--r--cli/tests/testdata/dynamic_import/static_remote.ts2
13 files changed, 52 insertions, 0 deletions
diff --git a/cli/tests/testdata/dynamic_import/b.js b/cli/tests/testdata/dynamic_import/b.js
new file mode 100644
index 000000000..6ea50d360
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/b.js
@@ -0,0 +1,2 @@
+import "./bad.mjs";
+export default () => "error";
diff --git a/cli/tests/testdata/dynamic_import/c.js b/cli/tests/testdata/dynamic_import/c.js
new file mode 100644
index 000000000..20546455e
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/c.js
@@ -0,0 +1,2 @@
+await import("./bad2.mjs");
+export default () => "error";
diff --git a/cli/tests/testdata/dynamic_import/permissions_blob_local.ts b/cli/tests/testdata/dynamic_import/permissions_blob_local.ts
new file mode 100644
index 000000000..9ef4158ce
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_blob_local.ts
@@ -0,0 +1,6 @@
+// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown.
+const code = `import "file:///${
+ Deno.build.os == "windows" ? "C:/" : ""
+}local_file.ts";`;
+const blob = new Blob([code]);
+await import(URL.createObjectURL(blob));
diff --git a/cli/tests/testdata/dynamic_import/permissions_blob_local.ts.out b/cli/tests/testdata/dynamic_import/permissions_blob_local.ts.out
new file mode 100644
index 000000000..6dfa8e527
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_blob_local.ts.out
@@ -0,0 +1,5 @@
+error: Uncaught (in promise) TypeError: Requires read access to "[WILDCARD]local_file.ts", run again with the --allow-read flag
+ at blob:null/[WILDCARD]:1:0
+await import(URL.createObjectURL(blob));
+^
+ at async file:///[WILDCARD]/dynamic_import/permissions_blob_local.ts:6:1
diff --git a/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts b/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts
new file mode 100644
index 000000000..1e2c8c21a
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts
@@ -0,0 +1,4 @@
+// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown.
+const code = `import "https://example.com/some/file.ts";`;
+const blob = new Blob([code]);
+await import(URL.createObjectURL(blob));
diff --git a/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts.out b/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts.out
new file mode 100644
index 000000000..60d71ed6d
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_blob_remote.ts.out
@@ -0,0 +1,5 @@
+error: Uncaught (in promise) TypeError: Requires net access to "example.com", run again with the --allow-net flag
+ at blob:null/[WILDCARD]:1:0
+await import(URL.createObjectURL(blob));
+^
+ at async file:///[WILDCARD]/dynamic_import/permissions_blob_remote.ts:4:1
diff --git a/cli/tests/testdata/dynamic_import/permissions_data_local.ts b/cli/tests/testdata/dynamic_import/permissions_data_local.ts
new file mode 100644
index 000000000..be4fc1c34
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_data_local.ts
@@ -0,0 +1,5 @@
+// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown.
+const code = `import "file:///${
+ Deno.build.os == "windows" ? "C:/" : ""
+}local_file.ts";`;
+await import(`data:application/javascript;base64,${btoa(code)}`);
diff --git a/cli/tests/testdata/dynamic_import/permissions_data_local.ts.out b/cli/tests/testdata/dynamic_import/permissions_data_local.ts.out
new file mode 100644
index 000000000..c9fcb0a17
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_data_local.ts.out
@@ -0,0 +1,5 @@
+error: Uncaught (in promise) TypeError: Requires read access to "[WILDCARD]local_file.ts", run again with the --allow-read flag
+ at data:application/javascript;base64,[WILDCARD]:1:0
+await import(`data:application/javascript;base64,${btoa(code)}`);
+^
+ at async file:///[WILDCARD]/dynamic_import/permissions_data_local.ts:5:1
diff --git a/cli/tests/testdata/dynamic_import/permissions_data_remote.ts b/cli/tests/testdata/dynamic_import/permissions_data_remote.ts
new file mode 100644
index 000000000..b0a9540c3
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_data_remote.ts
@@ -0,0 +1,3 @@
+// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown.
+const code = `import "https://example.com/some/file.ts";`;
+await import(`data:application/javascript;base64,${btoa(code)}`);
diff --git a/cli/tests/testdata/dynamic_import/permissions_data_remote.ts.out b/cli/tests/testdata/dynamic_import/permissions_data_remote.ts.out
new file mode 100644
index 000000000..772f0b51e
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_data_remote.ts.out
@@ -0,0 +1,5 @@
+error: Uncaught (in promise) TypeError: Requires net access to "example.com", run again with the --allow-net flag
+ at data:application/javascript;base64,aW1wb3J0ICJodHRwczovL2V4YW1wbGUuY29tL3NvbWUvZmlsZS50cyI7:1:0
+await import(`data:application/javascript;base64,${btoa(code)}`);
+^
+ at async file:///[WILDCARD]/dynamic_import/permissions_data_remote.ts:3:1
diff --git a/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts
new file mode 100644
index 000000000..0033bcccc
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts
@@ -0,0 +1,3 @@
+await import(
+ "http://localhost:4545/dynamic_import/static_remote.ts"
+);
diff --git a/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts.out b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts.out
new file mode 100644
index 000000000..cd7f58bb9
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts.out
@@ -0,0 +1,5 @@
+error: Uncaught (in promise) TypeError: Requires net access to "example.com", run again with the --allow-net flag
+ at http://localhost:4545/dynamic_import/static_remote.ts:2:0
+await import(
+^
+ at async file:///[WILDCARD]/dynamic_import/permissions_remote_remote.ts:1:1
diff --git a/cli/tests/testdata/dynamic_import/static_remote.ts b/cli/tests/testdata/dynamic_import/static_remote.ts
new file mode 100644
index 000000000..2d6e820fd
--- /dev/null
+++ b/cli/tests/testdata/dynamic_import/static_remote.ts
@@ -0,0 +1,2 @@
+// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown.
+import "https://example.com/some/file.ts";