예제 #1
0
 def onExecutionContentCreated(event: Dict) -> None:
     nonlocal jsHandleFactory
     executionContext = ExecutionContext(client, event['context'], None)
     jsHandleFactory = functools.partial(JSHandle,
                                         context=executionContext,
                                         client=client)
     self._executionContextPromise.set_result(executionContext)
예제 #2
0
        def onExecutionContentCreated(event: Dict) -> None:
            nonlocal jsHandleFactory

            def jsHandleFactory(remoteObject: Dict) -> JSHandle:
                return JSHandle(executionContext, client, remoteObject)
            executionContext = ExecutionContext(
                client, event['context'], jsHandleFactory)
            self._executionContextCallback(executionContext)
예제 #3
0
 def _onExecutionContextCreated(self, contextPayload: Dict) -> None:
     context = ExecutionContext(
         self._client, contextPayload,
         (lambda obj: self.createJSHandle(contextPayload['id'], obj)))
     self._contextIdToContext[contextPayload['id']] = context
     frame = (self._frames.get(context._frameId)
              if context._frameId else None)
     if (frame and context._isDefault):
         frame._setDefaultContext(context)
예제 #4
0
        def onExecutionContentCreated(event: Dict) -> None:
            _execution_contexts: List[ExecutionContext] = []
            nonlocal jsHandleFactory

            def jsHandleFactory(remoteObject: Dict) -> JSHandle:
                executionContext = _execution_contexts[0]
                return JSHandle(executionContext, client, remoteObject)

            executionContext = ExecutionContext(client, event['context'],
                                                jsHandleFactory)
            _execution_contexts.append(executionContext)
            self._executionContextCallback(executionContext)
예제 #5
0
 def _onExecutionContextCreated(self, contextPayload: Dict) -> None:
     if (contextPayload.get('auxData')
             and contextPayload['auxData']['isDefault']):
         frameId = contextPayload['auxData']['frameId']
     else:
         frameId = None
     frame = (self._frames.get(frameId) if frameId else None)
     context = ExecutionContext(
         self._client, contextPayload,
         (lambda obj: self.createJSHandle(contextPayload['id'], obj)),
         frame)
     self._contextIdToContext[contextPayload['id']] = context
     if frame:
         frame._setDefaultContext(context)
예제 #6
0
    def _onExecutionContextCreated(self, contextPayload: Dict) -> None:
        context = ExecutionContext(
            self._client,
            contextPayload['id'],
            lambda obj: self.createJSHandle(contextPayload['id'], obj),
        )
        self._contextIdToContext[contextPayload['id']] = context

        auxData = contextPayload.get('auxData')
        frameId = (auxData.get('frameId')
                   if auxData and auxData.get('isDefault') else None)
        frame = self._frames.get(frameId)
        if not frame:
            return
        frame._context = context
        for waitTask in frame._waitTasks:
            asyncio.ensure_future(waitTask.rerun())
예제 #7
0
    def _onExecutionContextCreated(self, contextPayload: Dict) -> None:
        if (contextPayload.get('auxData')
                and contextPayload['auxData'].get('frameId')):
            frameId = contextPayload['auxData']['frameId']
        else:
            frameId = None

        frame = self._frames.get(frameId)

        def _createJSHandle(obj: Dict) -> JSHandle:
            context = self.executionContextById(contextPayload['id'])
            return self.createJSHandle(context, obj)

        context = ExecutionContext(
            self._client,
            contextPayload,
            _createJSHandle,
            frame,
        )
        self._contextIdToContext[contextPayload['id']] = context

        if frame:
            frame._addExecutionContext(context)