1-
21// use webdriverbidi::remote::browsing_context::ActivateParameters;
32// use webdriverbidi::remote::script::{ContextTarget, EvaluateParameters, Target};
43
@@ -202,7 +201,6 @@ mod utils;
202201// }
203202// }
204203
205-
206204// // async def get_viewport_dimensions(bidi_session, context: str,
207205// // with_scrollbar: bool = True, quirk_mode: bool = False):
208206// // if with_scrollbar:
@@ -247,11 +245,11 @@ mod utils;
247245// // https://github.com/web-platform-tests/wpt/tree/master/webdriver/tests/bidi/browsing_context/capture_screenshot
248246// mod capture_screenshot {
249247// use super::*;
250-
248+
251249// // async def test_capture(bidi_session, top_context, inline, compare_png_bidi,
252250// // activate):
253251// // expected_size = await get_physical_viewport_dimensions(bidi_session, top_context)
254-
252+
255253// // await bidi_session.browsing_context.navigate(
256254// // context=top_context["context"], url="about:blank", wait="complete"
257255// // )
@@ -261,7 +259,7 @@ mod utils;
261259// // reference_data = await bidi_session.browsing_context.capture_screenshot(
262260// // context=top_context["context"])
263261// // assert png_dimensions(reference_data) == expected_size
264-
262+
265263// // await bidi_session.browsing_context.navigate(
266264// // context=top_context["context"], url=inline("<div>foo</div>"), wait="complete"
267265// // )
@@ -270,10 +268,10 @@ mod utils;
270268// // context=top_context["context"])
271269// // data = await bidi_session.browsing_context.capture_screenshot(
272270// // context=top_context["context"])
273-
271+
274272// // comparison = await compare_png_bidi(data, reference_data)
275273// // assert not comparison.equal()
276-
274+
277275// // # Take a second screenshot that should be identical to validate that
278276// // # we don't just always return false here
279277// // await bidi_session.browsing_context.navigate(
@@ -284,58 +282,56 @@ mod utils;
284282// // context=top_context["context"])
285283// // new_data = await bidi_session.browsing_context.capture_screenshot(
286284// // context=top_context["context"])
287-
285+
288286// // comparison = await compare_png_bidi(new_data, data)
289287// // assert comparison.equal()
290-
291-
288+
292289// // @pytest.mark.parametrize("delta_width", [-10, +20], ids=["width smaller", "width larger"])
293290// // @pytest.mark.parametrize("delta_height", [-30, +40], ids=["height smaller", "height larger"])
294291// // @pytest.mark.asyncio
295292// // async def test_capture_with_viewport(bidi_session, new_tab, delta_width, delta_height):
296293// // original_viewport = await get_viewport_dimensions(bidi_session, new_tab)
297-
294+
298295// // dpr = await get_device_pixel_ratio(bidi_session, new_tab)
299-
296+
300297// // test_viewport = {
301298// // "width": original_viewport["width"] + delta_width,
302299// // "height": original_viewport["height"] + delta_height
303300// // }
304301// // await bidi_session.browsing_context.set_viewport(
305302// // context=new_tab["context"],
306303// // viewport=test_viewport)
307-
304+
308305// // expected_size = {
309306// // "width": floor(test_viewport["width"] * dpr),
310307// // "height": floor(test_viewport["height"] * dpr)
311308// // }
312-
309+
313310// // await bidi_session.browsing_context.navigate(
314311// // context=new_tab["context"], url="about:blank", wait="complete"
315312// // )
316-
313+
317314// // result = await bidi_session.browsing_context.capture_screenshot(
318315// // context=new_tab["context"])
319316// // assert png_dimensions(result) == (expected_size["width"], expected_size["height"])
320-
321-
317+
322318// // @pytest.mark.parametrize("dpr", [0.5, 2])
323319// // @pytest.mark.asyncio
324320// // async def test_capture_with_different_dpr(bidi_session, new_tab, inline, dpr):
325321// // page = inline("<div style='background-color: black; width: 100px; height: 100px;'></div>")
326322// // await bidi_session.browsing_context.navigate(
327323// // context=new_tab["context"], url=page, wait="complete"
328324// // )
329-
325+
330326// // original_viewport = await get_viewport_dimensions(bidi_session, new_tab)
331-
327+
332328// // await bidi_session.browsing_context.set_viewport(
333329// // context=new_tab["context"],
334330// // device_pixel_ratio=dpr)
335-
331+
336332// // expected_width = original_viewport["width"] * dpr
337333// // expected_height = original_viewport["height"] * dpr
338-
334+
339335// // data = await bidi_session.browsing_context.capture_screenshot(context=new_tab["context"])
340336// // (actual_width, actual_height) = png_dimensions(data)
341337// // # The rounding is implementation-specific and can be either floor, ceil or round depending on the browser
0 commit comments