Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testharness tests run in a top-level browsing context #13966

Merged
merged 3 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/css-conditional/test_group_insertRule.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@media print {}
</style>
</head>
<body onload="run()">
<body>
<div id=log></div>
<div id="test"></div>
<script>
Expand Down
2 changes: 1 addition & 1 deletion css/css-transitions/currentcolor-animation-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="/resources/testharnessreport.js"></script>
<style id="style"></style>
</head>
<body onload="run()">
<body>
<div id=log></div>
<div id="test"></div>
<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
onload = opener.t.step_func_done(function() {
document.write("<body>Filler Text<div id='log'></div>");
opener.assert_equals(document.body.textContent, "Filler Text");
});
</script>
<body>FAIL
18 changes: 7 additions & 11 deletions html/webappapis/dynamic-markup-insertion/document-write/047.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<!doctype html>
<title>document.write</title>
<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test();
onload = function() {
t.step(function() {
document.write("<body>Filler Text<div id='log'></div>");
assert_equals(document.body.textContent, "Filler Text");
});
t.done();
};
var win;
var t = async_test(() => {
win = window.open("047-1.html");
});
t.add_cleanup(() => win.close());
</script>
<body>FAIL
<div id="log"></div>
15 changes: 0 additions & 15 deletions html/webappapis/dynamic-markup-insertion/document-write/048.html

This file was deleted.

9 changes: 8 additions & 1 deletion tools/wptrunner/wptrunner/browsers/base.py
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"):
"env_extras", "env_options", "timeout_multiplier"):
attr = super_wptrunner[k]
child_globals[attr] = getattr(super_module, attr)

Expand Down Expand Up @@ -57,6 +57,13 @@ 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
8 changes: 7 additions & 1 deletion tools/wptrunner/wptrunner/browsers/chrome.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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 @@ -15,7 +16,8 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier",}


def check_args(**kwargs):
Expand All @@ -34,6 +36,7 @@ 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 = {
"browserName": "chrome",
Expand All @@ -51,6 +54,9 @@ 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
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/chrome_android.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -17,7 +18,8 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}

_wptserve_ports = set()

Expand Down
12 changes: 11 additions & 1 deletion tools/wptrunner/wptrunner/browsers/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}


def get_timeout_multiplier(test_type, run_info_data, **kwargs):
if kwargs["timeout_multiplier"] is not None:
Expand All @@ -23,16 +25,19 @@ 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 @@ -42,14 +47,19 @@ 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
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/fennec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"update_properties": "update_properties"}
"update_properties": "update_properties",
"timeout_multiplier": "get_timeout_multiplier"}


class FennecProfile(FirefoxProfile):
# WPT-specific prefs are set in FennecBrowser.start()
Expand Down
5 changes: 4 additions & 1 deletion tools/wptrunner/wptrunner/browsers/firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras",
"update_properties": "update_properties"}
"update_properties": "update_properties",
"timeout_multiplier": "get_timeout_multiplier"}


def get_timeout_multiplier(test_type, run_info_data, **kwargs):
Expand Down Expand Up @@ -98,6 +99,8 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
**kwargs)
executor_kwargs["e10s"] = run_info_data["e10s"]
capabilities = {}
if test_type == "testharness":
capabilities["pageLoadStrategy"] = "eager"
if test_type == "reftest":
executor_kwargs["reftest_internal"] = kwargs["reftest_internal"]
executor_kwargs["reftest_screenshot"] = kwargs["reftest_screenshot"]
Expand Down
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/ie.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..webdriver_server import InternetExplorerDriverServer
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorselenium import (SeleniumTestharnessExecutor, # noqa: F401
Expand All @@ -14,7 +15,8 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}


def check_args(**kwargs):
Expand Down
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/opera.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..webdriver_server import OperaDriverServer
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorselenium import (SeleniumTestharnessExecutor, # noqa: F401
Expand All @@ -15,7 +16,8 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}


