-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Improved DOM support for HtmlTable and strongly typed QuerySelectorAllAsync
- Loading branch information
Showing
17 changed files
with
782 additions
and
29 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
43 changes: 43 additions & 0 deletions
43
WebView2.DevTools.Dom.Tests/DevToolsContextTests/AddHtmlElementTests.cs
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,43 @@ | ||
using System.Threading.Tasks; | ||
using WebView2.DevTools.Dom.Tests.Attributes; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace WebView2.DevTools.Dom.Tests.DevToolsContextTests | ||
{ | ||
[Collection(TestConstants.TestFixtureCollectionName)] | ||
public class AddHtmlElementTests : DevTooolsContextBaseTest | ||
{ | ||
public AddHtmlElementTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldCreateDiv() | ||
{ | ||
const string expected = ""; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.EmptyPage); | ||
var div = await DevToolsContext.CreateHtmlElementAsync<HtmlDivElement>("div"); | ||
Assert.NotNull(div); | ||
|
||
var actual = await div.GetIdAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldCreateDivWithId() | ||
{ | ||
const string expected = "myDiv"; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.EmptyPage); | ||
var div = await DevToolsContext.CreateHtmlElementAsync<HtmlDivElement>("div", expected); | ||
Assert.NotNull(div); | ||
|
||
var actual = await div.GetIdAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
WebView2.DevTools.Dom.Tests/DevToolsContextTests/PageEventsPageErrorTests.cs
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,61 @@ | ||
using System.Text.Json; | ||
using System; | ||
using System.Threading.Tasks; | ||
using WebView2.DevTools.Dom; | ||
using Microsoft.Web.WebView2.Core; | ||
using WebView2.DevTools.Dom.Tests.Attributes; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace WebView2.DevTools.Dom.Tests.DevToolsContextTests | ||
{ | ||
[Collection(TestConstants.TestFixtureCollectionName)] | ||
public class PageEventsPageErrorTests : DevTooolsContextBaseTest | ||
{ | ||
public PageEventsPageErrorTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[WebView2ContextFact(Skip = "Possibly implement this")] | ||
public Task ShouldFire() | ||
{ | ||
throw new System.NotImplementedException(); | ||
//string error = null; | ||
//void EventHandler(object sender, PageErrorEventArgs e) | ||
//{ | ||
// error = e.Message; | ||
// Page.PageError -= EventHandler; | ||
//} | ||
|
||
//Page.PageError += EventHandler; | ||
|
||
//var completion = new TaskCompletionSource<JsonElement>(); | ||
|
||
//var reciever = WebView.CoreWebView2.GetDevToolsProtocolEventReceiver("Runtime.exceptionThrown"); | ||
|
||
//reciever.DevToolsProtocolEventReceived += handler; | ||
|
||
//void handler(object sender, CoreWebView2DevToolsProtocolEventReceivedEventArgs e) | ||
//{ | ||
// var d = JsonDocument.Parse(e.ParameterObjectAsJson); | ||
|
||
// if (d.RootElement.GetProperty("MessageId").GetString() != "Runtime.exceptionThrown") | ||
// { | ||
// return; | ||
// } | ||
// reciever.DevToolsProtocolEventReceived -= handler; | ||
// completion.SetResult(d.RootElement.GetProperty("MessageData").GetString()); | ||
//} | ||
|
||
//reciever.DevToolsProtocolEventReceived += handler; | ||
//return completion.Task; | ||
|
||
//await Task.WhenAll( | ||
// WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/error.html"), | ||
// WaitEvent(, ) | ||
//); | ||
|
||
//Assert.Contains("Fancy", error); | ||
} | ||
} | ||
} |
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
112 changes: 112 additions & 0 deletions
112
WebView2.DevTools.Dom.Tests/ElementHandleTests/HtmlTableCellElementTests.cs
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,112 @@ | ||
using System.Threading.Tasks; | ||
using WebView2.DevTools.Dom.Tests.Attributes; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
|
||
namespace WebView2.DevTools.Dom.Tests.ElementHandleTests | ||
{ | ||
|
||
[Collection(TestConstants.TestFixtureCollectionName)] | ||
public class HtmlTableCellElementTests : DevTooolsContextBaseTest | ||
{ | ||
public HtmlTableCellElementTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldWork() | ||
{ | ||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
Assert.NotNull(element); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldReturnNull() | ||
{ | ||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("#table2 td"); | ||
|
||
Assert.Null(element); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldGetIndex() | ||
{ | ||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
var index = await element.GetCellIndexAsync(); | ||
|
||
Assert.True(index > -1); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldSetThenGetAbbr() | ||
{ | ||
const string expected = "Testing"; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
await element.SetAbbrAsync(expected); | ||
var actual = await element.GetAbbrAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldGetScope() | ||
{ | ||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
var actual = await element.GetScopeAsync(); | ||
|
||
Assert.Equal(string.Empty, actual); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldSetThenGetScope() | ||
{ | ||
const string expected = "col"; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
await element.SetScopeAsync(expected); | ||
var actual = await element.GetScopeAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldSetThenGetRowSpan() | ||
{ | ||
const int expected = 3; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
await element.SetRowSpanAsync(expected); | ||
var actual = await element.GetRowSpanAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[WebView2ContextFact] | ||
public async Task ShouldSetThenGetColSpan() | ||
{ | ||
const int expected = 3; | ||
|
||
await WebView.CoreWebView2.NavigateToAsync(TestConstants.ServerUrl + "/table.html"); | ||
var element = await DevToolsContext.QuerySelectorAsync<HtmlTableCellElement>("td"); | ||
|
||
await element.SetColSpanAsync(expected); | ||
var actual = await element.GetColSpanAsync(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
} | ||
} |
Oops, something went wrong.