mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:47:36 +00:00
WebDriver+Browser: Implement GET /session/{id}/screenshot
This doesn't follow the spec to a tee. Our OutOfProcessWebView already has a bitmap that can be used as the window screenshot. Therefore, we can bypass the steps that assume we need to access the window's frame buffer in-flight. We also don't create an HTMLCanvasElement. We would need a Document in the WebDriver process to do so. Instead, we can still run the encoding steps exactly as-is using the screenshot bitmap.
This commit is contained in:
parent
d603585802
commit
1ffaad29e1
8 changed files with 81 additions and 3 deletions
|
@ -255,4 +255,16 @@ Messages::WebDriverSessionClient::GetElementTagNameResponse WebDriverConnection:
|
|||
return { "" };
|
||||
}
|
||||
|
||||
Messages::WebDriverSessionClient::TakeScreenshotResponse WebDriverConnection::take_screenshot()
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: take_screenshot");
|
||||
if (auto browser_window = m_browser_window.strong_ref()) {
|
||||
auto& tab = browser_window->active_tab();
|
||||
if (tab.on_take_screenshot)
|
||||
return { tab.on_take_screenshot() };
|
||||
}
|
||||
|
||||
return { {} };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
virtual Messages::WebDriverSessionClient::GetComputedValueForElementResponse get_computed_value_for_element(i32 element_id, String const& property_name) override;
|
||||
virtual Messages::WebDriverSessionClient::GetElementTextResponse get_element_text(i32 element_id) override;
|
||||
virtual Messages::WebDriverSessionClient::GetElementTagNameResponse get_element_tag_name(i32 element_id) override;
|
||||
virtual Messages::WebDriverSessionClient::TakeScreenshotResponse take_screenshot() override;
|
||||
|
||||
private:
|
||||
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, NonnullRefPtr<BrowserWindow> browser_window);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/ShareableBitmap.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
|
@ -33,5 +34,5 @@ endpoint WebDriverSessionClient {
|
|||
get_computed_value_for_element(i32 element_id, String property_name) => (String computed_value)
|
||||
get_element_text(i32 element_id) => (String text)
|
||||
get_element_tag_name(i32 element_id) => (String tag_name)
|
||||
|
||||
take_screenshot() => (Gfx::ShareableBitmap data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue