mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision cd44958a002b1ad494168e0290554644de84526e
This commit is contained in:
parent
2ed23ce4c9
commit
4443426308
103 changed files with 1740 additions and 1138 deletions
|
@ -1,10 +1 @@
|
|||
def retrieve_element_rect(session, element):
|
||||
return session.execute_script("""
|
||||
let rect = arguments[0].getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left + window.pageXOffset,
|
||||
y: rect.top + window.pageYOffset,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
};
|
||||
""", args=(element,))
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.helpers import element_rect
|
||||
from tests.support.inline import inline
|
||||
|
||||
from . import retrieve_element_rect
|
||||
|
||||
|
||||
def get_element_rect(session, element_id):
|
||||
return session.transport.send(
|
||||
|
@ -38,4 +37,4 @@ def test_basic(session):
|
|||
element = session.find.css("input", all=False)
|
||||
|
||||
result = get_element_rect(session, element.id)
|
||||
assert_success(result, retrieve_element_rect(session, element))
|
||||
assert_success(result, element_rect(session, element))
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success, assert_dialog_handled
|
||||
from tests.support.helpers import element_rect
|
||||
from tests.support.inline import inline
|
||||
|
||||
from . import retrieve_element_rect
|
||||
|
||||
|
||||
def get_element_rect(session, element_id):
|
||||
return session.transport.send(
|
||||
|
@ -27,7 +26,7 @@ def check_user_prompt_closed_without_exception(session, create_dialog):
|
|||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = get_element_rect(session, element.id)
|
||||
assert_success(response, retrieve_element_rect(session, element))
|
||||
assert_success(response, element_rect(session, element))
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import base64
|
||||
import imghdr
|
||||
import struct
|
||||
|
||||
from webdriver import Element, NoSuchAlertException, WebDriverException
|
||||
|
||||
|
|
|
@ -231,4 +231,3 @@ def closed_window(session, create_window):
|
|||
yield new_handle
|
||||
|
||||
session.window_handle = original_handle
|
||||
|
||||
|
|
|
@ -105,6 +105,34 @@ def clear_all_cookies(session):
|
|||
session.transport.send("DELETE", "session/%s/cookie" % session.session_id)
|
||||
|
||||
|
||||
def document_dimensions(session):
|
||||
return tuple(session.execute_script("""
|
||||
let {width, height} = document.documentElement.getBoundingClientRect();
|
||||
return [width, height];
|
||||
"""))
|
||||
|
||||
|
||||
def document_hidden(session):
|
||||
"""Polls for the document to become hidden."""
|
||||
def hidden(session):
|
||||
return session.execute_script("return document.hidden")
|
||||
return Poll(session, timeout=3, raises=None).until(hidden)
|
||||
|
||||
|
||||
def element_rect(session, element):
|
||||
return session.execute_script("""
|
||||
let element = arguments[0];
|
||||
let {height, left, top, width} = element.getBoundingClientRect();
|
||||
|
||||
return {
|
||||
x: left + window.pageXOffset,
|
||||
y: top + window.pageYOffset,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
""", args=(element,))
|
||||
|
||||
|
||||
def is_element_in_viewport(session, element):
|
||||
"""Check if element is outside of the viewport"""
|
||||
return session.execute_script("""
|
||||
|
@ -121,13 +149,6 @@ def is_element_in_viewport(session, element):
|
|||
""", args=(element,))
|
||||
|
||||
|
||||
def document_hidden(session):
|
||||
"""Polls for the document to become hidden."""
|
||||
def hidden(session):
|
||||
return session.execute_script("return document.hidden")
|
||||
return Poll(session, timeout=3, raises=None).until(hidden)
|
||||
|
||||
|
||||
def is_fullscreen(session):
|
||||
# At the time of writing, WebKit does not conform to the
|
||||
# Fullscreen API specification.
|
||||
|
@ -137,11 +158,3 @@ def is_fullscreen(session):
|
|||
return session.execute_script("""
|
||||
return !!(window.fullScreen || document.webkitIsFullScreen)
|
||||
""")
|
||||
|
||||
|
||||
def document_dimensions(session):
|
||||
return tuple(session.execute_script("""
|
||||
let {devicePixelRatio} = window;
|
||||
let {width, height} = document.documentElement.getBoundingClientRect();
|
||||
return [width * devicePixelRatio, height * devicePixelRatio];
|
||||
"""))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import base64
|
||||
import math
|
||||
import struct
|
||||
|
||||
from tests.support.asserts import assert_png
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
def element_rect(session, element):
|
||||
return session.execute_script("""
|
||||
let {devicePixelRatio} = window;
|
||||
let rect = arguments[0].getBoundingClientRect();
|
||||
|
||||
return {
|
||||
x: Math.floor((rect.left + window.pageXOffset) * devicePixelRatio),
|
||||
y: Math.floor((rect.top + window.pageYOffset) * devicePixelRatio),
|
||||
width: Math.floor(rect.width * devicePixelRatio),
|
||||
height: Math.floor(rect.height * devicePixelRatio),
|
||||
};
|
||||
""", args=(element,))
|
|
@ -1,9 +1,9 @@
|
|||
import base64
|
||||
import imghdr
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.asserts import assert_error, assert_png, assert_success
|
||||
from tests.support.image import png_dimensions
|
||||
from tests.support.inline import inline
|
||||
|
||||
from . import element_rect
|
||||
|
||||
|
||||
def take_element_screenshot(session, element_id):
|
||||
return session.transport.send(
|
||||
|
@ -20,17 +20,6 @@ def test_no_browsing_context(session, closed_window):
|
|||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_screenshot(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
|
||||
response = take_element_screenshot(session, element.id)
|
||||
value = assert_success(response)
|
||||
|
||||
image = base64.decodestring(value)
|
||||
assert imghdr.what("", image) == "png"
|
||||
|
||||
|
||||
def test_stale(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
|
@ -38,3 +27,15 @@ def test_stale(session):
|
|||
|
||||
result = take_element_screenshot(session, element.id)
|
||||
assert_error(result, "stale element reference")
|
||||
|
||||
|
||||
def test_format_and_dimensions(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
rect = element_rect(session, element)
|
||||
|
||||
response = take_element_screenshot(session, element.id)
|
||||
value = assert_success(response)
|
||||
|
||||
assert_png(value)
|
||||
assert png_dimensions(value) == (rect["width"], rect["height"])
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
# META: timeout=long
|
||||
|
||||
import base64
|
||||
import imghdr
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_success
|
||||
from tests.support.asserts import assert_png, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
|
@ -30,8 +27,7 @@ def check_user_prompt_not_closed_without_exception(session, create_dialog):
|
|||
response = take_element_screenshot(session, element.id)
|
||||
value = assert_success(response)
|
||||
|
||||
image = base64.decodestring(value)
|
||||
assert imghdr.what("", image) == "png"
|
||||
assert_png(value)
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
def document_dimensions(session):
|
||||
return tuple(session.execute_script("""
|
||||
let {devicePixelRatio} = window;
|
||||
let {width, height} = document.documentElement.getBoundingClientRect();
|
||||
return [Math.floor(width * devicePixelRatio), Math.floor(height * devicePixelRatio)];
|
||||
"""))
|
|
@ -1,9 +1,9 @@
|
|||
import base64
|
||||
import imghdr
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.asserts import assert_error, assert_png, assert_success
|
||||
from tests.support.image import png_dimensions
|
||||
from tests.support.inline import inline
|
||||
|
||||
from . import document_dimensions
|
||||
|
||||
|
||||
def take_screenshot(session):
|
||||
return session.transport.send(
|
||||
|
@ -15,11 +15,11 @@ def test_no_browsing_context(session, closed_window):
|
|||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_screenshot(session):
|
||||
def test_format_and_dimensions(session):
|
||||
session.url = inline("<input>")
|
||||
|
||||
response = take_screenshot(session)
|
||||
value = assert_success(response)
|
||||
|
||||
image = base64.decodestring(value)
|
||||
assert imghdr.what("", image) == "png"
|
||||
assert_png(value)
|
||||
assert png_dimensions(value) == document_dimensions(session)
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
# META: timeout=long
|
||||
|
||||
import base64
|
||||
import imghdr
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_success
|
||||
from tests.support.asserts import assert_png, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
|
@ -24,8 +21,7 @@ def check_user_prompt_not_closed_without_exception(session, create_dialog):
|
|||
response = take_screenshot(session)
|
||||
value = assert_success(response)
|
||||
|
||||
image = base64.decodestring(value)
|
||||
assert imghdr.what("", image) == "png"
|
||||
assert_png(value)
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue