Skip to content

Commit

Permalink
Merge branch 'always-do-full-taskcluster-runs' into wptrunner_tlbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Bjerring committed Nov 7, 2018
2 parents 0e5347a + 3a8bdb8 commit 3d0c723
Show file tree
Hide file tree
Showing 24 changed files with 243 additions and 87 deletions.
4 changes: 1 addition & 3 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tasks:
$map:
$flatten:
$match: {
event.ref == "refs/heads/master": [{name: firefox, channel: nightly}, {name: chrome, channel: dev}],
event.ref == "refs/heads/epochs/daily": [{name: firefox, channel: stable}, {name: chrome, channel: stable}],
event.ref == "refs/heads/epochs/weekly": [{name: firefox, channel: beta}, {name: chrome, channel: beta}]
True: [{name: firefox, channel: nightly}, {name: chrome, channel: dev}]
}
each(browser):
$map:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<body>
<html>
<head>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script src=/feature-policy/resources/featurepolicy.js></script>
<!-- Feature-Policy: fullscreen *; -->
<script>
Expand Down Expand Up @@ -143,3 +147,4 @@
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<body>
<html>
<head>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script src=/feature-policy/resources/featurepolicy.js></script>
<!-- Feature-Policy: fullscreen 'self'; -->
<script>
Expand Down Expand Up @@ -177,3 +181,4 @@
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<body>
<html>
<head>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script src=/feature-policy/resources/featurepolicy.js></script>
<!-- Feature-Policy: fullscreen 'self' cross_origin https://www.example.com; -->
<script>
Expand Down Expand Up @@ -184,3 +188,4 @@
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<body>
<html>
<head>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script src=/feature-policy/resources/featurepolicy.js></script>
<!-- Feature-Policy: fullscreen 'none'; -->
<script>
Expand Down Expand Up @@ -143,3 +147,4 @@
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var prefixedMessage = new PrefixedMessageResource();
var max = 50, attempts = 0;
var max = 150, attempts = 0;
function sendCoordinates() {
// Certain windowing systems position windows asynchronously.
// As a result, the window may not be positioned yet when the
// load event fires. To accommodate this, allow waiting up to
// 5 seconds for positioning to take place.
// 15 seconds for positioning to take place.
if (!window.screenX && !window.screenY && ++attempts < max) {
setTimeout(sendCoordinates, 100);
return;
Expand Down
18 changes: 9 additions & 9 deletions tools/wptrunner/wptrunner/browsers/webkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ def browser_kwargs(test_type, run_info_data, config, **kwargs):


def capabilities_for_port(server_config, **kwargs):
if kwargs["webkit_port"] == "gtk":
capabilities = {
port_name = kwargs["webkit_port"]
if port_name in ["gtk", "wpe"]:
port_key_map = {"gtk": "webkitgtk"}
browser_options_port = port_key_map.get(port_name, port_name)
browser_options_key = "%s:browserOptions" % browser_options_port

return {
"browserName": "MiniBrowser",
"browserVersion": "2.20",
"platformName": "ANY",
"webkitgtk:browserOptions": {
browser_options_key: {
"binary": kwargs["binary"],
"args": kwargs.get("binary_args", []),
"certificates": [
{"host": server_config["browser_host"],
"certificateFile": kwargs["host_cert_path"]}
]
}
}

return capabilities
"certificateFile": kwargs["host_cert_path"]}]}}

return {}

Expand Down
53 changes: 50 additions & 3 deletions tools/wptrunner/wptrunner/formatters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
import json
import re
import sys

from mozlog.structured.formatters.base import BaseFormatter


LONE_SURROGATE_RE = re.compile(u"[\uD800-\uDFFF]")


def surrogate_replacement_ucs4(match):
return "U+" + hex(ord(match.group()))[2:]


class SurrogateReplacementUcs2(object):
def __init__(self):
self.skip = False

def __call__(self, match):
char = match.group()

if self.skip:
self.skip = False
return char

is_low = 0xD800 <= ord(char) <= 0xDBFF

escape = True
if is_low:
next_idx = match.end()
if next_idx < len(match.string):
next_char = match.string[next_idx]
if 0xDC00 <= ord(next_char) <= 0xDFFF:
escape = False

if not escape:
self.skip = True
return char

return "U+" + hex(ord(match.group()))[2:]


if sys.maxunicode == 0x10FFFF:
surrogate_replacement = surrogate_replacement_ucs4
else:
surrogate_replacement = SurrogateReplacementUcs2()


def replace_lone_surrogate(data):
return LONE_SURROGATE_RE.subn(surrogate_replacement, data)[0]


class WptreportFormatter(BaseFormatter):
"""Formatter that produces results in the format that wpreport expects."""

Expand Down Expand Up @@ -40,7 +87,7 @@ def test_start(self, data):

def create_subtest(self, data):
test = self.find_or_create_test(data)
subtest_name = data["subtest"]
subtest_name = replace_lone_surrogate(data["subtest"])

subtest = {
"name": subtest_name,
Expand All @@ -57,7 +104,7 @@ def test_status(self, data):
if "expected" in data:
subtest["expected"] = data["expected"]
if "message" in data:
subtest["message"] = data["message"]
subtest["message"] = replace_lone_surrogate(data["message"])

def test_end(self, data):
test = self.find_or_create_test(data)
Expand All @@ -67,7 +114,7 @@ def test_end(self, data):
if "expected" in data:
test["expected"] = data["expected"]
if "message" in data:
test["message"] = data["message"]
test["message"] = replace_lone_surrogate(data["message"])

def assertion_count(self, data):
test = self.find_or_create_test(data)
Expand Down
73 changes: 73 additions & 0 deletions tools/wptrunner/wptrunner/tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
from os.path import dirname, join
from StringIO import StringIO

import mock

from mozlog import handlers, structuredlog

sys.path.insert(0, join(dirname(__file__), "..", ".."))

from wptrunner import formatters
from wptrunner.formatters import WptreportFormatter


Expand Down Expand Up @@ -62,3 +65,73 @@ def test_wptreport_run_info_optional(capfd):
output.seek(0)
output_obj = json.load(output)
assert "run_info" not in output_obj or output_obj["run_info"] == {}


def test_wptreport_lone_surrogate(capfd):
output = StringIO()
logger = structuredlog.StructuredLogger("test_a")
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))

# output a bunch of stuff
logger.suite_start(["test-id-1"]) # no run_info arg!
logger.test_start("test-id-1")
logger.test_status("test-id-1",
subtest=u"Name with surrogate\uD800",
status="FAIL",
message=u"\U0001F601 \uDE0A\uD83D")
logger.test_end("test-id-1",
status="PASS",
message=u"\uDE0A\uD83D \U0001F601")
logger.suite_end()

# check nothing got output to stdout/stderr
# (note that mozlog outputs exceptions during handling to stderr!)
captured = capfd.readouterr()
assert captured.out == ""
assert captured.err == ""

# check the actual output of the formatter
output.seek(0)
output_obj = json.load(output)
test = output_obj["results"][0]
assert test["message"] == u"U+de0aU+d83d \U0001F601"
subtest = test["subtests"][0]
assert subtest["name"] == u"Name with surrogateU+d800"
assert subtest["message"] == u"\U0001F601 U+de0aU+d83d"


def test_wptreport_lone_surrogate_ucs2(capfd):
# Since UCS4 is a superset of UCS2 we can meaningfully test the UCS2 code on a
# UCS4 build, but not the reverse. However UCS2 is harder to handle and UCS4 is
# the commonest (and sensible) configuration, so that's OK.
output = StringIO()
logger = structuredlog.StructuredLogger("test_a")
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))

with mock.patch.object(formatters, 'surrogate_replacement', formatters.SurrogateReplacementUcs2()):
# output a bunch of stuff
logger.suite_start(["test-id-1"]) # no run_info arg!
logger.test_start("test-id-1")
logger.test_status("test-id-1",
subtest=u"Name with surrogate\uD800",
status="FAIL",
message=u"\U0001F601 \uDE0A\uD83D \uD83D\uDE0A")
logger.test_end("test-id-1",
status="PASS",
message=u"\uDE0A\uD83D \uD83D\uDE0A \U0001F601")
logger.suite_end()

# check nothing got output to stdout/stderr
# (note that mozlog outputs exceptions during handling to stderr!)
captured = capfd.readouterr()
assert captured.out == ""
assert captured.err == ""

# check the actual output of the formatter
output.seek(0)
output_obj = json.load(output)
test = output_obj["results"][0]
assert test["message"] == u"U+de0aU+d83d \U0001f60a \U0001F601"
subtest = test["subtests"][0]
assert subtest["name"] == u"Name with surrogateU+d800"
assert subtest["message"] == u"\U0001F601 U+de0aU+d83d \U0001f60a"
11 changes: 1 addition & 10 deletions webdriver/tests/get_element_rect/__init__.py
Original file line number Diff line number Diff line change
@@ -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,))

5 changes: 2 additions & 3 deletions webdriver/tests/get_element_rect/get.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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))
5 changes: 2 additions & 3 deletions webdriver/tests/get_element_rect/user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -27,7 +26,7 @@ def check_user_prompt_closed_without_exception(dialog_type, retval):
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)

Expand Down
1 change: 1 addition & 0 deletions webdriver/tests/support/asserts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
import imghdr
import struct

from webdriver import Element, NoSuchAlertException, WebDriverException

Expand Down
1 change: 0 additions & 1 deletion webdriver/tests/support/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,3 @@ def closed_window(session, create_window):
yield new_handle

session.window_handle = original_handle

Loading

0 comments on commit 3d0c723

Please sign in to comment.