Skip to content

Commit fc902ee

Browse files
committed
Fix CDP refactor
1 parent deaae6b commit fc902ee

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

lib/PuppeteerSharp/Cdp/CdpElementHandle.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace PuppeteerSharp.Cdp;
3333

3434
/// <inheritdoc />
3535
[DebuggerDisplay("{DebuggerDisplay,nq}")]
36-
public class CdpElementHandle : ElementHandle
36+
public class CdpElementHandle : ElementHandle, ICdpHandle
3737
{
3838
private readonly CdpFrame _cdpFrame;
3939

@@ -52,6 +52,7 @@ internal CdpElementHandle(
5252
/// </summary>
5353
public RemoteObject RemoteObject => ((CdpJSHandle)Handle).RemoteObject;
5454

55+
/// <inheritdoc/>
5556
internal override Realm Realm => Handle.Realm;
5657

5758
/// <summary>

lib/PuppeteerSharp/Cdp/CdpJSHandle.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
namespace PuppeteerSharp.Cdp;
3030

3131
/// <inheritdoc/>
32-
public class CdpJSHandle : JSHandle
32+
public class CdpJSHandle : JSHandle, ICdpHandle
3333
{
3434
internal CdpJSHandle(IsolatedWorld world, RemoteObject remoteObject)
3535
{
@@ -45,6 +45,7 @@ internal CdpJSHandle(IsolatedWorld world, RemoteObject remoteObject)
4545

4646
internal string Id => RemoteObject.ObjectId;
4747

48+
/// <inheritdoc/>
4849
internal override Realm Realm { get; }
4950

5051
/// <summary>

lib/PuppeteerSharp/Cdp/ICdpHandle.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// * MIT License
2+
// *
3+
// * Copyright (c) Darío Kondratiuk
4+
// *
5+
// * Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// * of this software and associated documentation files (the "Software"), to deal
7+
// * in the Software without restriction, including without limitation the rights
8+
// * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// * copies of the Software, and to permit persons to whom the Software is
10+
// * furnished to do so, subject to the following conditions:
11+
// *
12+
// * The above copyright notice and this permission notice shall be included in all
13+
// * copies or substantial portions of the Software.
14+
// *
15+
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// * SOFTWARE.
22+
23+
using PuppeteerSharp.Cdp.Messaging;
24+
25+
namespace PuppeteerSharp.Cdp;
26+
27+
/// <summary>
28+
/// CDP Specific handle info.
29+
/// </summary>
30+
internal interface ICdpHandle : IJSHandle
31+
{
32+
/// <summary>
33+
/// CDP remote object.
34+
/// </summary>
35+
RemoteObject RemoteObject { get; }
36+
}

lib/PuppeteerSharp/IsolatedWorld.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ internal override async Task<IElementHandle> AdoptBackendNodeAsync(object backen
131131

132132
internal override async Task<IJSHandle> TransferHandleAsync(IJSHandle handle)
133133
{
134-
var cdpHandle = (CdpJSHandle)handle;
135-
if (cdpHandle.Realm == this)
134+
var cdpHandle = (ICdpHandle)handle;
135+
if (((JSHandle)cdpHandle).Realm == this)
136136
{
137137
return handle;
138138
}

0 commit comments

Comments
 (0)