fix(chromium): missing webp validation

This commit is contained in:
Julien Neuhart
2024-01-08 11:44:56 +01:00
parent afd3763d96
commit 0e8385a5a7
2 changed files with 36 additions and 2 deletions

View File

@@ -209,7 +209,24 @@ func TestFormDataChromiumScreenshotOptions(t *testing.T) {
}(),
},
{
scenario: "valid format form field",
scenario: "valid png format form field",
ctx: func() *api.ContextMock {
ctx := &api.ContextMock{Context: new(api.Context)}
ctx.SetValues(map[string][]string{
"format": {
"png",
},
})
return ctx
}(),
expectedOptions: func() ScreenshotOptions {
options := DefaultScreenshotOptions()
options.Format = "png"
return options
}(),
},
{
scenario: "valid jpeg format form field",
ctx: func() *api.ContextMock {
ctx := &api.ContextMock{Context: new(api.Context)}
ctx.SetValues(map[string][]string{
@@ -225,6 +242,23 @@ func TestFormDataChromiumScreenshotOptions(t *testing.T) {
return options
}(),
},
{
scenario: "valid webp format form field",
ctx: func() *api.ContextMock {
ctx := &api.ContextMock{Context: new(api.Context)}
ctx.SetValues(map[string][]string{
"format": {
"webp",
},
})
return ctx
}(),
expectedOptions: func() ScreenshotOptions {
options := DefaultScreenshotOptions()
options.Format = "webp"
return options
}(),
},
{
scenario: "invalid quality form field (not an integer)",
ctx: func() *api.ContextMock {