def check_args(**kwargs):
Expand Down
6 changes: 5 additions & 1 deletion tools/wptrunner/wptrunner/browsers/safari.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..webdriver_server import SafariDriverServer
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorselenium import (SeleniumTestharnessExecutor, # noqa: F401
Expand All @@ -15,7 +16,8 @@
"browser_kwargs": "browser_kwargs",
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options"}
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier"}


def check_args(**kwargs):
Expand All @@ -33,6 +35,8 @@ 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["capabilities"] = {}
if test_type == "testharness":
executor_kwargs["capabilities"]["pageLoadStrategy"] = "eager"
if kwargs["binary"] is not None:
raise ValueError("Safari doesn't support setting executable location")

Expand Down
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/sauce.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import requests

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


def get_capabilities(**kwargs):
Expand Down
2 changes: 2 additions & 0 deletions tools/wptrunner/wptrunner/browsers/servo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from .base import NullBrowser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorservo import ServoTestharnessExecutor, ServoRefTestExecutor, ServoWdspecExecutor # noqa: F401

Expand All @@ -19,6 +20,7 @@
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier",
"update_properties": "update_properties",
}

Expand Down
2 changes: 2 additions & 0 deletions tools/wptrunner/wptrunner/browsers/servodriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tools.serve.serve import make_hosts_file

from .base import Browser, require_arg, get_free_port, browser_command, ExecutorBrowser
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorservodriver import (ServoWebDriverTestharnessExecutor, # noqa: F401
ServoWebDriverRefTestExecutor) # noqa: F401
Expand All @@ -25,6 +26,7 @@
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"timeout_multiplier": "get_timeout_multiplier",
"update_properties": "update_properties",
}

Expand Down
4 changes: 3 additions & 1 deletion tools/wptrunner/wptrunner/browsers/webkit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base import Browser, ExecutorBrowser, require_arg
from .base import get_timeout_multiplier # noqa: F401
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, # noqa: F401
WebDriverRefTestExecutor) # noqa: F401
Expand All @@ -16,7 +17,8 @@
"executor_kwargs": "executor_kwargs",
"env_extras": "env_extras",
"env_options": "env_options",
"run_info_extras": "run_info_extras"}
"run_info_extras": "run_info_extras",
"timeout_multiplier": "get_timeout_multiplier"}


def check_args(**kwargs):
Expand Down
8 changes: 6 additions & 2 deletions tools/wptrunner/wptrunner/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ class TestEnvironmentError(Exception):


class TestEnvironment(object):
def __init__(self, test_paths, pause_after_test, debug_info, options, ssl_config, env_extras):
def __init__(self, test_paths, testharness_timeout_multipler, pause_after_test, debug_info, options, ssl_config, env_extras):
"""Context manager that owns the test environment i.e. the http and
websockets servers"""
self.test_paths = test_paths
self.server = None
self.config_ctx = None
self.config = None
self.testharness_timeout_multipler = testharness_timeout_multipler
self.pause_after_test = pause_after_test
self.test_server_port = options.pop("test_server_port", True)
self.debug_info = debug_info
Expand Down Expand Up @@ -169,7 +170,10 @@ def get_routes(self):
for path, format_args, content_type, route in [
("testharness_runner.html", {}, "text/html", "/testharness_runner.html"),
(self.options.get("testharnessreport", "testharnessreport.js"),
{"output": self.pause_after_test}, "text/javascript;charset=utf8",
{"output": self.pause_after_test,
"timeout_multiplier": self.testharness_timeout_multipler,
"explicit_timeout": "true" if self.debug_info is not None else "false"},
"text/javascript;charset=utf8",
"/resources/testharnessreport.js")]:
path = os.path.normpath(os.path.join(here, path))
# Note that .headers. files don't apply to static routes, so we need to
Expand Down
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def __call__(self, result):
return callback(url, payload)

def process_complete(self, url, payload):
rv = [url] + payload
rv = [strip_server(url)] + payload
return True, rv

def process_action(self, url, payload):
Expand Down
Loading