mirror of
https://github.com/MontFerret/ferret.git
synced 2025-07-03 00:46:51 +02:00
Feature/#220 iframe support (#315)
* Refactored Virtual DOM structure * Added new E2E tests * Updated E2E Test Runner
This commit is contained in:
@ -8,8 +8,8 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
)
|
||||
|
||||
// CookieSet sets cookies to a given document
|
||||
// @param doc (HTMLDocument) - Target document.
|
||||
// CookieSet sets cookies to a given page
|
||||
// @param page (HTMLPage) - Target page.
|
||||
// @param cookie... (HTTPCookie) - Target cookies.
|
||||
func CookieSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
@ -18,14 +18,12 @@ func CookieSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return values.None, err
|
||||
}
|
||||
|
||||
err = core.ValidateType(args[0], drivers.HTMLDocumentType)
|
||||
page, err := drivers.ToPage(args[0])
|
||||
|
||||
if err != nil {
|
||||
return values.None, err
|
||||
}
|
||||
|
||||
doc := args[0].(drivers.HTMLDocument)
|
||||
|
||||
cookies := make([]drivers.HTTPCookie, 0, len(args)-1)
|
||||
|
||||
for _, c := range args[1:] {
|
||||
@ -38,5 +36,5 @@ func CookieSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
cookies = append(cookies, cookie)
|
||||
}
|
||||
|
||||
return values.None, doc.SetCookies(ctx, cookies...)
|
||||
return values.None, page.SetCookies(ctx, cookies...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user