예제 #1
0
        private Page(Session client, Target target, FrameTree frameTree, bool ignoreHTTPSErrors, TaskQueue screenshotTaskQueue)
        {
            _client           = client;
            _target           = target;
            Keyboard          = new Keyboard(client);
            _mouse            = new Mouse(client, Keyboard);
            Touchscreen       = new Touchscreen(client, Keyboard);
            _frameManager     = new FrameManager(client, frameTree, this);
            _networkManager   = new NetworkManager(client, _frameManager);
            _emulationManager = new EmulationManager(client);
            Tracing           = new Tracing(client);
            _pageBindings     = new Dictionary <string, Func <object> >();

            _ignoreHTTPSErrors = ignoreHTTPSErrors;

            _screenshotTaskQueue = screenshotTaskQueue;

            //TODO: Do we need this bubble?
            _frameManager.FrameAttached  += (sender, e) => FrameAttached?.Invoke(this, e);
            _frameManager.FrameDetached  += (sender, e) => FrameDetached?.Invoke(this, e);
            _frameManager.FrameNavigated += (sender, e) => FrameNavigated?.Invoke(this, e);

            _networkManager.RequestCreated  += (sender, e) => RequestCreated?.Invoke(this, e);
            _networkManager.RequestFailed   += (sender, e) => RequestFailed?.Invoke(this, e);
            _networkManager.ResponseCreated += (sender, e) => ResponseCreated?.Invoke(this, e);
            _networkManager.RequestFinished += (sender, e) => RequestFinished?.Invoke(this, e);

            _client.MessageReceived += client_MessageReceived;
        }
예제 #2
0
파일: FrameTree.cs 프로젝트: BoboBH/Demo
        private void LoadChilds(FrameTree frame, JToken frameTree)
        {
            var childFrames = frameTree[MessageKeys.ChildFrames];

            if (childFrames != null)
            {
                foreach (var item in childFrames)
                {
                    var childFrame = item[MessageKeys.Frame];

                    var newFrame = new FrameTree
                    {
                        Frame = new FramePayload
                        {
                            Id       = childFrame[MessageKeys.Id].AsString(),
                            ParentId = childFrame[MessageKeys.ParentId].AsString(),
                            Url      = childFrame[MessageKeys.Url].AsString()
                        }
                    };

                    if ((item as JObject)[MessageKeys.ChildFrames] != null)
                    {
                        LoadChilds(newFrame, item);
                    }

                    frame.Childs.Add(newFrame);
                }
            }
        }
예제 #3
0
        public FrameManager(Session client, FrameTree frameTree, Page page)
        {
            _client             = client;
            _page               = page;
            Frames              = new Dictionary <string, Frame>();
            _contextIdToContext = new Dictionary <string, ExecutionContext>();

            _client.MessageReceived += _client_MessageReceived;
            HandleFrameTree(frameTree);
        }
예제 #4
0
        internal FrameManager(CDPSession client, FrameTree frameTree, Page page)
        {
            _client             = client;
            Page                = page;
            Frames              = new Dictionary <string, Frame>();
            _contextIdToContext = new Dictionary <int, ExecutionContext>();
            _logger             = _client.Connection.LoggerFactory.CreateLogger <FrameManager>();

            _client.MessageReceived += _client_MessageReceived;
            HandleFrameTree(frameTree);
        }
예제 #5
0
        internal static async Task <FrameManager> CreateFrameManagerAsync(
            CDPSession client,
            Page page,
            NetworkManager networkManager,
            FrameTree frameTree,
            TimeoutSettings timeoutSettings)
        {
            var frameManager = new FrameManager(client, page, networkManager, timeoutSettings);
            await frameManager.HandleFrameTreeAsync(frameTree).ConfigureAwait(false);

            return(frameManager);
        }
예제 #6
0
        private void HandleFrameTree(FrameTree frameTree)
        {
            if (!string.IsNullOrEmpty(frameTree.Frame.ParentId))
            {
                OnFrameAttached(frameTree.Frame.Id, frameTree.Frame.ParentId);
            }

            OnFrameNavigated(frameTree.Frame);

            if (frameTree.Childs != null)
            {
                foreach (var child in frameTree.Childs)
                {
                    HandleFrameTree(child);
                }
            }
        }
예제 #7
0
        private async Task HandleFrameTreeAsync(FrameTree frameTree)
        {
            if (!string.IsNullOrEmpty(frameTree.Frame.ParentId))
            {
                OnFrameAttached(frameTree.Frame.Id, frameTree.Frame.ParentId);
            }

            await OnFrameNavigatedAsync(frameTree.Frame);

            if (frameTree.Childs != null)
            {
                foreach (var child in frameTree.Childs)
                {
                    await HandleFrameTreeAsync(child);
                }
            }
        }
예제 #8
0
        private void LoadChilds(FrameTree frame, dynamic frameTree)
        {
            if ((frameTree as JObject)["childs"] != null)
            {
                foreach (dynamic item in frameTree.childs)
                {
                    var newFrame = new FrameTree();

                    newFrame.Frame = new FramePayload
                    {
                        Id       = item.id,
                        ParentId = item.parentID
                    };

                    LoadChilds(newFrame, item.childs);
                    frame.Childs.Add(newFrame);
                }
            }
        }
예제 #9
0
        private void LoadChilds(FrameTree frame, dynamic frameTree)
        {
            if ((frameTree as JObject)["childFrames"] != null)
            {
                foreach (dynamic item in frameTree.childFrames)
                {
                    var newFrame = new FrameTree();

                    newFrame.Frame = new FramePayload
                    {
                        Id       = item.frame.id,
                        ParentId = item.frame.parentId,
                        Url      = item.frame.url
                    };

                    if ((item as JObject)["childFrames"] != null)
                    {
                        LoadChilds(newFrame, item);
                    }
                    frame.Childs.Add(newFrame);
                }
            }
        }