Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update WebView[2]_WithHeaders tests to use httpbin.org #18529

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
VerticalAlignment="Stretch">
<StackPanel Orientation="Vertical">
<TextBlock Text="WebView2_NavigateWithHttpRequestMessage" />
<mux:WebView2 Source="http://www.hslkdjghsldkjhlskjdhlsfjbvxcmnbxcmvnbjkhfksjdhf.com/"
<mux:WebView2 Source="about:blank"
x:Name="MyWebView2"
Height="100"
Width="100" />
<TextBlock x:Name="MyTextBlock" TextWrapping="Wrap" />
<Button Content="Navigate to Requestb.in" x:Name="MyButton" />
<Button Content="Navigate to httpbin.org" x:Name="MyButton" />
</StackPanel>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ public WebView2_WithHeaders()
{
InitializeComponent();
MyButton.Click += MyButton_OnClick;
MyWebView2.NavigationCompleted += async (s, e) =>
{
if (MyWebView2.Source.Scheme == "about")
{
MyTextBlock.Text = "Click button to send request with custom headers...";
}
else
{
var html = await MyWebView2.CoreWebView2.ExecuteScriptAsync("document.body.outerText");
if (html.Contains("\\\"Hello\\\": \\\"TESTTEST, TEST2\\\"") && html.Contains("\\\"Hello2\\\": \\\"TEST111\\\""))
{
MyTextBlock.Text = "Success! Found both HELLO and HELLO2 headers with their respective values";
}
else
{
MyTextBlock.Text = "Failed! Did not find expected HELLO and HELLO2 or they values. See HTML output...";
}
}
};
}

private void MyButton_OnClick(object sender, RoutedEventArgs e)
{
var url = "http://requestb.in/rw35narw";
MyTextBlock.Text = $"Inspect data at {url}?inspect";
var url = "https://httpbin.org/headers";
var request = new HttpRequestMessage
{
RequestUri = new Uri(url),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
VerticalAlignment="Stretch">
<StackPanel Orientation="Vertical">
<TextBlock Text="WebView_NavigateWithHttpRequestMessage" />
<WebView Source="http://www.hslkdjghsldkjhlskjdhlsfjbvxcmnbxcmvnbjkhfksjdhf.com/"
<WebView Source="about:blank"
x:Name="MyWebView2"
Height="100"
Width="100" />
<TextBlock x:Name="MyTextBlock" TextWrapping="Wrap" />
<Button Content="Navigate to Requestb.in" x:Name="MyButton" />
<Button Content="Navigate to httpbin.org" x:Name="MyButton" />
</StackPanel>
</not_win:Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ public WebView_WithHeaders()
{
InitializeComponent();
MyButton.Click += MyButton_OnClick;
MyWebView2.NavigationCompleted += async (s, e) =>
{
if (MyWebView2.Source is null)
{
MyTextBlock.Text = "Click button to send request with custom headers...";
}
else
{
var html = await MyWebView2.CoreWebView2.ExecuteScriptAsync("document.body.outerText");
if (html.Contains("\\\"Hello\\\": \\\"TESTTEST, TEST2\\\"") && html.Contains("\\\"Hello2\\\": \\\"TEST111\\\""))
{
MyTextBlock.Text = "Success! Found both HELLO and HELLO2 headers with their respective values";
}
else
{
MyTextBlock.Text = "Failed! Did not find expected HELLO and HELLO2 or they values. See HTML output...";
}
}
};
}

private void MyButton_OnClick(object sender, RoutedEventArgs e)
{
var url = "http://requestb.in/rw35narw";
MyTextBlock.Text = $"Inspect data at {url}?inspect";
var url = "https://httpbin.org/headers";
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
request.Headers.Add("HELLO", "TESTTEST, TEST2");
request.Headers.Add("HELLO2", "TEST111");
Expand Down
Loading