From f37036ba2e33c000c87fb98c795554b43edd1535 Mon Sep 17 00:00:00 2001 From: Shengfa Lin Date: Thu, 16 Jul 2020 12:33:52 -0500 Subject: [PATCH 1/4] Proposing a post endpoint for Take Screenshot that with fullpage option Due to the high demand from https://bugs.chromium.org/p/chromedriver/issues/detail?id=294, come up with initial proposal for the spec --- index.html | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/index.html b/index.html index a607412f5..cc41251eb 100644 --- a/index.html +++ b/index.html @@ -1016,6 +1016,12 @@

Endpoints

Take Element Screenshot + + POST + /session/{session id}/screenshot + Take Screenshot with option + + POST /session/{session id}/print @@ -9035,6 +9041,74 @@

Screen capture

and a command Take Element Screenshot for doing the same with the visible region of an element’s bounding rectangle after it has been scrolled into view. + It also provides a Take Screenshot with option command + to optionally capture the fullpage region. + +

An element’s fullpage region + is the rendered rectangle that encompasses the maximal scrollable width + and height, + it can be calculated this way: +

    +
  1. Let x be 0 + +

  2. Let y be 0 + +

  3. Let width be the value + returned by +

    max(document.body.scrollWidth, document.documentElement.scrollWidth, + document.body.offsetWidth, document.documentElement.offsetWidth, + document.body.clientWidth, document.documentElement.clientWidth) + +

  4. Let height be the value + returned by +

    max(document.body.scrollHeight, document.documentElement.scrollHeight, + document.body.offsetHeight, document.documentElement.offsetHeight, + document.body.clientHeight, document.documentElement.clientHeight) + +

  5. Return {x, y, width, height}. +

+ +

In order to draw a bounding box from the fullpage region, + given a rectangle: + +

    +
  1. If either the rectangle’s width or height + is 0 CSS pixels, + return error with error code unable to capture screen. + +

  2. Let paint width be the rectangle’s width + +

  3. Let paint height be the rectangle’s height + +

  4. Let canvas be a new canvas element, + and set its width + and height + to paint width and paint height, respectively. + +

  5. Let context, a canvas context mode, + be the result of invoking the 2D context creation algorithm + given canvas as the target. + +

  6. Complete implementation specific steps equivalent to + drawing the region of the framebuffer + specified by the following coordinates onto context: + +

    +
    X coordinate +
    rectangle x coordinate + +
    Y coordinate +
    rectangle y coordinate + +
    Width +
    paint width + +
    Height +
    paint height +
    + +
  7. Return success with canvas. +

In order to draw a bounding box from the framebuffer, given a rectangle: @@ -9215,6 +9289,55 @@

