Skip to content
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
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp.Tests/NavigationTests/PageGotoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ await Task.WhenAll(
Server.WaitForRequest("/digits/1.png", r => referer2 = r.Headers["Referer"]),
Page.GoToAsync(TestConstants.ServerUrl + "/grid.html", new NavigationOptions
{
ReferrerPolicy = "no-referer"
ReferrerPolicy = "no-referrer"
})
);

Expand Down
11 changes: 10 additions & 1 deletion lib/PuppeteerSharp/Cdp/CdpFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using PuppeteerSharp.Cdp.Messaging;
Expand Down Expand Up @@ -114,7 +115,7 @@ async Task NavigateAsync()
{
Url = url,
Referrer = referrer ?? string.Empty,
ReferrerPolicy = referrerPolicy ?? string.Empty,
ReferrerPolicy = ReferrerPolicyToProtocol(referrerPolicy),
FrameId = Id,
}).ConfigureAwait(false);

Expand Down Expand Up @@ -335,4 +336,12 @@ internal void UpdateClient(CDPSession client, bool keepWorlds = false)
/// <inheritdoc />
protected internal override DeviceRequestPromptManager GetDeviceRequestPromptManager()
=> FrameManager.GetDeviceRequestPromptManager(Client);

// See https://chromedevtools.github.io/devtools-protocol/tot/Page/#type-ReferrerPolicy.
private static string ReferrerPolicyToProtocol(string referrerPolicy)
{
// Transform kebab-case to camelCase
return string.IsNullOrEmpty(referrerPolicy) ? null :
Regex.Replace(referrerPolicy, "-(.)", match => match.Groups[1].Value.ToUpperInvariant());
}
}
Loading