(parent *channelOwner, objectType string, guid string, initializer map[string]any)
| 902 | } |
| 903 | |
| 904 | func newPage(parent *channelOwner, objectType string, guid string, initializer map[string]any) *pageImpl { |
| 905 | viewportSize := &Size{} |
| 906 | if _, ok := initializer["viewportSize"].(map[string]any); ok { |
| 907 | viewportSize.Height = int(initializer["viewportSize"].(map[string]any)["height"].(float64)) |
| 908 | viewportSize.Width = int(initializer["viewportSize"].(map[string]any)["width"].(float64)) |
| 909 | } |
| 910 | bt := &pageImpl{ |
| 911 | workers: make([]Worker, 0), |
| 912 | routes: make([]*routeHandlerEntry, 0), |
| 913 | bindings: safe.NewSyncMap[string, BindingCallFunction](), |
| 914 | viewportSize: viewportSize, |
| 915 | harRouters: make([]*harRouter, 0), |
| 916 | locatorHandlers: make(map[float64]*locatorHandlerEntry, 0), |
| 917 | } |
| 918 | bt.createChannelOwner(bt, parent, objectType, guid, initializer) |
| 919 | if closed, ok := initializer["isClosed"].(bool); ok { |
| 920 | bt.isClosed = closed |
| 921 | } |
| 922 | bt.browserContext = fromChannel(parent.channel).(*browserContextImpl) |
| 923 | bt.timeoutSettings = newTimeoutSettings(bt.browserContext.timeoutSettings) |
| 924 | mainframe := fromChannel(initializer["mainFrame"]).(*frameImpl) |
| 925 | mainframe.page = bt |
| 926 | bt.mainFrame = mainframe |
| 927 | bt.frames = []Frame{mainframe} |
| 928 | bt.mouse = newMouse(bt.channel) |
| 929 | bt.keyboard = newKeyboard(bt.channel) |
| 930 | bt.touchscreen = newTouchscreen(bt.channel) |
| 931 | bt.localStorage = newWebStorage(bt, "local") |
| 932 | bt.sessionStorage = newWebStorage(bt, "session") |
| 933 | bt.channel.On("bindingCall", func(params map[string]any) { |
| 934 | bt.onBinding(fromChannel(params["binding"]).(*bindingCallImpl)) |
| 935 | }) |
| 936 | bt.channel.On("close", bt.onClose) |
| 937 | bt.channel.On("crash", func() { |
| 938 | bt.Emit("crash", bt) |
| 939 | }) |
| 940 | bt.channel.On("domcontentloaded", func() { |
| 941 | bt.Emit("domcontentloaded", bt) |
| 942 | }) |
| 943 | bt.channel.On("fileChooser", func(ev map[string]any) { |
| 944 | bt.Emit("filechooser", newFileChooser(bt, fromChannel(ev["element"]).(*elementHandleImpl), ev["isMultiple"].(bool))) |
| 945 | }) |
| 946 | bt.channel.On("frameAttached", func(ev map[string]any) { |
| 947 | bt.onFrameAttached(fromChannel(ev["frame"]).(*frameImpl)) |
| 948 | }) |
| 949 | bt.channel.On("frameDetached", func(ev map[string]any) { |
| 950 | bt.onFrameDetached(fromChannel(ev["frame"]).(*frameImpl)) |
| 951 | }) |
| 952 | bt.channel.On("viewportSizeChanged", func(ev map[string]any) { |
| 953 | // Keep viewportSize in sync with server-driven changes (e.g. a sized popup). |
| 954 | if vs, ok := ev["viewportSize"].(map[string]any); ok { |
| 955 | bt.viewportSize = &Size{ |
| 956 | Width: int(vs["width"].(float64)), |
| 957 | Height: int(vs["height"].(float64)), |
| 958 | } |
| 959 | } |
| 960 | }) |
| 961 | bt.channel.On("locatorHandlerTriggered", func(ev map[string]any) { |
no test coverage detected