Repository navigation
Add FedCM Initiator Type - #3424
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for the Chrome DevTools Protocol Network.Initiator.type value FedCM to avoid JSON deserialization failures when that initiator type appears.
Changes:
- Added
FedCmtoInitiatorTypewith anEnumMembermapping to the protocol string"FedCM".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <summary> | ||
| /// FedCM. | ||
| /// </summary> | ||
| [EnumMember(Value = "FedCM")] | ||
| FedCm, |
There was a problem hiding this comment.
Consider adding a small unit test that deserializes a Network.Initiator payload with type: "FedCM" and asserts it maps to InitiatorType.FedCm. The existing tests around initiators exercise Other/Parser/Script (e.g., lib/PuppeteerSharp.Tests/NetworkTests/RequestInitiatorTests.cs), but none cover this new protocol value that previously caused failures.
| /// <summary> | ||
| /// Other. | ||
| /// </summary> | ||
| Other, | ||
|
|
||
| /// <summary> | ||
| /// FedCM. | ||
| /// </summary> | ||
| [EnumMember(Value = "FedCM")] | ||
| FedCm, |
There was a problem hiding this comment.
This enum still throws for any future CDP initiator types that aren’t yet modeled (via EnumHelper.FromValueString). If the intent is to be resilient to protocol additions, consider adding [DefaultEnumValue((int)Other)] on the enum (similar to TargetType and DOMWorldType) so unknown values fall back to Other instead of throwing.
* feat: add FedCm to InitiatorType and add DefaultEnumValue fallback Add FedCm enum member with [EnumMember(Value = "FedCM")] to prevent JSON deserialization failures when Chrome sends this initiator type. Also add [DefaultEnumValue((int)Other)] so any future unknown CDP initiator types gracefully fall back to Other instead of throwing. Closes #3424 * Remove FedCm from InitiatorType enum Removed FedCm enum value from InitiatorType.
|
Hey @kblok just out of curiosity, why remove the explicit FedCM? I understand adding the fallback for the future, but seems worthwhile to differentiate when known? |
Hmmm I didn't remove it, did I? |
Nope, my bad! I was misreading on mobile and saw the remove commit without the add back in... checked main and it's there! Thanks again 💯 |
I started getting json serialization exceptions
Unknown value 'FedCM' for enum InitiatorTypeLooking at chrome dev tools protocol it is indeed there.
So, I added it to the enum.
I wasn't sure if we wanted
Otherto be last always or to maintain its numeric order... so I was conservative and putFedCmat the end.