From 4cdb84ffab5586ee9aeac9057ff3a4d343083f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dari=CC=81o=20Kondratiuk?= Date: Thu, 27 Dec 2018 09:21:00 -0300 Subject: [PATCH 1/5] Some progress --- lib/PuppeteerSharp/CDPSession.cs | 12 ++++++------ lib/PuppeteerSharp/Connection.cs | 8 ++++---- lib/PuppeteerSharp/EvaluationFailedException.cs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/PuppeteerSharp/CDPSession.cs b/lib/PuppeteerSharp/CDPSession.cs index 24967eaa2..2ad1e985b 100644 --- a/lib/PuppeteerSharp/CDPSession.cs +++ b/lib/PuppeteerSharp/CDPSession.cs @@ -106,7 +106,7 @@ internal CDPSession(IConnection connection, TargetType targetType, string sessio #region Public Methods - internal void Send(string method, dynamic args = null) + internal void Send(string method, object args = null) => _ = SendAsync(method, args, false); /// @@ -115,9 +115,9 @@ internal void Send(string method, dynamic args = null) /// The method name /// The method args /// The task. - public async Task SendAsync(string method, dynamic args = null) + public async Task SendAsync(string method, object args = null) { - JObject content = await SendAsync(method, args).ConfigureAwait(false); + var content = await SendAsync(method, args).ConfigureAwait(false); return content.ToObject(true); } @@ -133,7 +133,7 @@ public async Task SendAsync(string method, dynamic args = null) /// /// The task. /// - public async Task SendAsync(string method, dynamic args = null, bool waitForCallback = true) + public async Task SendAsync(string method, object args = null, bool waitForCallback = true) { if (Connection == null) { @@ -150,7 +150,7 @@ public async Task SendAsync(string method, dynamic args = null, bool wa { MessageKeys.Params, args } }, JsonHelper.DefaultJsonSerializerSettings); - _logger.LogTrace("Send ► {Id} Method {Method} Params {@Params}", id, method, (object)args); + _logger.LogTrace("Send ► {Id} Method {Method} Params {@Params}", id, method, args); MessageTask callback = null; if (waitForCallback) @@ -310,7 +310,7 @@ internal CDPSession CreateSession(TargetType targetType, string sessionId) #region IConnection ILoggerFactory IConnection.LoggerFactory => LoggerFactory; bool IConnection.IsClosed => IsClosed; - Task IConnection.SendAsync(string method, dynamic args, bool waitForCallback) + Task IConnection.SendAsync(string method, object args, bool waitForCallback) => SendAsync(method, args, waitForCallback); IConnection IConnection.Connection => Connection; void IConnection.Close(string closeReason) => Close(closeReason); diff --git a/lib/PuppeteerSharp/Connection.cs b/lib/PuppeteerSharp/Connection.cs index 2aa04a16e..97a1ef231 100644 --- a/lib/PuppeteerSharp/Connection.cs +++ b/lib/PuppeteerSharp/Connection.cs @@ -87,7 +87,7 @@ internal Connection(string url, int delay, IConnectionTransport transport, ILogg #region Public Methods - internal async Task SendAsync(string method, dynamic args = null, bool waitForCallback = true) + internal async Task SendAsync(string method, object args = null, bool waitForCallback = true) { if (IsClosed) { @@ -119,9 +119,9 @@ internal async Task SendAsync(string method, dynamic args = null, bool return waitForCallback ? await callback.TaskWrapper.Task.WithConnectionCheck(this).ConfigureAwait(false) : null; } - internal async Task SendAsync(string method, dynamic args = null) + internal async Task SendAsync(string method, object args = null) { - JToken response = await SendAsync(method, args).ConfigureAwait(false); + var response = await SendAsync(method, args).ConfigureAwait(false); return response.ToObject(true); } @@ -305,7 +305,7 @@ public void Dispose() #region IConnection ILoggerFactory IConnection.LoggerFactory => LoggerFactory; bool IConnection.IsClosed => IsClosed; - Task IConnection.SendAsync(string method, dynamic args, bool waitForCallback) + Task IConnection.SendAsync(string method, object args, bool waitForCallback) => SendAsync(method, args, waitForCallback); IConnection IConnection.Connection => null; void IConnection.Close(string closeReason) => Close(closeReason); diff --git a/lib/PuppeteerSharp/EvaluationFailedException.cs b/lib/PuppeteerSharp/EvaluationFailedException.cs index 4c29779ef..01afef4a8 100644 --- a/lib/PuppeteerSharp/EvaluationFailedException.cs +++ b/lib/PuppeteerSharp/EvaluationFailedException.cs @@ -4,7 +4,7 @@ namespace PuppeteerSharp { /// - /// Exception thrown by . + /// Exception thrown by . /// [Serializable] public class EvaluationFailedException : PuppeteerException From 62a1a6fe8087db01c003c3c83850c9f63cb1bfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dari=CC=81o=20Kondratiuk?= Date: Thu, 27 Dec 2018 20:05:31 -0300 Subject: [PATCH 2/5] Some progress --- lib/PuppeteerSharp/CDPSession.cs | 2 +- lib/PuppeteerSharp/ExecutionContext.cs | 9 +++++---- lib/PuppeteerSharp/Messaging/MessageKeys.cs | 1 - .../Messaging/RuntimeQueryObjectsResponse.cs | 9 +++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs diff --git a/lib/PuppeteerSharp/CDPSession.cs b/lib/PuppeteerSharp/CDPSession.cs index 2ad1e985b..b8dd4d09e 100644 --- a/lib/PuppeteerSharp/CDPSession.cs +++ b/lib/PuppeteerSharp/CDPSession.cs @@ -15,7 +15,7 @@ namespace PuppeteerSharp { /// /// The CDPSession instances are used to talk raw Chrome Devtools Protocol: - /// * Protocol methods can be called with method. + /// * Protocol methods can be called with method. /// * Protocol events, using the event. /// /// Documentation on DevTools Protocol can be found here: . diff --git a/lib/PuppeteerSharp/ExecutionContext.cs b/lib/PuppeteerSharp/ExecutionContext.cs index 08f2ae944..2e36517c6 100755 --- a/lib/PuppeteerSharp/ExecutionContext.cs +++ b/lib/PuppeteerSharp/ExecutionContext.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json.Linq; using PuppeteerSharp.Messaging; using PuppeteerSharp.Helpers; +using static PuppeteerSharp.Messaging.RuntimeQueryObjectsResponse; namespace PuppeteerSharp { @@ -116,12 +117,12 @@ public async Task QueryObjectsAsync(JSHandle prototypeHandle) throw new PuppeteerException("Prototype JSHandle must not be referencing primitive value"); } - var response = await _client.SendAsync("Runtime.queryObjects", new Dictionary + var response = await _client.SendAsync("Runtime.queryObjects", new Dictionary { {"prototypeObjectId", objectId.ToString()} }).ConfigureAwait(false); - return CreateJSHandle(response[MessageKeys.Objects]); + return CreateJSHandle(response.Objects); } internal async Task EvaluateExpressionHandleAsync(string script) @@ -173,8 +174,8 @@ internal async Task EvaluateFunctionHandleAsync(string script, params } } - internal JSHandle CreateJSHandle(dynamic remoteObject) - => (remoteObject.subtype == "node" && Frame != null) + internal JSHandle CreateJSHandle(JToken remoteObject) + => (remoteObject.SelectToken(MessageKeys.Subtype).AsString() == "node" && Frame != null) ? new ElementHandle(this, _client, remoteObject, Frame.FrameManager.Page, Frame.FrameManager) : new JSHandle(this, _client, remoteObject); diff --git a/lib/PuppeteerSharp/Messaging/MessageKeys.cs b/lib/PuppeteerSharp/Messaging/MessageKeys.cs index 3d46db68a..c64c0a690 100644 --- a/lib/PuppeteerSharp/Messaging/MessageKeys.cs +++ b/lib/PuppeteerSharp/Messaging/MessageKeys.cs @@ -21,7 +21,6 @@ internal class MessageKeys public const string PromptText = "promptText"; public const string Enumerable = "enumerable"; public const string Data = "data"; - public const string Objects = "objects"; public const string Name = "name"; public const string Value = "value"; public const string Text = "text"; diff --git a/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs b/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs new file mode 100644 index 000000000..5bc350e99 --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs @@ -0,0 +1,9 @@ +using Newtonsoft.Json.Linq; + +namespace PuppeteerSharp.Messaging +{ + internal class RuntimeQueryObjectsResponse + { + public JToken Objects { get; set; } + } +} From 731d71eb5f5a6c35fbe19289f00871e6364e676e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dari=CC=81o=20Kondratiuk?= Date: Thu, 27 Dec 2018 20:48:47 -0300 Subject: [PATCH 3/5] Feature complete --- .../PuppeteerSharpPdfDemo-Local.csproj | 9 ++----- .../PuppeteerSharpPdfDemo.csproj | 10 ++------ lib/PuppeteerSharp/ExecutionContext.cs | 10 ++++---- .../Helpers/RemoteObjectHelper.cs | 2 +- lib/PuppeteerSharp/IConnection.cs | 2 +- lib/PuppeteerSharp/JSHandle.cs | 2 +- lib/PuppeteerSharp/MessageException.cs | 2 +- .../Messaging/EvaluateHandleResponse.cs | 10 ++++++++ .../Messaging/LogEntryAddedResponse.cs | 6 +++-- .../Messaging/PageCaptureScreenshotRequest.cs | 15 +++++++++++ .../Messaging/PageConsoleResponse.cs | 6 +++-- lib/PuppeteerSharp/Page.cs | 25 ++++++++++--------- lib/PuppeteerSharp/Worker.cs | 2 +- 13 files changed, 60 insertions(+), 41 deletions(-) mode change 100755 => 100644 lib/PuppeteerSharp/JSHandle.cs create mode 100644 lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs create mode 100644 lib/PuppeteerSharp/Messaging/PageCaptureScreenshotRequest.cs diff --git a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj index f12d1f7da..b9fbd3d89 100644 --- a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj +++ b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj @@ -2,13 +2,8 @@ Exe - netcoreapp2.0;net471 - - - 7.2 - - - 7.2 + netcoreapp2.2;net471 + 7.3 win7-x64 diff --git a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj index 1e72bb176..836052b60 100644 --- a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj +++ b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj @@ -2,14 +2,8 @@ Exe - netcoreapp2.0 - - - - 7.2 - - - 7.2 + netcoreapp2.2 + 7.3 diff --git a/lib/PuppeteerSharp/ExecutionContext.cs b/lib/PuppeteerSharp/ExecutionContext.cs index 2e36517c6..b8e77e26c 100755 --- a/lib/PuppeteerSharp/ExecutionContext.cs +++ b/lib/PuppeteerSharp/ExecutionContext.cs @@ -202,17 +202,17 @@ private async Task EvaluateAsync(Task handleEvaluator) return result is JToken token && token.Type == JTokenType.Null ? default : result; } - private async Task EvaluateHandleAsync(string method, dynamic args) + private async Task EvaluateHandleAsync(string method, object args) { - var response = await _client.SendAsync(method, args).ConfigureAwait(false); + var response = await _client.SendAsync(method, args).ConfigureAwait(false); - if (response[MessageKeys.ExceptionDetails] is JToken exceptionDetails) + if (response.ExceptionDetails != null) { throw new EvaluationFailedException("Evaluation failed: " + - GetExceptionMessage(exceptionDetails.ToObject(true))); + GetExceptionMessage(response.ExceptionDetails.ToObject(true))); } - return CreateJSHandle(response.result); + return CreateJSHandle(response.Result); } private object FormatArgument(object arg) diff --git a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs index c6f8b8f5e..c3578603a 100755 --- a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs +++ b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs @@ -56,7 +56,7 @@ internal static object ValueFromRemoteObject(JToken remoteObject) } } - internal static async Task ReleaseObject(CDPSession client, JToken remoteObject, ILogger logger) + internal static async Task ReleaseObjectAsync(CDPSession client, JToken remoteObject, ILogger logger) { var objectId = remoteObject[MessageKeys.ObjectId]?.AsString(); diff --git a/lib/PuppeteerSharp/IConnection.cs b/lib/PuppeteerSharp/IConnection.cs index bd0aa3240..cfb451259 100644 --- a/lib/PuppeteerSharp/IConnection.cs +++ b/lib/PuppeteerSharp/IConnection.cs @@ -34,7 +34,7 @@ internal interface IConnection /// If true the method will return a task to be completed when the message is confirmed by Chromium. /// If false the task will be considered complete after sending the message to Chromium. /// - Task SendAsync(string method, dynamic args = null, bool waitForCallback = true); + Task SendAsync(string method, object args = null, bool waitForCallback = true); /// /// Gets the parent connection /// diff --git a/lib/PuppeteerSharp/JSHandle.cs b/lib/PuppeteerSharp/JSHandle.cs old mode 100755 new mode 100644 index 615a8f3ae..0794fcf5b --- a/lib/PuppeteerSharp/JSHandle.cs +++ b/lib/PuppeteerSharp/JSHandle.cs @@ -147,7 +147,7 @@ public async Task DisposeAsync() } Disposed = true; - await RemoteObjectHelper.ReleaseObject(Client, RemoteObject, Logger).ConfigureAwait(false); + await RemoteObjectHelper.ReleaseObjectAsync(Client, RemoteObject, Logger).ConfigureAwait(false); } /// diff --git a/lib/PuppeteerSharp/MessageException.cs b/lib/PuppeteerSharp/MessageException.cs index 30bd9fd7c..d740782f0 100644 --- a/lib/PuppeteerSharp/MessageException.cs +++ b/lib/PuppeteerSharp/MessageException.cs @@ -5,7 +5,7 @@ namespace PuppeteerSharp { /// - /// Exception thrown by + /// Exception thrown by /// public class MessageException : PuppeteerException { diff --git a/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs b/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs new file mode 100644 index 000000000..0387d4979 --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json.Linq; + +namespace PuppeteerSharp.Messaging +{ + internal class EvaluateHandleResponse + { + public JToken ExceptionDetails { get; set; } + public JToken Result { get; set; } + } +} diff --git a/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs b/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs index a72c420d1..c94ce0f24 100644 --- a/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs +++ b/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs @@ -1,4 +1,6 @@ -namespace PuppeteerSharp.Messaging +using Newtonsoft.Json.Linq; + +namespace PuppeteerSharp.Messaging { internal class LogEntryAddedResponse { @@ -7,7 +9,7 @@ internal class LogEntryAddedResponse internal class LogEntry { public TargetType Source { get; set; } - public dynamic[] Args { get; set; } + public JToken[] Args { get; set; } public ConsoleType Level { get; set; } public string Text { get; set; } } diff --git a/lib/PuppeteerSharp/Messaging/PageCaptureScreenshotRequest.cs b/lib/PuppeteerSharp/Messaging/PageCaptureScreenshotRequest.cs new file mode 100644 index 000000000..d8b0fc8ee --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/PageCaptureScreenshotRequest.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using PuppeteerSharp.Media; + +namespace PuppeteerSharp.Messaging +{ + internal class PageCaptureScreenshotRequest + { + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string Format { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int Quality { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Clip Clip { get; set; } + } +} diff --git a/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs b/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs index d6236eed9..5278b4b51 100644 --- a/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs +++ b/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs @@ -1,9 +1,11 @@ -namespace PuppeteerSharp.Messaging +using Newtonsoft.Json.Linq; + +namespace PuppeteerSharp.Messaging { internal class PageConsoleResponse { public ConsoleType Type { get; set; } - public dynamic[] Args { get; set; } + public JToken[] Args { get; set; } public int ExecutionContextId { get; set; } } } diff --git a/lib/PuppeteerSharp/Page.cs b/lib/PuppeteerSharp/Page.cs index 0323782d2..16f7d2ff6 100644 --- a/lib/PuppeteerSharp/Page.cs +++ b/lib/PuppeteerSharp/Page.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; @@ -1679,18 +1678,19 @@ private async Task PerformScreenshot(ScreenshotType type, ScreenshotOpti } } - dynamic screenMessage = new ExpandoObject(); - - screenMessage.format = type.ToString().ToLower(); + var screenMessage = new PageCaptureScreenshotRequest + { + Format = type.ToString().ToLower() + }; if (options.Quality.HasValue) { - screenMessage.quality = options.Quality.Value; + screenMessage.Quality = options.Quality.Value; } if (clip != null) { - screenMessage.clip = clip; + screenMessage.Clip = clip; } var result = await Client.SendAsync("Page.captureScreenshot", screenMessage).ConfigureAwait(false); @@ -1797,7 +1797,7 @@ private async void Client_MessageReceived(object sender, MessageEventArgs e) OnDetachedFromTarget(e); break; case "Log.entryAdded": - OnLogEntryAdded(e.MessageData.ToObject(true)); + await OnLogEntryAddedAsync(e.MessageData.ToObject(true)).ConfigureAwait(false); break; case "Runtime.bindingCalled": await OnBindingCalled(e.MessageData.ToObject(true)).ConfigureAwait(false); @@ -1851,6 +1851,7 @@ private async Task OnBindingCalled(BindingCalledResponse e) private async Task ExecuteBinding(BindingCalledResponse e) { + const string taskResultPropertyName = "Result"; object result; var binding = _pageBindings[e.BindingPayload.Name]; var methodParams = binding.Method.GetParameters().Select(parameter => parameter.ParameterType).ToArray(); @@ -1865,7 +1866,7 @@ private async Task ExecuteBinding(BindingCalledResponse e) if (taskResult.GetType().IsGenericType) { // the task is already awaited and therefore the call to property Result will not deadlock - result = ((dynamic)taskResult).Result; + result = taskResult.GetType().GetProperty(taskResultPropertyName).GetValue(taskResult); } } @@ -1904,13 +1905,13 @@ private async Task OnAttachedToTarget(MessageEventArgs e) WorkerCreated?.Invoke(this, new WorkerEventArgs(worker)); } - private void OnLogEntryAdded(LogEntryAddedResponse e) + private async Task OnLogEntryAddedAsync(LogEntryAddedResponse e) { if (e.Entry.Args != null) { foreach (var arg in e.Entry?.Args) { - RemoteObjectHelper.ReleaseObject(Client, arg, _logger); + await RemoteObjectHelper.ReleaseObjectAsync(Client, arg, _logger); } } if (e.Entry.Source != TargetType.Worker) @@ -1982,7 +1983,7 @@ private void OnDialog(PageJavascriptDialogOpeningResponse message) private Task OnConsoleAPI(PageConsoleResponse message) { var ctx = _frameManager.ExecutionContextById(message.ExecutionContextId); - var values = message.Args.Select(i => ctx.CreateJSHandle(i)).ToArray(); + var values = message.Args.Select(i => ctx.CreateJSHandle(i)).ToArray(); return AddConsoleMessage(message.Type, values); } @@ -1992,7 +1993,7 @@ private async Task AddConsoleMessage(ConsoleType type, JSHandle[] values) { foreach (var arg in values) { - await RemoteObjectHelper.ReleaseObject(Client, arg.RemoteObject, _logger).ConfigureAwait(false); + await RemoteObjectHelper.ReleaseObjectAsync(Client, arg.RemoteObject, _logger).ConfigureAwait(false); } return; diff --git a/lib/PuppeteerSharp/Worker.cs b/lib/PuppeteerSharp/Worker.cs index a56d13b77..b79eff08e 100644 --- a/lib/PuppeteerSharp/Worker.cs +++ b/lib/PuppeteerSharp/Worker.cs @@ -130,7 +130,7 @@ private async Task OnConsoleAPICalled(MessageEventArgs e) var consoleData = e.MessageData.ToObject(true); await _consoleAPICalled( consoleData.Type, - consoleData.Args.Select(i => _jsHandleFactory(_executionContext, i)).ToArray()) + consoleData.Args.Select(i => _jsHandleFactory(_executionContext, i)).ToArray()) .ConfigureAwait(false); } From f1480f9acba6f7dc25295cd199d4713c22868eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dari=CC=81o=20Kondratiuk?= Date: Fri, 28 Dec 2018 19:12:20 -0300 Subject: [PATCH 4/5] cr --- lib/PuppeteerSharp/ElementHandle.cs | 10 +++--- lib/PuppeteerSharp/ExecutionContext.cs | 10 +++--- .../Helpers/RemoteObjectHelper.cs | 16 ++++----- lib/PuppeteerSharp/JSHandle.cs | 34 +++++++++---------- .../Messaging/EvaluateHandleResponse.cs | 4 +-- .../Messaging/LogEntryAddedResponse.cs | 2 +- lib/PuppeteerSharp/Messaging/MessageKeys.cs | 4 +-- .../Messaging/PageConsoleResponse.cs | 2 +- lib/PuppeteerSharp/Messaging/RemoteObject.cs | 33 ++++++++++++++++++ .../RuntimeCallFunctionOnResponse.cs | 7 ++++ .../Messaging/RuntimeGetPropertiesResponse.cs | 16 +++++++++ .../Messaging/RuntimeQueryObjectsResponse.cs | 2 +- lib/PuppeteerSharp/Page.cs | 6 ++-- lib/PuppeteerSharp/Worker.cs | 4 +-- 14 files changed, 100 insertions(+), 50 deletions(-) create mode 100644 lib/PuppeteerSharp/Messaging/RemoteObject.cs create mode 100644 lib/PuppeteerSharp/Messaging/RuntimeCallFunctionOnResponse.cs create mode 100644 lib/PuppeteerSharp/Messaging/RuntimeGetPropertiesResponse.cs diff --git a/lib/PuppeteerSharp/ElementHandle.cs b/lib/PuppeteerSharp/ElementHandle.cs index bf15169a0..b0c7df2ef 100644 --- a/lib/PuppeteerSharp/ElementHandle.cs +++ b/lib/PuppeteerSharp/ElementHandle.cs @@ -24,7 +24,7 @@ public class ElementHandle : JSHandle internal ElementHandle( ExecutionContext context, CDPSession client, - JToken remoteObject, + RemoteObject remoteObject, Page page, FrameManager frameManager) : base(context, client, remoteObject) @@ -198,7 +198,7 @@ public async Task ClickAsync(ClickOptions options = null) public Task UploadFileAsync(params string[] filePaths) { var files = filePaths.Select(Path.GetFullPath).ToArray(); - var objectId = RemoteObject[MessageKeys.ObjectId].AsString(); + var objectId = RemoteObject.ObjectId; return Client.SendAsync("DOM.setFileInputFiles", new { objectId, files }); } @@ -386,7 +386,7 @@ public async Task ContentFrameAsync() { var nodeInfo = await Client.SendAsync("DOM.describeNode", new Dictionary { - { MessageKeys.ObjectId, RemoteObject[MessageKeys.ObjectId] } + { MessageKeys.ObjectId, RemoteObject.ObjectId } }).ConfigureAwait(false); return string.IsNullOrEmpty(nodeInfo.Node.FrameId) ? null : await _frameManager.GetFrameAsync(nodeInfo.Node.FrameId); @@ -419,7 +419,7 @@ public Task IsIntersectingViewportAsync() { result = await Client.SendAsync("DOM.getContentQuads", new Dictionary { - { MessageKeys.ObjectId, RemoteObject[MessageKeys.ObjectId] } + { MessageKeys.ObjectId, RemoteObject.ObjectId } }).ConfigureAwait(false); } catch (Exception ex) @@ -491,7 +491,7 @@ private async Task GetBoxModelAsync() { return await Client.SendAsync("DOM.getBoxModel", new { - objectId = RemoteObject[MessageKeys.ObjectId].AsString() + objectId = RemoteObject.ObjectId }).ConfigureAwait(false); } catch (PuppeteerException ex) diff --git a/lib/PuppeteerSharp/ExecutionContext.cs b/lib/PuppeteerSharp/ExecutionContext.cs index b8e77e26c..d3d19b685 100755 --- a/lib/PuppeteerSharp/ExecutionContext.cs +++ b/lib/PuppeteerSharp/ExecutionContext.cs @@ -112,14 +112,14 @@ public async Task QueryObjectsAsync(JSHandle prototypeHandle) throw new PuppeteerException("Prototype JSHandle is disposed!"); } - if (!((JObject)prototypeHandle.RemoteObject).TryGetValue(MessageKeys.ObjectId, out var objectId)) + if (prototypeHandle.RemoteObject.ObjectId == null) { throw new PuppeteerException("Prototype JSHandle must not be referencing primitive value"); } var response = await _client.SendAsync("Runtime.queryObjects", new Dictionary { - {"prototypeObjectId", objectId.ToString()} + {"prototypeObjectId", prototypeHandle.RemoteObject.ObjectId} }).ConfigureAwait(false); return CreateJSHandle(response.Objects); @@ -174,8 +174,8 @@ internal async Task EvaluateFunctionHandleAsync(string script, params } } - internal JSHandle CreateJSHandle(JToken remoteObject) - => (remoteObject.SelectToken(MessageKeys.Subtype).AsString() == "node" && Frame != null) + internal JSHandle CreateJSHandle(RemoteObject remoteObject) + => remoteObject.Subtype == "node" && Frame != null ? new ElementHandle(this, _client, remoteObject, Frame.FrameManager.Page, Frame.FrameManager) : new JSHandle(this, _client, remoteObject); @@ -209,7 +209,7 @@ private async Task EvaluateHandleAsync(string method, object args) if (response.ExceptionDetails != null) { throw new EvaluationFailedException("Evaluation failed: " + - GetExceptionMessage(response.ExceptionDetails.ToObject(true))); + GetExceptionMessage(response.ExceptionDetails)); } return CreateJSHandle(response.Result); diff --git a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs index c3578603a..2a14f6227 100755 --- a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs +++ b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs @@ -8,9 +8,9 @@ namespace PuppeteerSharp.Helpers { internal class RemoteObjectHelper { - internal static object ValueFromRemoteObject(JToken remoteObject) + internal static object ValueFromRemoteObject(RemoteObject remoteObject) { - var unserializableValue = remoteObject[MessageKeys.UnserializableValue]?.AsString(); + var unserializableValue = remoteObject.UnserializableValue; if (unserializableValue != null) { @@ -29,7 +29,7 @@ internal static object ValueFromRemoteObject(JToken remoteObject) } } - var value = remoteObject[MessageKeys.Value]; + var value = remoteObject.Value; if (value == null) { @@ -37,7 +37,7 @@ internal static object ValueFromRemoteObject(JToken remoteObject) } // https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-RemoteObject - var objectType = remoteObject[MessageKeys.Type].AsString(); + var objectType = remoteObject.Type; switch (objectType) { @@ -56,18 +56,16 @@ internal static object ValueFromRemoteObject(JToken remoteObject) } } - internal static async Task ReleaseObjectAsync(CDPSession client, JToken remoteObject, ILogger logger) + internal static async Task ReleaseObjectAsync(CDPSession client, RemoteObject remoteObject, ILogger logger) { - var objectId = remoteObject[MessageKeys.ObjectId]?.AsString(); - - if (objectId == null) + if (remoteObject.ObjectId == null) { return; } try { - await client.SendAsync("Runtime.releaseObject", new { objectId }).ConfigureAwait(false); + await client.SendAsync("Runtime.releaseObject", new { remoteObject.ObjectId }).ConfigureAwait(false); } catch (Exception ex) { diff --git a/lib/PuppeteerSharp/JSHandle.cs b/lib/PuppeteerSharp/JSHandle.cs index 0794fcf5b..71518ce09 100644 --- a/lib/PuppeteerSharp/JSHandle.cs +++ b/lib/PuppeteerSharp/JSHandle.cs @@ -12,7 +12,7 @@ namespace PuppeteerSharp /// public class JSHandle { - internal JSHandle(ExecutionContext context, CDPSession client, JToken remoteObject) + internal JSHandle(ExecutionContext context, CDPSession client, RemoteObject remoteObject) { ExecutionContext = context; Client = client; @@ -34,7 +34,7 @@ internal JSHandle(ExecutionContext context, CDPSession client, JToken remoteObje /// Gets or sets the remote object. /// /// The remote object. - public JToken RemoteObject { get; } + public RemoteObject RemoteObject { get; } /// /// Gets the client. /// @@ -79,22 +79,22 @@ public async Task GetPropertyAsync(string propertyName) /// public async Task> GetPropertiesAsync() { - var response = await Client.SendAsync("Runtime.getProperties", new + var response = await Client.SendAsync("Runtime.getProperties", new { - objectId = RemoteObject[MessageKeys.ObjectId].AsString(), + objectId = RemoteObject.ObjectId, ownProperties = true }).ConfigureAwait(false); var result = new Dictionary(); - foreach (var property in response[MessageKeys.Result]) + foreach (var property in response.Result) { - if (property[MessageKeys.Enumerable] == null) + if (property.Enumerable == null) { continue; } - result.Add(property[MessageKeys.Name].AsString(), ExecutionContext.CreateJSHandle(property[MessageKeys.Value])); + result.Add(property.Name, ExecutionContext.CreateJSHandle(property.Value)); } return result; } @@ -118,18 +118,18 @@ public async Task> GetPropertiesAsync() /// public async Task JsonValueAsync() { - var objectId = RemoteObject[MessageKeys.ObjectId]; + var objectId = RemoteObject.ObjectId; if (objectId != null) { - var response = await Client.SendAsync("Runtime.callFunctionOn", new Dictionary + var response = await Client.SendAsync("Runtime.callFunctionOn", new Dictionary { ["functionDeclaration"] = "function() { return this; }", [MessageKeys.ObjectId] = objectId, ["returnByValue"] = true, ["awaitPromise"] = true }).ConfigureAwait(false); - return (T)RemoteObjectHelper.ValueFromRemoteObject(response[MessageKeys.Result]); + return (T)RemoteObjectHelper.ValueFromRemoteObject(response.Result); } return (T)RemoteObjectHelper.ValueFromRemoteObject(RemoteObject); @@ -153,9 +153,9 @@ public async Task DisposeAsync() /// public override string ToString() { - if ((RemoteObject)[MessageKeys.ObjectId] != null) + if (RemoteObject.ObjectId != null) { - var type = RemoteObject[MessageKeys.Subtype] ?? RemoteObject[MessageKeys.Type]; + var type = RemoteObject.Subtype ?? RemoteObject.Type; return "JSHandle@" + type; } @@ -174,21 +174,19 @@ internal object FormatArgument(ExecutionContext context) throw new PuppeteerException("JSHandle is disposed!"); } - var unserializableValue = RemoteObject[MessageKeys.UnserializableValue]; + var unserializableValue = RemoteObject.UnserializableValue; if (unserializableValue != null) { return unserializableValue; } - if (RemoteObject[MessageKeys.ObjectId] == null) + if (RemoteObject.ObjectId == null) { - var value = RemoteObject[MessageKeys.Value]; - - return new { value }; + return new { RemoteObject.Value }; } - var objectId = RemoteObject[MessageKeys.ObjectId]; + var objectId = RemoteObject.ObjectId; return new { objectId }; } diff --git a/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs b/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs index 0387d4979..079480cc3 100644 --- a/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs +++ b/lib/PuppeteerSharp/Messaging/EvaluateHandleResponse.cs @@ -4,7 +4,7 @@ namespace PuppeteerSharp.Messaging { internal class EvaluateHandleResponse { - public JToken ExceptionDetails { get; set; } - public JToken Result { get; set; } + public EvaluateExceptionResponseDetails ExceptionDetails { get; set; } + public RemoteObject Result { get; set; } } } diff --git a/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs b/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs index c94ce0f24..543b3c1ec 100644 --- a/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs +++ b/lib/PuppeteerSharp/Messaging/LogEntryAddedResponse.cs @@ -9,7 +9,7 @@ internal class LogEntryAddedResponse internal class LogEntry { public TargetType Source { get; set; } - public JToken[] Args { get; set; } + public RemoteObject[] Args { get; set; } public ConsoleType Level { get; set; } public string Text { get; set; } } diff --git a/lib/PuppeteerSharp/Messaging/MessageKeys.cs b/lib/PuppeteerSharp/Messaging/MessageKeys.cs index c64c0a690..709ec70dd 100644 --- a/lib/PuppeteerSharp/Messaging/MessageKeys.cs +++ b/lib/PuppeteerSharp/Messaging/MessageKeys.cs @@ -26,10 +26,7 @@ internal class MessageKeys public const string Text = "text"; public const string TargetId = "targetId"; public const string ScriptSource = "scriptSource"; - public const string ObjectId = "objectId"; - public const string Subtype = "subtype"; public const string Type = "type"; - public const string UnserializableValue = "unserializableValue"; public const string Product = "product"; public const string UserAgent = "userAgent"; public const string Frame = "frame"; @@ -73,5 +70,6 @@ internal class MessageKeys public const string ErrorReason = "errorReason"; public const string X = "x"; public const string Y = "y"; + public const string ObjectId = "objectId"; } } diff --git a/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs b/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs index 5278b4b51..34bdef3c9 100644 --- a/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs +++ b/lib/PuppeteerSharp/Messaging/PageConsoleResponse.cs @@ -5,7 +5,7 @@ namespace PuppeteerSharp.Messaging internal class PageConsoleResponse { public ConsoleType Type { get; set; } - public JToken[] Args { get; set; } + public RemoteObject[] Args { get; set; } public int ExecutionContextId { get; set; } } } diff --git a/lib/PuppeteerSharp/Messaging/RemoteObject.cs b/lib/PuppeteerSharp/Messaging/RemoteObject.cs new file mode 100644 index 000000000..025f19a68 --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RemoteObject.cs @@ -0,0 +1,33 @@ +using Newtonsoft.Json.Linq; + +namespace PuppeteerSharp.Messaging +{ + /// + /// Remote object. + /// + public class RemoteObject + { + /// + /// Gets or sets the type. + /// + public object Type { get; set; } + + /// + /// Gets or sets the subtype. + /// + public string Subtype { get; set; } + /// + /// Gets or sets the object identifier. + /// + public string ObjectId { get; set; } + /// + /// Gets or sets the unserializable value. + /// + public string UnserializableValue { get; set; } + /// + /// Gets or sets the value. + /// + public JToken Value { get; set; } + + } +} diff --git a/lib/PuppeteerSharp/Messaging/RuntimeCallFunctionOnResponse.cs b/lib/PuppeteerSharp/Messaging/RuntimeCallFunctionOnResponse.cs new file mode 100644 index 000000000..1b790323c --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RuntimeCallFunctionOnResponse.cs @@ -0,0 +1,7 @@ +namespace PuppeteerSharp.Messaging +{ + internal class RuntimeCallFunctionOnResponse + { + public RemoteObject Result { get; set; } + } +} diff --git a/lib/PuppeteerSharp/Messaging/RuntimeGetPropertiesResponse.cs b/lib/PuppeteerSharp/Messaging/RuntimeGetPropertiesResponse.cs new file mode 100644 index 000000000..803cb35ae --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RuntimeGetPropertiesResponse.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace PuppeteerSharp.Messaging +{ + internal class RuntimeGetPropertiesResponse + { + public IEnumerable Result { get; set; } + + public class RuntimeGetPropertiesResponseItem + { + public object Enumerable { get; set; } + public string Name { get; set; } + public RemoteObject Value { get; set; } + } + } +} diff --git a/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs b/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs index 5bc350e99..207d1d992 100644 --- a/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs +++ b/lib/PuppeteerSharp/Messaging/RuntimeQueryObjectsResponse.cs @@ -4,6 +4,6 @@ namespace PuppeteerSharp.Messaging { internal class RuntimeQueryObjectsResponse { - public JToken Objects { get; set; } + public RemoteObject Objects { get; set; } } } diff --git a/lib/PuppeteerSharp/Page.cs b/lib/PuppeteerSharp/Page.cs index 16f7d2ff6..27de7d137 100644 --- a/lib/PuppeteerSharp/Page.cs +++ b/lib/PuppeteerSharp/Page.cs @@ -1911,7 +1911,7 @@ private async Task OnLogEntryAddedAsync(LogEntryAddedResponse e) { foreach (var arg in e.Entry?.Args) { - await RemoteObjectHelper.ReleaseObjectAsync(Client, arg, _logger); + await RemoteObjectHelper.ReleaseObjectAsync(Client, arg, _logger).ConfigureAwait(false); } } if (e.Entry.Source != TargetType.Worker) @@ -1983,7 +1983,7 @@ private void OnDialog(PageJavascriptDialogOpeningResponse message) private Task OnConsoleAPI(PageConsoleResponse message) { var ctx = _frameManager.ExecutionContextById(message.ExecutionContextId); - var values = message.Args.Select(i => ctx.CreateJSHandle(i)).ToArray(); + var values = message.Args.Select(i => ctx.CreateJSHandle(i)).ToArray(); return AddConsoleMessage(message.Type, values); } @@ -1999,7 +1999,7 @@ private async Task AddConsoleMessage(ConsoleType type, JSHandle[] values) return; } - var tokens = values.Select(i => i.RemoteObject[MessageKeys.ObjectId] != null + var tokens = values.Select(i => i.RemoteObject.ObjectId != null ? i.ToString() : RemoteObjectHelper.ValueFromRemoteObject(i.RemoteObject)); diff --git a/lib/PuppeteerSharp/Worker.cs b/lib/PuppeteerSharp/Worker.cs index b79eff08e..295cc345f 100644 --- a/lib/PuppeteerSharp/Worker.cs +++ b/lib/PuppeteerSharp/Worker.cs @@ -32,7 +32,7 @@ public class Worker private readonly Func _consoleAPICalled; private readonly Action _exceptionThrown; private readonly TaskCompletionSource _executionContextCallback; - private Func _jsHandleFactory; + private Func _jsHandleFactory; internal Worker( CDPSession client, @@ -130,7 +130,7 @@ private async Task OnConsoleAPICalled(MessageEventArgs e) var consoleData = e.MessageData.ToObject(true); await _consoleAPICalled( consoleData.Type, - consoleData.Args.Select(i => _jsHandleFactory(_executionContext, i)).ToArray()) + consoleData.Args.Select(i => _jsHandleFactory(_executionContext, i)).ToArray()) .ConfigureAwait(false); } From 4a5d97df9e223a54701efa05bfc018af897acd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dari=CC=81o=20Kondratiuk?= Date: Fri, 28 Dec 2018 19:44:12 -0300 Subject: [PATCH 5/5] RemoteObject --- lib/PuppeteerSharp/ExecutionContext.cs | 2 +- .../Helpers/FlexibleStringEnumConverter.cs | 7 +- .../Helpers/RemoteObjectHelper.cs | 10 +-- lib/PuppeteerSharp/JSHandle.cs | 6 +- lib/PuppeteerSharp/Messaging/RemoteObject.cs | 6 +- .../Messaging/RemoteObjectSubtype.cs | 85 +++++++++++++++++++ .../Messaging/RemoteObjectType.cs | 49 +++++++++++ 7 files changed, 148 insertions(+), 17 deletions(-) create mode 100644 lib/PuppeteerSharp/Messaging/RemoteObjectSubtype.cs create mode 100644 lib/PuppeteerSharp/Messaging/RemoteObjectType.cs diff --git a/lib/PuppeteerSharp/ExecutionContext.cs b/lib/PuppeteerSharp/ExecutionContext.cs index d3d19b685..c3bc4e2df 100755 --- a/lib/PuppeteerSharp/ExecutionContext.cs +++ b/lib/PuppeteerSharp/ExecutionContext.cs @@ -175,7 +175,7 @@ internal async Task EvaluateFunctionHandleAsync(string script, params } internal JSHandle CreateJSHandle(RemoteObject remoteObject) - => remoteObject.Subtype == "node" && Frame != null + => remoteObject.Subtype == RemoteObjectSubtype.Node && Frame != null ? new ElementHandle(this, _client, remoteObject, Frame.FrameManager.Page, Frame.FrameManager) : new JSHandle(this, _client, remoteObject); diff --git a/lib/PuppeteerSharp/Helpers/FlexibleStringEnumConverter.cs b/lib/PuppeteerSharp/Helpers/FlexibleStringEnumConverter.cs index 1422282b7..6f50e2797 100644 --- a/lib/PuppeteerSharp/Helpers/FlexibleStringEnumConverter.cs +++ b/lib/PuppeteerSharp/Helpers/FlexibleStringEnumConverter.cs @@ -6,12 +6,9 @@ namespace PuppeteerSharp.Helpers { internal class FlexibleStringEnumConverter : StringEnumConverter { - private Enum _fallbackValue; + private readonly Enum _fallbackValue; - public FlexibleStringEnumConverter(Enum fallbackValue) - { - _fallbackValue = fallbackValue; - } + public FlexibleStringEnumConverter(Enum fallbackValue) => _fallbackValue = fallbackValue; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { diff --git a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs index 2a14f6227..c02bb1b9b 100755 --- a/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs +++ b/lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs @@ -41,15 +41,15 @@ internal static object ValueFromRemoteObject(RemoteObject remoteObject) switch (objectType) { - case "object": + case RemoteObjectType.Object: return value.ToObject(true); - case "undefined": + case RemoteObjectType.Undefined: return null; - case "number": + case RemoteObjectType.Number: return value.Value(); - case "boolean": + case RemoteObjectType.Boolean: return value.Value(); - case "bigint": + case RemoteObjectType.Bigint: return value.Value(); default: // string, symbol, function return value.ToObject(); diff --git a/lib/PuppeteerSharp/JSHandle.cs b/lib/PuppeteerSharp/JSHandle.cs index 71518ce09..da0819f70 100644 --- a/lib/PuppeteerSharp/JSHandle.cs +++ b/lib/PuppeteerSharp/JSHandle.cs @@ -155,8 +155,10 @@ public override string ToString() { if (RemoteObject.ObjectId != null) { - var type = RemoteObject.Subtype ?? RemoteObject.Type; - return "JSHandle@" + type; + var type = RemoteObject.Subtype != RemoteObjectSubtype.Other + ? RemoteObject.Subtype.ToString() + : RemoteObject.Type.ToString(); + return "JSHandle@" + type.ToLower(); } return "JSHandle:" + RemoteObjectHelper.ValueFromRemoteObject(RemoteObject)?.ToString(); diff --git a/lib/PuppeteerSharp/Messaging/RemoteObject.cs b/lib/PuppeteerSharp/Messaging/RemoteObject.cs index 025f19a68..e4dd81e8a 100644 --- a/lib/PuppeteerSharp/Messaging/RemoteObject.cs +++ b/lib/PuppeteerSharp/Messaging/RemoteObject.cs @@ -10,12 +10,11 @@ public class RemoteObject /// /// Gets or sets the type. /// - public object Type { get; set; } - + public RemoteObjectType Type { get; set; } /// /// Gets or sets the subtype. /// - public string Subtype { get; set; } + public RemoteObjectSubtype Subtype { get; set; } /// /// Gets or sets the object identifier. /// @@ -28,6 +27,5 @@ public class RemoteObject /// Gets or sets the value. /// public JToken Value { get; set; } - } } diff --git a/lib/PuppeteerSharp/Messaging/RemoteObjectSubtype.cs b/lib/PuppeteerSharp/Messaging/RemoteObjectSubtype.cs new file mode 100644 index 000000000..54f6292a1 --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RemoteObjectSubtype.cs @@ -0,0 +1,85 @@ +using Newtonsoft.Json; +using PuppeteerSharp.Helpers; + +namespace PuppeteerSharp.Messaging +{ + /// + /// Remote object subtype. + /// + [JsonConverter(typeof(FlexibleStringEnumConverter), Other)] + public enum RemoteObjectSubtype + { + /// + /// Other. + /// + Other, + /// + /// Array. + /// + Array, + /// + /// Null. + /// + Null, + /// + /// Node. + /// + Node, + /// + /// Regexp. + /// + Regexp, + /// + /// Date. + /// + Date, + /// + /// Map. + /// + Map, + /// + /// Set. + /// + Set, + /// + /// Weakmap. + /// + Weakmap, + /// + /// Weakset. + /// + Weakset, + /// + /// Iterator. + /// + Iterator, + /// + /// Generator. + /// + Generator, + /// + /// Error. + /// + Error, + /// + /// Proxy. + /// + Proxy, + /// + /// Promise. + /// + Promise, + /// + /// Typedarray. + /// + Typedarray, + /// + /// Arraybuffer. + /// + Arraybuffer, + /// + /// Dataview. + /// + Dataview + } +} \ No newline at end of file diff --git a/lib/PuppeteerSharp/Messaging/RemoteObjectType.cs b/lib/PuppeteerSharp/Messaging/RemoteObjectType.cs new file mode 100644 index 000000000..826c20a29 --- /dev/null +++ b/lib/PuppeteerSharp/Messaging/RemoteObjectType.cs @@ -0,0 +1,49 @@ +using Newtonsoft.Json; +using PuppeteerSharp.Helpers; + +namespace PuppeteerSharp.Messaging +{ + /// + /// Remote object type. + /// + [JsonConverter(typeof(FlexibleStringEnumConverter), Other)] + public enum RemoteObjectType + { + /// + /// Other. + /// + Other, + /// + /// Object. + /// + Object, + /// + /// Function. + /// + Function, + /// + /// Undefined. + /// + Undefined, + /// + /// String. + /// + String, + /// + /// Number. + /// + Number, + /// + /// Boolean. + /// + Boolean, + /// + /// Symbol. + /// + Symbol, + /// + /// Bigint. + /// + Bigint + } +} \ No newline at end of file