1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-15 01:25:00 +02:00

Feature/#220 iframe support (#315)

* Refactored Virtual DOM structure
* Added new E2E tests
* Updated E2E Test Runner
This commit is contained in:
Tim Voronov
2019-06-19 17:58:56 -04:00
committed by GitHub
parent 8c07516ed1
commit d7b923e4c3
103 changed files with 2815 additions and 1629 deletions

View File

@ -2,14 +2,15 @@ package html
import (
"context"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// CookieSet gets a cookie from a given document by name.
// @param source (HTMLDocument) - Target HTMLDocument.
// CookieSet gets a cookie from a given page by name.
// @param page (HTMLPage) - Target page.
// @param cookie (...HTTPCookie|String) - Cookie or cookie name to delete.
func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, core.MaxArgs)
@ -18,13 +19,12 @@ func CookieDel(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)
inputs := args[1:]
var currentCookies *values.Array
cookies := make([]drivers.HTTPCookie, 0, len(inputs))
@ -33,7 +33,7 @@ func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) {
switch cookie := c.(type) {
case values.String:
if currentCookies == nil {
current, err := doc.GetCookies(ctx)
current, err := page.GetCookies(ctx)
if err != nil {
return values.None, err
@ -60,5 +60,5 @@ func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) {
}
}
return values.None, doc.DeleteCookies(ctx, cookies...)
return values.None, page.DeleteCookies(ctx, cookies...)
}