Skip to content

Commit

Permalink
Undo changes. Error will come
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok committed Nov 16, 2023
1 parent 9ed06fe commit fb66e6b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
48 changes: 24 additions & 24 deletions lib/PuppeteerSharp/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,30 +396,6 @@ public async Task TypeAsync(string selector, string text, TypeOptions options =

internal void ClearContext() => _documentTask = null;

internal Task<ElementHandle> GetDocumentAsync()
{
if (_documentTask != null)
{
return _documentTask;
}

async Task<ElementHandle> EvaluateDocumentInContext()
{
var document = await EvaluateFunctionHandleAsync("() => document").ConfigureAwait(false);

if (document is not ElementHandle element)
{
throw new PuppeteerException("Document is null");
}

return element;
}

_documentTask = EvaluateDocumentInContext();

return _documentTask;
}

internal void OnLoadingStarted() => HasStartedLoading = true;

internal void OnLoadingStopped()
Expand Down Expand Up @@ -467,5 +443,29 @@ internal void UpdateClient(CDPSession client)
null,
FrameManager.TimeoutSettings);
}

private Task<ElementHandle> GetDocumentAsync()
{
if (_documentTask != null)
{
return _documentTask;
}

async Task<ElementHandle> EvaluateDocumentInContext()
{
var document = await IsolatedRealm.EvaluateFunctionHandleAsync("() => document").ConfigureAwait(false);

if (document is not ElementHandle)
{
throw new PuppeteerException("Document is null");
}

return await MainRealm.TransferHandleAsync(document).ConfigureAwait(false) as ElementHandle;
}

_documentTask = EvaluateDocumentInContext();

return _documentTask;
}
}
}
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/IsolatedWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal override async Task<IElementHandle> AdoptBackendNodeAsync(object backen

internal override async Task<IJSHandle> TransferHandleAsync(IJSHandle handle)
{
if ((handle as JSHandle)?.Realm.Client == Client)
if ((handle as JSHandle)?.Realm == this)
{
return handle;
}
Expand Down

0 comments on commit fb66e6b

Please sign in to comment.