mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
fe7b45df6e
* Refactored networking * Some work * Added event loop * Renamed EventHandler to Handler * wip * Removed console logs * Added DOMManager * Refactored frame managment * Fixes * Fixed concurrency issues * Fixed unit tests * Improved EventLoop api * Some fixes * Refactored event loop. * Improved logic of initial page load * Cleaned up * Fixed linting issues * Fixed dom.Manager.Close * SOme works * Fixes * Removed fmt.Println statements * Refactored WaitForNavigation * Removed filter for e2e tests * Made Cookies Measurable * Made Cookies KeyedCollection * Fixes after code review * Updated e2e tests for iframes * Fixed iframe lookup in e2e tests * Added comments
48 lines
883 B
Go
48 lines
883 B
Go
package drivers
|
|
|
|
import "github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
var (
|
|
HTTPResponseType = core.NewType("HTTPResponse")
|
|
HTTPHeaderType = core.NewType("HTTPHeaders")
|
|
HTTPCookieType = core.NewType("HTTPCookie")
|
|
HTTPCookiesType = core.NewType("HTTPCookies")
|
|
HTMLElementType = core.NewType("HTMLElement")
|
|
HTMLDocumentType = core.NewType("HTMLDocument")
|
|
HTMLPageType = core.NewType("HTMLPageType")
|
|
)
|
|
|
|
// Comparison table of builtin types
|
|
var typeComparisonTable = map[core.Type]uint64{
|
|
HTTPHeaderType: 0,
|
|
HTTPCookieType: 1,
|
|
HTTPCookiesType: 2,
|
|
HTMLElementType: 3,
|
|
HTMLDocumentType: 4,
|
|
HTMLPageType: 5,
|
|
}
|
|
|
|
func Compare(first, second core.Type) int64 {
|
|
f, ok := typeComparisonTable[first]
|
|
|
|
if !ok {
|
|
return -1
|
|
}
|
|
|
|
s, ok := typeComparisonTable[second]
|
|
|
|
if !ok {
|
|
return -1
|
|
}
|
|
|
|
if f == s {
|
|
return 0
|
|
}
|
|
|
|
if f > s {
|
|
return 1
|
|
}
|
|
|
|
return -1
|
|
}
|