Take Element Screenshot

  • Return success with data encoded string. + +

    +

    Take Screenshot with option

    + + + + + + + + + + +
    HTTP MethodURI Template
    POST/session/{session id}/screenshot
    + +

    The remote end steps are: + +

      +
    1. If the current top-level browsing context is no longer open, + return error with error code no such window. + +

    2. Let fullpage be the result of getting a + property with default named fullpage and with + default true from the parameters argument. + +

    3. If fullpage is true, when the user agent is next to run the animation frame callbacks: +

        + +
      1. Let content rect be the current top-level browsing context’s + document element’s fullpage region. + +

      2. Let screenshot result be the result of trying to call + draw a bounding box from the fullpage region, + given content rect as an argument. + +

      3. Let canvas be a canvas element + of screenshot result’s data. + +

      4. Let encoding result be the result of trying + encoding a canvas as Base64 canvas. + +

      5. Let encoded string be encoding result’s data. +

      + +
    4. Return success with data encoded string. +

    5. Otherwise, run the steps for Take Screenshot +

    + +
    From e134c44b5d9a7911b62c21c5227a1cc107474ed4 Mon Sep 17 00:00:00 2001 From: Shengfa Lin Date: Fri, 17 Jul 2020 14:27:40 -0500 Subject: [PATCH 2/4] Use GET with /screenshot/full instead --- index.html | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index cc41251eb..08a67f9b7 100644 --- a/index.html +++ b/index.html @@ -1017,9 +1017,9 @@

    Endpoints

    - POST - /session/{session id}/screenshot - Take Screenshot with option + GET + /session/{session id}/screenshot/full + Take Fullpage Screenshot @@ -9041,7 +9041,7 @@

    Screen capture

    and a command Take Element Screenshot for doing the same with the visible region of an element’s bounding rectangle after it has been scrolled into view. - It also provides a Take Screenshot with option command + It also provides a Take Fullpage Screenshot command to optionally capture the fullpage region.

    An element’s fullpage region @@ -9291,7 +9291,7 @@

    Take Element Screenshot

    -

    Take Screenshot with option

    +

    Take Fullpage Screenshot

    @@ -9299,8 +9299,8 @@

    Take Screenshot with option

    - - + +
    URI Template
    POST/session/{session id}/screenshotGET/session/{session id}/screenshot/full
    @@ -9310,11 +9310,7 @@

    Take Screenshot with option

  • If the current top-level browsing context is no longer open, return error with error code no such window. -

  • Let fullpage be the result of getting a - property with default named fullpage and with - default true from the parameters argument. - -

  • If fullpage is true, when the user agent is next to run the animation frame callbacks: +

  • When the user agent is next to run the animation frame callbacks:

    1. Let content rect be the current top-level browsing context’s @@ -9334,7 +9330,6 @@

      Take Screenshot with option

  • Return success with data encoded string. -

  • Otherwise, run the steps for Take Screenshot

  • From 16a640d4cad49cde666e87d7757971e5a8ce6339 Mon Sep 17 00:00:00 2001 From: Shengfa Lin Date: Tue, 22 Sep 2020 01:20:02 -0500 Subject: [PATCH 3/4] Simplify wording and width/height calculation --- index.html | 83 ++++++++++++++++++++---------------------------------- 1 file changed, 31 insertions(+), 52 deletions(-) diff --git a/index.html b/index.html index 08a67f9b7..626de0d0d 100644 --- a/index.html +++ b/index.html @@ -1019,7 +1019,7 @@

    Endpoints

    GET /session/{session id}/screenshot/full - Take Fullpage Screenshot + Take Full Page Screenshot @@ -9041,44 +9041,24 @@

    Screen capture

    and a command Take Element Screenshot for doing the same with the visible region of an element’s bounding rectangle after it has been scrolled into view. - It also provides a Take Fullpage Screenshot command - to optionally capture the fullpage region. + It also provides a Take Full Page Screenshot command + to capture the scrollable region of the top-level browsing context’s scrolling element -

    An element’s fullpage region - is the rendered rectangle that encompasses the maximal scrollable width - and height, - it can be calculated this way: -

      -
    1. Let x be 0 - -

    2. Let y be 0 - -

    3. Let width be the value - returned by -

      max(document.body.scrollWidth, document.documentElement.scrollWidth, - document.body.offsetWidth, document.documentElement.offsetWidth, - document.body.clientWidth, document.documentElement.clientWidth) - -

    4. Let height be the value - returned by -

      max(document.body.scrollHeight, document.documentElement.scrollHeight, - document.body.offsetHeight, document.documentElement.offsetHeight, - document.body.clientHeight, document.documentElement.clientHeight) - -

    5. Return {x, y, width, height}. -

    - -

    In order to draw a bounding box from the fullpage region, +

    In order to draw a bounding box from the framebuffer, given a rectangle:

      -
    1. If either the rectangle’s width or height +

    2. If either the initial viewport’s width or height is 0 CSS pixels, return error with error code unable to capture screen. -

    3. Let paint width be the rectangle’s width +

    4. Let paint width be the initial viewport’s width – + min(rectangle x coordinate, + rectangle x coordinate + rectangle width dimension). -

    5. Let paint height be the rectangle’s height +

    6. Let paint height be the initial viewport’s height – + min(rectangle y coordinate, + rectangle y coordinate + rectangle height dimension).

    7. Let canvas be a new canvas element, and set its width @@ -9110,26 +9090,18 @@

      Screen capture

    8. Return success with canvas.

    -

    In order to draw a bounding box from the framebuffer, - given a rectangle: +

    In order to draw a scrollable region from the framebuffer, + given a scrolling element:

    1. If either the initial viewport’s width or height is 0 CSS pixels, return error with error code unable to capture screen. -

    2. Let paint width be the initial viewport’s width – - min(rectangle x coordinate, - rectangle x coordinate + rectangle width dimension). - -

    3. Let paint height be the initial viewport’s height – - min(rectangle y coordinate, - rectangle y coordinate + rectangle height dimension). -

    4. Let canvas be a new canvas element, and set its width and height - to paint width and paint height, respectively. + to scrolling element scrollWidth and scrollHeight, respectively.

    5. Let context, a canvas context mode, be the result of invoking the 2D context creation algorithm @@ -9141,21 +9113,22 @@

      Screen capture

      X coordinate -
      rectangle x coordinate +
      0
      Y coordinate -
      rectangle y coordinate +
      0
      Width -
      paint width +
      scrolling element scrollWidth
      Height -
      paint height +
      scrolling element scrollHeight
    6. Return success with canvas.

    +

    To encode a canvas as Base64 a canvas element: @@ -9291,7 +9264,7 @@

    Take Element Screenshot

    -

    Take Fullpage Screenshot

    +

    Take Full Page Screenshot

    @@ -9313,12 +9286,9 @@

    Take Fullpage Screenshot

  • When the user agent is next to run the animation frame callbacks:

      -
    1. Let content rect be the current top-level browsing context’s - document element’s fullpage region. -

    2. Let screenshot result be the result of trying to call - draw a bounding box from the fullpage region, - given content rect as an argument. + draw a scrollable region from the framebuffer, + given scrolling element as an argument.

    3. Let canvas be a canvas element of screenshot result’s data. @@ -10229,6 +10199,15 @@

      Index

      sometimes here referred to as the viewport. +
      The following terms are defined in + the CSSOM View Module: [[CSSOM-VIEW]] + +
      The following properties are defined in the CSS Display Module Level 3 specification: [[CSS3-DISPLAY]]
        From 1a802aaf986f3c527c28f2069814f925cc3f0f64 Mon Sep 17 00:00:00 2001 From: Shengfa Lin Date: Mon, 30 Nov 2020 12:55:31 -0600 Subject: [PATCH 4/4] Moved Take Full Screenshot right after Take Screenshot --- index.html | 94 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/index.html b/index.html index 626de0d0d..aeb3cdf53 100644 --- a/index.html +++ b/index.html @@ -1012,14 +1012,14 @@

        Endpoints

  • - - + + - - + + @@ -9038,11 +9038,11 @@

    Screen capture

    WebDriver provides the Take Screenshot command to capture the top-level browsing context’s initial viewport, + and the Take Full Screenshot command + to capture the scrollable region of the top-level browsing context’s scrolling element, and a command Take Element Screenshot for doing the same with the visible region of an element’s bounding rectangle after it has been scrolled into view. - It also provides a Take Full Page Screenshot command - to capture the scrollable region of the top-level browsing context’s scrolling element

    In order to draw a bounding box from the framebuffer, given a rectangle: @@ -9199,6 +9199,47 @@

    Take Screenshot

    +
    +

    Take Full Screenshot

    + +
    GET/session/{session id}/element/{element id}/screenshotTake Element Screenshot/session/{session id}/screenshot/fullTake Full Screenshot
    GET/session/{session id}/screenshot/fullTake Full Page Screenshot/session/{session id}/element/{element id}/screenshotTake Element Screenshot
    + + + + + + + + +
    HTTP MethodURI Template
    GET/session/{session id}/screenshot/full
    + +

    The remote end steps are: + +

      +
    1. If the current top-level browsing context is no longer open, + return error with error code no such window. + +

    2. When the user agent is next to run the animation frame callbacks: +

        + +
      1. Let screenshot result be the result of trying to call + draw a scrollable region from the framebuffer, + given scrolling element as an argument. + +

      2. Let canvas be a canvas element + of screenshot result’s data. + +

      3. Let encoding result be the result of trying + encoding a canvas as Base64 canvas. + +

      4. Let encoded string be encoding result’s data. +

      + +
    3. Return success with data encoded string. +

    + +
    +

    Take Element Screenshot

    @@ -9262,47 +9303,6 @@

    Take Element Screenshot

  • Return success with data encoded string.

  • - -
    -

    Take Full Page Screenshot

    - - - - - - - - - - -
    HTTP MethodURI Template
    GET/session/{session id}/screenshot/full
    - -

    The remote end steps are: - -

      -
    1. If the current top-level browsing context is no longer open, - return error with error code no such window. - -

    2. When the user agent is next to run the animation frame callbacks: -

        - -
      1. Let screenshot result be the result of trying to call - draw a scrollable region from the framebuffer, - given scrolling element as an argument. - -

      2. Let canvas be a canvas element - of screenshot result’s data. - -

      3. Let encoding result be the result of trying - encoding a canvas as Base64 canvas. - -

      4. Let encoded string be encoding result’s data. -

      - -
    3. Return success with data encoded string. -

    - -