U
    g'Q                     @  s~  d dl mZ ddlmZmZ d dlmZ d dlZd dlZddl	m
Z
 ddl	mZ ddl	mZ eG d	d
 d
ZeG dd dZG dd dejZeG dd dZeG dd dZddddZddddZddddZddddZdddd d!Zd"dd#d$d%Zdid&dd'd(d)Zdjd*d*d"dd+d,d,d,d,d-d.d/dd0d1d2Zddd3d4d5Zddd6d7d8Zdkdd9dd:d;d<Zdld9d=dd>d?d@ZdAddBdCdDZdmd+d+d+ddEdFdGZ dAddHdIdJZ!d"ddKdLdMZ"dddNdOdPZ#dndd,ddQdRdSZ$dodd+d,d-dTdUdVdWdXZ%dpd9ddYdZd[Z&dAdd\d]d^Z'd*d*dd_d`daZ(dqdAd9d9dbddcdddeZ)edfeG dgdh dhZ*dS )r    )annotations   )event_classT_JSON_DICT)	dataclassN)dom)network)pagec                   @  s6   e Zd ZU dZded< ded< dd Zedd	 Zd
S )ScreenOrientationz
    Screen orientation.
    strtype_intanglec                 C  s   t  }| j|d< | j|d< |S )Ntyper   )dictr   r   selfjson r   T/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/devtools/v85/emulation.pyto_json   s    

zScreenOrientation.to_jsonc                 C  s   | t |d t|d dS )Nr   r   )r   r   )r   r   clsr   r   r   r   	from_json"   s    

zScreenOrientation.from_jsonN__name__
__module____qualname____doc____annotations__r   classmethodr   r   r   r   r   r
      s   
r
   c                   @  s2   e Zd ZU ded< ded< dd Zedd ZdS )	MediaFeaturer   namevaluec                 C  s   t  }| j|d< | j|d< |S )Nr"   r#   )r   r"   r#   r   r   r   r   r   0   s    

zMediaFeature.to_jsonc                 C  s   | t |d t |d dS )Nr"   r#   )r"   r#   r   r   r   r   r   r   6   s    

zMediaFeature.from_jsonN)r   r   r   r   r   r    r   r   r   r   r   r!   *   s
   
r!   c                   @  s0   e Zd ZdZdZdZdZdd Zedd Z	d	S )
VirtualTimePolicya?  
    advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to
    allow the next delayed task (if any) to run; pause: The virtual time base may not advance;
    pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending
    resource fetches.
    ZadvancepauseZpauseIfNetworkFetchesPendingc                 C  s   | j S N)r#   )r   r   r   r   r   I   s    zVirtualTimePolicy.to_jsonc                 C  s   | |S r'   r   r   r   r   r   r   L   s    zVirtualTimePolicy.from_jsonN)
r   r   r   r   ZADVANCEZPAUSEZ PAUSE_IF_NETWORK_FETCHES_PENDINGr   r    r   r   r   r   r   r%   >   s   r%   c                   @  s6   e Zd ZU dZded< ded< dd Zedd Zd	S )
UserAgentBrandVersiong
    Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
    r   brandversionc                 C  s   t  }| j|d< | j|d< |S )Nr*   r+   )r   r*   r+   r   r   r   r   r   Z   s    

