From fac64478157ee563b185edb5734688e4523df3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 7 Jan 2023 17:25:34 +0100 Subject: refactor(permissions): add PermissionsContainer struct for internal mutability (#17134) Turns out we were cloning permissions which after prompting were discarded, so the state of permissions was never preserved. To handle that we need to store all permissions behind "Arc>" (because there are situations where we need to send them to other thread). Testing and benching code still uses "Permissions" in most places - it's undesirable to share the same permission set between various test/bench files - otherwise granting or revoking permissions in one file would influence behavior of other test files. --- cli/tests/run_tests.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cli/tests/run_tests.rs') diff --git a/cli/tests/run_tests.rs b/cli/tests/run_tests.rs index dfe95d9a8..8460d3f8f 100644 --- a/cli/tests/run_tests.rs +++ b/cli/tests/run_tests.rs @@ -3725,4 +3725,21 @@ console.log("finish"); args: "run --quiet run/001_hello.js --allow-net", output: "run/001_hello.js.out", }); + + // Regression test for https://github.com/denoland/deno/issues/16772 + #[test] + fn file_fetcher_preserves_permissions() { + let _guard = util::http_server(); + util::with_pty(&["repl"], |mut console| { + console.write_text( + "const a = import('http://127.0.0.1:4545/run/019_media_types.ts');", + ); + console.write_text("y"); + console.write_line(""); + console.write_line("close();"); + let output = console.read_all_output(); + assert_contains!(output, "success"); + assert_contains!(output, "true"); + }); + } } -- cgit v1.2.3