summaryrefslogtreecommitdiff
path: root/cli/cdp.rs
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2022-03-02 13:39:08 +0900
committerGitHub <noreply@github.com>2022-03-02 13:39:08 +0900
commitb751e97a014f486375c9b8c99446de237c7dbede (patch)
treec7d9fd2425520c9c033ef8a9a3cc1f2f26a211f1 /cli/cdp.rs
parent7fc5bfe51b7d405aaa5293ec6f1a8f1e9119aea2 (diff)
fix(repl): fix null eval result (#13804)
Co-authored-by: Satya Rohith <me@satyarohith.com>
Diffstat (limited to 'cli/cdp.rs')
-rw-r--r--cli/cdp.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/cdp.rs b/cli/cdp.rs
index 55229947d..d1b09565d 100644
--- a/cli/cdp.rs
+++ b/cli/cdp.rs
@@ -4,6 +4,7 @@
use deno_core::serde_json;
use deno_core::serde_json::Value;
use serde::Deserialize;
+use serde::Deserializer;
use serde::Serialize;
/// https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-awaitPromise
@@ -245,6 +246,7 @@ pub struct RemoteObject {
pub kind: String,
pub subtype: Option<String>,
pub class_name: Option<String>,
+ #[serde(default, deserialize_with = "deserialize_some")]
pub value: Option<Value>,
pub unserializable_value: Option<UnserializableValue>,
pub description: Option<String>,
@@ -253,6 +255,16 @@ pub struct RemoteObject {
pub custom_preview: Option<CustomPreview>,
}
+// Any value that is present is considered Some value, including null.
+// ref: https://github.com/serde-rs/serde/issues/984#issuecomment-314143738
+fn deserialize_some<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
+where
+ T: Deserialize<'de>,
+ D: Deserializer<'de>,
+{
+ Deserialize::deserialize(deserializer).map(Some)
+}
+
/// https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-ObjectPreview
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]