-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test - Add CanLoadRequestWithPostData test
- Loading branch information
Showing
6 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright © 2021 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
using CefSharp.Internals; | ||
using System.Threading.Tasks; | ||
|
||
namespace CefSharp | ||
{ | ||
/// <summary> | ||
/// Extended WebBrowserExtensions | ||
/// </summary> | ||
public static class WebBrowserExtensionsEx | ||
{ | ||
/// <summary> | ||
/// Retrieve the current <see cref="NavigationEntry"/>. Contains information like | ||
/// <see cref="NavigationEntry.HttpStatusCode"/> and <see cref="NavigationEntry.SslStatus"/> | ||
/// </summary> | ||
/// <param name="browser">The ChromiumWebBrowser instance this method extends.</param> | ||
/// <returns> | ||
/// <see cref="Task{NavigationEntry}"/> that when executed returns the current <see cref="NavigationEntry"/> or null | ||
/// </returns> | ||
public static Task<NavigationEntry> GetVisibleNavigationEntryAsync(this IWebBrowser browser) | ||
{ | ||
var host = browser.GetBrowserHost(); | ||
|
||
if (host == null) | ||
{ | ||
return Task.FromResult<NavigationEntry>(null); | ||
} | ||
|
||
if(Cef.CurrentlyOnThread(CefThreadIds.TID_UI)) | ||
{ | ||
var entry = host.GetVisibleNavigationEntry(); | ||
|
||
return Task.FromResult<NavigationEntry>(entry); | ||
} | ||
|
||
var tcs = new TaskCompletionSource<NavigationEntry>(); | ||
|
||
Cef.UIThreadTaskFactory.StartNew(delegate | ||
{ | ||
var entry = host.GetVisibleNavigationEntry(); | ||
|
||
tcs.TrySetResultAsync(entry); | ||
}); | ||
|
||
return tcs.Task; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright © 2021 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
using Xunit; | ||
|
||
namespace CefSharp.Test.Framework | ||
{ | ||
//NOTE: All Test classes must be part of this collection as it manages the Cef Initialize/Shutdown lifecycle | ||
[Collection(CefSharpFixtureCollection.Key)] | ||
public class RequestContextFacts | ||
{ | ||
[Fact] | ||
public void IsSameAs() | ||
{ | ||
var ctx1 = new RequestContext(); | ||
var ctx2 = ctx1.UnWrap(); | ||
|
||
Assert.True(ctx1.IsSame(ctx2)); | ||
} | ||
|
||
[Fact] | ||
public void IsSharingWith() | ||
{ | ||
var ctx1 = RequestContext.Configure() | ||
.WithCachePath(@"c:\temp") | ||
.Create(); | ||
var ctx2 = new RequestContext(ctx1); | ||
|
||
Assert.True(ctx1.IsSharingWith(ctx2)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters