Skip to content

Commit

Permalink
Bug 1513880 [wpt PR 14496] - Revert "Make testharness tests run in a …
Browse files Browse the repository at this point in the history
…top-level browsing context", a=testonly

Automatic update from web-platform-tests
Revert "Make testharness tests run in a top-level browsing context" (#14496)

This reverts commit 74522a275bea481821e789145578e9e16fd27be3.

Fixes web-platform-tests/wpt#14495.

Reopens web-platform-tests/wpt#13418.
--

wpt-commits: 9377b490049c9af88ea0261ad3b92757733e8e95
wpt-pr: 14496


--HG--
rename : testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/base.py => testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/base.py.orig
rename : testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/sauce.py => testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/sauce.py.orig
  • Loading branch information
moz-wptsync-bot authored and jgraham committed Jan 23, 2019
1 parent 7e332a5 commit d71eda9
Show file tree
Hide file tree
Showing 31 changed files with 1,845 additions and 365 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def inherit(super_module, child_globals, product_name):
child_wptrunner["product"] = product_name

for k in ("check_args", "browser", "browser_kwargs", "executor_kwargs",
"env_extras", "env_options", "timeout_multiplier"):
"env_extras", "env_options"):
attr = super_wptrunner[k]
child_globals[attr] = getattr(super_module, attr)

Expand Down Expand Up @@ -81,13 +81,6 @@ def get_free_port(start_port, exclude=None):
finally:
s.close()


def get_timeout_multiplier(test_type, run_info_data, **kwargs):
if kwargs["timeout_multiplier"] is not None:
return kwargs["timeout_multiplier"]
return 1


def browser_command(binary, args, debug_info):
if debug_info:
if debug_info.requiresEscapedArgs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import os
import platform
import socket
from abc import ABCMeta, abstractmethod
from copy import deepcopy

from ..wptcommandline import require_arg # noqa: F401

here = os.path.split(__file__)[0]


def inherit(super_module, child_globals, product_name):
super_wptrunner = super_module.__wptrunner__
child_globals["__wptrunner__"] = child_wptrunner = deepcopy(super_wptrunner)

child_wptrunner["product"] = product_name

for k in ("check_args", "browser", "browser_kwargs", "executor_kwargs",
"env_extras", "env_options", "timeout_multiplier"):
attr = super_wptrunner[k]
child_globals[attr] = getattr(super_module, attr)

for v in super_module.__wptrunner__["executor"].values():
child_globals[v] = getattr(super_module, v)

if "run_info_extras" in super_wptrunner:
attr = super_wptrunner["run_info_extras"]
child_globals[attr] = getattr(super_module, attr)


def cmd_arg(name, value=None):
prefix = "-" if platform.system() == "Windows" else "--"
rv = prefix + name


def inherit(super_module, child_globals, product_name):
super_wptrunner = super_module.__wptrunner__
child_globals["__wptrunner__"] = child_wptrunner = deepcopy(super_wptrunner)

child_wptrunner["product"] = product_name

for k in ("check_args", "browser", "browser_kwargs", "executor_kwargs",
"env_extras", "env_options"):
attr = super_wptrunner[k]
child_globals[attr] = getattr(super_module, attr)

for v in super_module.__wptrunner__["executor"].values():
child_globals[v] = getattr(super_module, v)

if "run_info_extras" in super_wptrunner:
attr = super_wptrunner["run_info_extras"]
child_globals[attr] = getattr(super_module, attr)


def cmd_arg(name, value=None):
prefix = "-" if platform.system() == "Windows" else "--"
rv = prefix + name
if value is not None:
rv += "=" + value
return rv


def get_free_port(start_port, exclude=None):
"""Get the first port number after start_port (inclusive) that is
not currently bound.

:param start_port: Integer port number at which to start testing.
:param exclude: Set of port numbers to skip"""
port = start_port
while True:
if exclude and port in exclude:
port += 1
continue
s = socket.socket()
try:
s.bind(("127.0.0.1", port))
except socket.error:
port += 1
else:
return port
finally:
s.close()


def get_timeout_multiplier(test_type, run_info_data, **kwargs):
if kwargs["timeout_multiplier"] is not None:
return kwargs["timeout_multiplier"]
return 1


def browser_command(binary, args, debug_info):
if debug_info:
if debug_info.requiresEscapedArgs:
args = [item.replace("&", "\\&") for item in args]
debug_args = [debug_info.path] + debug_info.args
else:
debug_args = []

command = [binary] + args

return debug_args, command


class BrowserError(Exception):
pass


class Browser(object):
__metaclass__ = ABCMeta

process_cls = None
init_timeout = 30

def __init__(self, logger):
"""Abstract class serving as the basis for Browser implementations.

The Browser is used in the TestRunnerManager to start and stop the browser
process, and to check the state of that process. This class also acts as a
context manager, enabling it to do browser-specific setup at the start of
the testrun and cleanup after the run is complete.

:param logger: Structured logger to use for output.
"""
self.logger = logger

def __enter__(self):
self.setup()
return self

def __exit__(self, *args, **kwargs):
self.cleanup()

def setup(self):
"""Used for browser-specific setup that happens at the start of a test run"""
pass

def settings(self, test):
return {}

@abstractmethod
def start(self, group_metadata, **kwargs):
"""Launch the browser object and get it into a state where is is ready to run tests"""
pass

@abstractmethod
def stop(self, force=False):
"""Stop the running browser process."""
pass

@abstractmethod
def pid(self):
"""pid of the browser process or None if there is no pid"""
pass

@abstractmethod
def is_alive(self):
"""Boolean indicating whether the browser process is still running"""
pass

def setup_ssl(self, hosts):
"""Return a certificate to use for tests requiring ssl that will be trusted by the browser"""
raise NotImplementedError("ssl testing not supported")

def cleanup(self):
"""Browser-specific cleanup that is run after the testrun is finished"""
pass

def executor_browser(self):
"""Returns the ExecutorBrowser subclass for this Browser subclass and the keyword arguments
with which it should be instantiated"""
return ExecutorBrowser, {}

def check_crash(self, process, test):
"""Check if a crash occured and output any useful information to the
log. Returns a boolean indicating whether a crash occured."""
return False


class NullBrowser(Browser):
def __init__(self, logger, **kwargs):
super(NullBrowser, self).__init__(logger)

def start(self, **kwargs):
"""No-op browser to use in scenarios where the TestRunnerManager shouldn't
actually own the browser process (e.g. Servo where we start one browser
per test)"""
pass

def stop(self, force=False):
pass

def pid(self):
return None

def is_alive(self):
return True

def on_output(self, line):
raise NotImplementedError


class ExecutorBrowser(object):
def __init__(self, **kwargs):
"""View of the Browser used by the Executor object.
This is needed because the Executor runs in a child process and
we can't ship Browser instances between processes on Windows.

Typically this will have a few product-specific properties set,
but in some cases it may have more elaborate methods for setting
up the browser from the runner process.
"""
for k, v in kwargs.iteritems():
setattr(self, k, v)
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..webdriver_server import ChromeDriverServer
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
Expand All @@ -16,8 +15,7 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier",}
"env_options": "env_options"}


def check_args(**kwargs):
Expand All @@ -36,7 +34,6 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
cache_manager, run_info_data,
**kwargs)
executor_kwargs["close_after_done"] = True
executor_kwargs["supports_eager_pageload"] = False

capabilities = {
"goog:chromeOptions": {
Expand All @@ -51,9 +48,6 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
}
}

if test_type == "testharness":
capabilities["pageLoadStrategy"] = "none"

for (kwarg, capability) in [("binary", "binary"), ("binary_args", "args")]:
if kwargs[kwarg] is not None:
capabilities["goog:chromeOptions"][capability] = kwargs[kwarg]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import subprocess

from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..webdriver_server import ChromeDriverServer
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorselenium import (SeleniumTestharnessExecutor, # noqa: F401
Expand All @@ -18,8 +17,7 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}
"env_options": "env_options"}

_wptserve_ports = set()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}

"env_options": "env_options"}

def get_timeout_multiplier(test_type, run_info_data, **kwargs):
if kwargs["timeout_multiplier"] is not None:
Expand All @@ -25,19 +23,16 @@ def get_timeout_multiplier(test_type, run_info_data, **kwargs):
return 10
return 1


def check_args(**kwargs):
require_arg(kwargs, "webdriver_binary")


def browser_kwargs(test_type, run_info_data, config, **kwargs):
return {"webdriver_binary": kwargs["webdriver_binary"],
"webdriver_args": kwargs.get("webdriver_args"),
"timeout_multiplier": get_timeout_multiplier(test_type,
run_info_data,
**kwargs)}


def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs):
executor_kwargs = base_executor_kwargs(test_type, server_config,
Expand All @@ -47,19 +42,14 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
run_info_data,
**kwargs)
executor_kwargs["capabilities"] = {}
if test_type == "testharness":
executor_kwargs["capabilities"]["pageLoadStrategy"] = "eager"
return executor_kwargs


def env_extras(**kwargs):
return []


def env_options():
return {"supports_debugger": False}


class EdgeBrowser(Browser):
used_ports = set()
init_timeout = 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"update_properties": "update_properties",
"timeout_multiplier": "get_timeout_multiplier"}

"update_properties": "update_properties"}


def check_args(**kwargs):
Expand Down
Loading

0 comments on commit d71eda9

Please sign in to comment.