zUserAgentBrandVersion.to_jsonc                 C  s   | t |d t |d dS )Nr*   r+   )r*   r+   r$   r   r   r   r   r   `   s    

zUserAgentBrandVersion.from_jsonNr   r   r   r   r   r(   Q   s   
r(   c                   @  s^   e Zd ZU dZded< ded< ded< ded< ded< ded	< d
ed< dd Zedd ZdS )UserAgentMetadatar)   z"typing.List[UserAgentBrandVersion]brandsr   full_versionplatformplatform_versionarchitecturemodelboolmobilec                 C  sZ   t  }dd | jD |d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d	< |S )
Nc                 S  s   g | ]}|  qS r   r   .0ir   r   r   
<listcomp>}   s     z-UserAgentMetadata.to_json.<locals>.<listcomp>r-   fullVersionr/   platformVersionr1   r2   r4   )r   r-   r.   r/   r0   r1   r2   r4   r   r   r   r   r   {   s    





zUserAgentMetadata.to_jsonc              
   C  sT   | dd |d D t |d t |d t |d t |d t |d t|d	 d
S )Nc                 S  s   g | ]}t |qS r   )r(   r   r6   r   r   r   r9      s     z/UserAgentMetadata.from_json.<locals>.<listcomp>r-   r:   r/   r;   r1   r2   r4   )r-   r.   r/   r0   r1   r2   r4   )r   r3   r   r   r   r   r      s    





zUserAgentMetadata.from_jsonNr   r   r   r   r   r,   h   s   
r,   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, bool])returnc                  c  s   ddi} | V }t |d S )z^
    Tells whether emulation is supported.

    :returns: True if emulation is supported.
    methodzEmulation.canEmulateresult)r3   cmd_dictr   r   r   r   can_emulate   s
     rA   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c  s   ddi} | V }dS )z/
    Clears the overridden device metrics.
    r=   z$Emulation.clearDeviceMetricsOverrideNr   r?   r   r   r   clear_device_metrics_override   s     rB   c                  c  s   ddi} | V }dS )z?
    Clears the overridden Geolocation Position and Error.
    r=   z"Emulation.clearGeolocationOverrideNr   r?   r   r   r   clear_geolocation_override   s     rC   c                  c  s   ddi} | V }dS )z[
    Requests that page scale factor is reset to initial values.

    **EXPERIMENTAL**
    r=   zEmulation.resetPageScaleFactorNr   r?   r   r   r   reset_page_scale_factor   s     rD   r3   )enabledr<   c                 c  s"   t  }| |d< d|d}|V }dS )z
    Enables or disables simulating a focused and active page.

    **EXPERIMENTAL**

    :param enabled: Whether to enable to disable focus emulation.
    rE   z"Emulation.setFocusEmulationEnabledr=   paramsNr   )rE   rG   r@   r   r   r   r   set_focus_emulation_enabled   s    
rI   float)rater<   c                 c  s"   t  }| |d< d|d}|V }dS )z
    Enables CPU throttling to emulate slow CPUs.

    **EXPERIMENTAL**

    :param rate: Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
    rK   zEmulation.setCPUThrottlingRaterF   NrH   )rK   rG   r@   r   r   r   r   set_cpu_throttling_rate   s    
rL   ztyping.Optional[dom.RGBA])colorr<   c                 c  s.   t  }| dk	r|  |d< d|d}|V }dS )a  
    Sets or clears an override of the default background color of the frame. This override is used
    if the content does not specify one.

    :param color: *(Optional)* RGBA of the default background color. If not specified, any existing override will be cleared.
    NrM   z+Emulation.setDefaultBackgroundColorOverriderF   r   r   )rM   rG   r@   r   r   r   r   %set_default_background_color_override   s    	rO   r   ztyping.Optional[float]ztyping.Optional[int]ztyping.Optional[bool]z"typing.Optional[ScreenOrientation]ztyping.Optional[page.Viewport])widthheightdevice_scale_factorr4   scalescreen_widthscreen_height
position_x
position_ydont_set_visible_sizescreen_orientationviewportr<   c                 c  s   t  }| |d< ||d< ||d< ||d< |dk	r6||d< |dk	rF||d< |dk	rV||d< |dk	rf||d	< |dk	rv||d
< |	dk	r|	|d< |
dk	r|
 |d< |dk	r| |d< d|d}|V }dS )a  
    Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
    window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
    query results).

    :param width: Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
    :param height: Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
    :param device_scale_factor: Overriding device scale factor value. 0 disables the override.
    :param mobile: Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
    :param scale: **(EXPERIMENTAL)** *(Optional)* Scale to apply to resulting view image.
    :param screen_width: **(EXPERIMENTAL)** *(Optional)* Overriding screen width value in pixels (minimum 0, maximum 10000000).
    :param screen_height: **(EXPERIMENTAL)** *(Optional)* Overriding screen height value in pixels (minimum 0, maximum 10000000).
    :param position_x: **(EXPERIMENTAL)** *(Optional)* Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
    :param position_y: **(EXPERIMENTAL)** *(Optional)* Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
    :param dont_set_visible_size: **(EXPERIMENTAL)** *(Optional)* Do not set visible view size, rely upon explicit setVisibleSize call.
    :param screen_orientation: *(Optional)* Screen orientation override.
    :param viewport: **(EXPERIMENTAL)** *(Optional)* If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions.
    rP   rQ   ZdeviceScaleFactorr4   NrS   ZscreenWidthZscreenHeightZ	positionXZ	positionYZdontSetVisibleSizeZscreenOrientationrZ   z"Emulation.setDeviceMetricsOverriderF   rN   )rP   rQ   rR   r4   rS   rT   rU   rV   rW   rX   rY   rZ   rG   r@   r   r   r   r   set_device_metrics_override   s2     r[   )hiddenr<   c                 c  s"   t  }| |d< d|d}|V }dS )z\


    **EXPERIMENTAL**

    :param hidden: Whether scrollbars should be always hidden.
    r\   zEmulation.setScrollbarsHiddenrF   NrH   )r\   rG   r@   r   r   r   r   set_scrollbars_hidden5  s    
r]   )disabledr<   c                 c  s"   t  }| |d< d|d}|V }dS )zc


    **EXPERIMENTAL**

    :param disabled: Whether document.coookie API should be disabled.
    r^   z#Emulation.setDocumentCookieDisabledrF   NrH   )r^   rG   r@   r   r   r   r   set_document_cookie_disabledH  s    
r_   ztyping.Optional[str])rE   configurationr<   c                 c  s2   t  }| |d< |dk	r||d< d|d}|V }dS )z


    **EXPERIMENTAL**

    :param enabled: Whether touch emulation based on mouse input should be enabled.
    :param configuration: *(Optional)* Touch/gesture events configuration. Default: current platform.
    rE   Nr`   z$Emulation.setEmitTouchEventsForMouserF   rH   )rE   r`   rG   r@   r   r   r   r   set_emit_touch_events_for_mouse[  s    ra   z*typing.Optional[typing.List[MediaFeature]])mediafeaturesr<   c                 c  sD   t  }| dk	r| |d< |dk	r0dd |D |d< d|d}|V }dS )z
    Emulates the given media type or media feature for CSS media queries.

    :param media: *(Optional)* Media type to emulate. Empty string disables the override.
    :param features: *(Optional)* Media features to emulate.
    Nrb   c                 S  s   g | ]}|  qS r   r5   r6   r   r   r   r9     s     z&set_emulated_media.<locals>.<listcomp>rc   zEmulation.setEmulatedMediarF   rH   )rb   rc   rG   r@   r   r   r   r   set_emulated_mediar  s    
rd   r   )r   r<   c                 c  s"   t  }| |d< d|d}|V }dS )zv
    Emulates the given vision deficiency.

    **EXPERIMENTAL**

    :param type_: Vision deficiency to emulate.
    r   z%Emulation.setEmulatedVisionDeficiencyrF   NrH   )r   rG   r@   r   r   r   r   set_emulated_vision_deficiency  s    
re   )latitude	longitudeaccuracyr<   c                 c  sJ   t  }| dk	r| |d< |dk	r&||d< |dk	r6||d< d|d}|V }dS )a  
    Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
    unavailable.

    :param latitude: *(Optional)* Mock latitude
    :param longitude: *(Optional)* Mock longitude
    :param accuracy: *(Optional)* Mock accuracy
    Nrf   rg   rh   z Emulation.setGeolocationOverriderF   rH   )rf   rg   rh   rG   r@   r   r   r   r   set_geolocation_override  s    ri   )r/   r<   c                 c  s"   t  }| |d< d|d}|V }dS )z
    Overrides value returned by the javascript navigator object.

    **EXPERIMENTAL**

    :param platform: The platform navigator.platform should return.
    r/   zEmulation.setNavigatorOverridesrF   NrH   )r/   rG   r@   r   r   r   r   set_navigator_overrides  s    
rj   )page_scale_factorr<   c                 c  s"   t  }| |d< d|d}|V }dS )zu
    Sets a specified page scale factor.

    **EXPERIMENTAL**

    :param page_scale_factor: Page scale factor.
    ZpageScaleFactorzEmulation.setPageScaleFactorrF   NrH   )rk   rG   r@   r   r   r   r   set_page_scale_factor  s    
rl   )r#   r<   c                 c  s"   t  }| |d< d|d}|V }dS )z|
    Switches script execution in the page.

    :param value: Whether script execution should be disabled in the page.
    r#   z$Emulation.setScriptExecutionDisabledrF   NrH   )r#   rG   r@   r   r   r   r   set_script_execution_disabled  s    rm   )rE   max_touch_pointsr<   c                 c  s2   t  }| |d< |dk	r||d< d|d}|V }dS )z
    Enables touch on platforms which do not support them.

    :param enabled: Whether the touch event emulation should be enabled.
    :param max_touch_points: *(Optional)* Maximum touch points supported. Defaults to one.
    rE   NZmaxTouchPointsz"Emulation.setTouchEmulationEnabledrF   rH   )rE   rn   rG   r@   r   r   r   r   set_touch_emulation_enabled  s    
ro   z'typing.Optional[network.TimeSinceEpoch]z1typing.Generator[T_JSON_DICT, T_JSON_DICT, float])policybudget&max_virtual_time_task_starvation_countwait_for_navigationinitial_virtual_timer<   c                 c  sr   t  }|  |d< |dk	r"||d< |dk	r2||d< |dk	rB||d< |dk	rV| |d< d|d}|V }t|d	 S )
a  
    Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets
    the current virtual time policy.  Note this supersedes any previous time budget.

    **EXPERIMENTAL**

    :param policy:
    :param budget: *(Optional)* If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
    :param max_virtual_time_task_starvation_count: *(Optional)* If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
    :param wait_for_navigation: *(Optional)* If set the virtual time policy change should be deferred until any frame starts navigating. Note any previous deferred policy change is superseded.
    :param initial_virtual_time: *(Optional)* If set, base::Time::Now will be overridden to initially return this value.
    :returns: Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
    rp   Nrq   Z!maxVirtualTimeTaskStarvationCountZwaitForNavigationZinitialVirtualTimezEmulation.setVirtualTimePolicyrF   ZvirtualTimeTicksBase)r   r   rJ   )rp   rq   rr   rs   rt   rG   r@   r   r   r   r   set_virtual_time_policy  s    ru   )localer<   c                 c  s*   t  }| dk	r| |d< d|d}|V }dS )z
    Overrides default host system locale with the specified one.

    **EXPERIMENTAL**

    :param locale: *(Optional)* ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
    Nrv   zEmulation.setLocaleOverriderF   rH   )rv   rG   r@   r   r   r   r   set_locale_override(  s    
rw   )timezone_idr<   c                 c  s"   t  }| |d< d|d}|V }dS )z
    Overrides default host system timezone with the specified one.

    **EXPERIMENTAL**

    :param timezone_id: The timezone identifier. If empty, disables the override and restores default host system timezone.
    Z
timezoneIdzEmulation.setTimezoneOverriderF   NrH   )rx   rG   r@   r   r   r   r   set_timezone_override<  s    
ry   )rP   rQ   r<   c                 c  s*   t  }| |d< ||d< d|d}|V }dS )a<  
    Resizes the frame/viewport of the page. Note that this does not affect the frame's container
    (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported
    on Android.

    **EXPERIMENTAL**

    :param width: Frame width (DIP).
    :param height: Frame height (DIP).
    rP   rQ   zEmulation.setVisibleSizerF   NrH   )rP   rQ   rG   r@   r   r   r   r   set_visible_sizeO  s    rz   z"typing.Optional[UserAgentMetadata])
user_agentaccept_languager/   user_agent_metadatar<   c                 c  sV   t  }| |d< |dk	r||d< |dk	r.||d< |dk	rB| |d< d|d}|V }dS )a  
    Allows overriding user agent with the given string.

    :param user_agent: User agent to use.
    :param accept_language: *(Optional)* Browser langugage to emulate.
    :param platform: *(Optional)* The platform navigator.platform should return.
    :param user_agent_metadata: **(EXPERIMENTAL)** *(Optional)* To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
    Z	userAgentNZacceptLanguager/   ZuserAgentMetadatazEmulation.setUserAgentOverriderF   rN   )r{   r|   r/   r}   rG   r@   r   r   r   r   set_user_agent_overrideg  s    r~   z"Emulation.virtualTimeBudgetExpiredc                   @  s$   e Zd ZdZedd dddZdS )VirtualTimeBudgetExpiredz~
    **EXPERIMENTAL**

    Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
    r   )r   r<   c                 C  s   |  S r'   r   r   r   r   r   r     s    z"VirtualTimeBudgetExpired.from_jsonN)r   r   r   r   r    r   r   r   r   r   r     s   r   )N)NNNNNNNN)N)NN)NNN)N)NNNN)N)NNN)+
__future__r   utilr   r   Zdataclassesr   enumtyping r   r   r	   r
   r!   Enumr%   r(   r,   rA   rB   rC   rD   rI   rL   rO   r[   r]   r_   ra   rd   re   ri   rj   rl   rm   ro   ru   rw   ry   rz   r~   r   r   r   r   r   <module>   s   *

         (<           '    