ScreenCaptureModel.js 2.3 KB

123456789101112131415161718192021222324252627282930
  1. export default class ScreenCaptureModel extends SDK.SDKModel{constructor(target){super(target);this._agent=target.pageAgent();this._onScreencastFrame=null;this._onScreencastVisibilityChanged=null;target.registerPageDispatcher(this);}
  2. startScreencast(format,quality,width,height,everyNthFrame,onFrame,onVisibilityChanged){this._onScreencastFrame=onFrame;this._onScreencastVisibilityChanged=onVisibilityChanged;this._agent.startScreencast(format,quality,width,height,everyNthFrame);}
  3. stopScreencast(){this._onScreencastFrame=null;this._onScreencastVisibilityChanged=null;this._agent.stopScreencast();}
  4. async captureScreenshot(format,quality,clip){await SDK.OverlayModel.muteHighlight();const result=await this._agent.captureScreenshot(format,quality,clip,true);await SDK.OverlayModel.unmuteHighlight();return result;}
  5. async fetchLayoutMetrics(){const response=await this._agent.invoke_getLayoutMetrics({});if(response[Protocol.Error]){return null;}
  6. return{viewportX:response.visualViewport.pageX,viewportY:response.visualViewport.pageY,viewportScale:response.visualViewport.scale,contentWidth:response.contentSize.width,contentHeight:response.contentSize.height};}
  7. screencastFrame(data,metadata,sessionId){this._agent.screencastFrameAck(sessionId);if(this._onScreencastFrame){this._onScreencastFrame.call(null,data,metadata);}}
  8. screencastVisibilityChanged(visible){if(this._onScreencastVisibilityChanged){this._onScreencastVisibilityChanged.call(null,visible);}}
  9. domContentEventFired(time){}
  10. loadEventFired(time){}
  11. lifecycleEvent(frameId,loaderId,name,time){}
  12. navigatedWithinDocument(frameId,url){}
  13. frameAttached(frameId,parentFrameId){}
  14. frameNavigated(frame){}
  15. frameDetached(frameId){}
  16. frameStartedLoading(frameId){}
  17. frameStoppedLoading(frameId){}
  18. frameRequestedNavigation(frameId){}
  19. frameScheduledNavigation(frameId,delay){}
  20. frameClearedScheduledNavigation(frameId){}
  21. frameResized(){}
  22. javascriptDialogOpening(url,message,dialogType,hasBrowserHandler,prompt){}
  23. javascriptDialogClosed(result,userInput){}
  24. interstitialShown(){}
  25. interstitialHidden(){}
  26. windowOpen(url,windowName,windowFeatures,userGesture){}
  27. fileChooserOpened(mode){}
  28. compilationCacheProduced(url,data){}
  29. downloadWillBegin(frameId,url){}}
  30. self.SDK=self.SDK||{};SDK=SDK||{};SDK.ScreenCaptureModel=ScreenCaptureModel;SDK.SDKModel.register(SDK.ScreenCaptureModel,SDK.Target.Capability.ScreenCapture,false);