summaryrefslogtreecommitdiff
path: root/cli/tests/integration/inspector_tests.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-07-20 15:41:36 +0200
committerGitHub <noreply@github.com>2021-07-20 15:41:36 +0200
commit9b9becf1ae256b645e37a7eecf3441f3ae4b8ea5 (patch)
tree6c38ba3bab912db6c1fd0cd1f2b6601d2bbb8ca6 /cli/tests/integration/inspector_tests.rs
parent73ed009ddae73353c4df882a43db28508d6ef35e (diff)
fix: panic for non-WS connections to inspector (#11466)
Diffstat (limited to 'cli/tests/integration/inspector_tests.rs')
-rw-r--r--cli/tests/integration/inspector_tests.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs
index ebbfe94d2..edc18b8d7 100644
--- a/cli/tests/integration/inspector_tests.rs
+++ b/cli/tests/integration/inspector_tests.rs
@@ -493,3 +493,29 @@ async fn inspector_json_list() {
assert!(matching_endpoint.is_some());
child.kill().unwrap();
}
+
+#[tokio::test]
+async fn inspector_connect_non_ws() {
+ // https://github.com/denoland/deno/issues/11449
+ // Verify we don't panic if non-WS connection is being established
+ let script = util::tests_path().join("inspector1.js");
+ let mut child = util::deno_cmd()
+ .arg("run")
+ .arg(inspect_flag_with_unique_port("--inspect"))
+ .arg(script)
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+
+ let stderr = child.stderr.as_mut().unwrap();
+ let mut stderr_lines =
+ std::io::BufReader::new(stderr).lines().map(|r| r.unwrap());
+ let mut ws_url = extract_ws_url_from_stderr(&mut stderr_lines);
+ // Change scheme to URL and try send a request. We're not interested
+ // in the request result, just that the process doesn't panic.
+ ws_url.set_scheme("http").unwrap();
+ let resp = reqwest::get(ws_url).await.unwrap();
+ assert_eq!("400 Bad Request", resp.status().to_string());
+ child.kill().unwrap();
+ child.wait().unwrap();
+}