Commit df4260b6 authored by Luke Zielinski's avatar Luke Zielinski Committed by Commit Bot

Roll internal WPT tools

This rolls up to d7d965cb51cb8a87ff9f87668f00b242e597d499

Major change is support for using mojo JS in tests

Change-Id: I0aea49dfc7c046a5a1d38accf029691548350e62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392408Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Luke Z <lpz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804964}
parent 7d86528b
...@@ -22,7 +22,7 @@ Local Modifications: None ...@@ -22,7 +22,7 @@ Local Modifications: None
Name: web-platform-tests - Test Suites for Web Platform specifications Name: web-platform-tests - Test Suites for Web Platform specifications
Short Name: wpt Short Name: wpt
URL: https://github.com/web-platform-tests/wpt/ URL: https://github.com/web-platform-tests/wpt/
Version: da260d2136bc4bec547fa7ebe98598d77e0f5841 Version: d7d965cb51cb8a87ff9f87668f00b242e597d499
License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html) License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html)
License File: wpt/wpt/LICENSE.md License File: wpt/wpt/LICENSE.md
Security Critical: no Security Critical: no
......
...@@ -9,7 +9,7 @@ cd $DIR ...@@ -9,7 +9,7 @@ cd $DIR
TARGET_DIR=$DIR/wpt TARGET_DIR=$DIR/wpt
REMOTE_REPO="https://github.com/web-platform-tests/wpt.git" REMOTE_REPO="https://github.com/web-platform-tests/wpt.git"
WPT_HEAD=da260d2136bc4bec547fa7ebe98598d77e0f5841 WPT_HEAD=d7d965cb51cb8a87ff9f87668f00b242e597d499
function clone { function clone {
# Remove existing repo if already exists. # Remove existing repo if already exists.
......
...@@ -198,6 +198,13 @@ def check_gitignore_file(repo_root, path): ...@@ -198,6 +198,13 @@ def check_gitignore_file(repo_root, path):
return [rules.GitIgnoreFile.error(path)] return [rules.GitIgnoreFile.error(path)]
def check_mojom_js(repo_root, path):
# type: (Text, Text) -> List[rules.Error]
if path.endswith(".mojom.js"):
return [rules.MojomJSFile.error(path)]
return []
def check_ahem_copy(repo_root, path): def check_ahem_copy(repo_root, path):
# type: (Text, Text) -> List[rules.Error] # type: (Text, Text) -> List[rules.Error]
lpath = path.lower() lpath = path.lower()
...@@ -997,8 +1004,9 @@ def lint(repo_root, paths, output_format, ignore_glob=None): ...@@ -997,8 +1004,9 @@ def lint(repo_root, paths, output_format, ignore_glob=None):
logger.info(line) logger.info(line)
return sum(itervalues(error_count)) return sum(itervalues(error_count))
path_lints = [check_file_type, check_path_length, check_worker_collision, check_ahem_copy, path_lints = [check_file_type, check_path_length, check_worker_collision, check_ahem_copy,
check_tentative_directories, check_gitignore_file] check_mojom_js, check_tentative_directories, check_gitignore_file]
all_paths_lints = [check_css_globally_unique, check_unique_testharness_basenames] all_paths_lints = [check_css_globally_unique, check_unique_testharness_basenames]
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata, file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata,
check_ahem_system_font] check_ahem_system_font]
......
...@@ -81,6 +81,18 @@ class GitIgnoreFile(Rule): ...@@ -81,6 +81,18 @@ class GitIgnoreFile(Rule):
description = ".gitignore found outside the root" description = ".gitignore found outside the root"
class MojomJSFile(Rule):
name = "MOJOM-JS"
description = "Don't check *.mojom.js files into WPT"
to_fix = """
Check if the file is already included in mojojs.zip:
https://source.chromium.org/chromium/chromium/src/+/master:chrome/tools/build/linux/FILES.cfg
If yes, use `loadMojoResources` from `resources/test-only-api.js` to load
it; if not, contact ecosystem-infra@chromium.org for adding new files
to mojojs.zip.
"""
class AhemCopy(Rule): class AhemCopy(Rule):
name = "AHEM COPY" name = "AHEM COPY"
description = "Don't add extra copies of Ahem, use /fonts/Ahem.ttf" description = "Don't add extra copies of Ahem, use /fonts/Ahem.ttf"
......
import os import os
import sys import sys
here = os.path.abspath(os.path.split(__file__)[0]) here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(here)) sys.path.insert(0, os.path.join(here))
sys.path.insert(0, os.path.join(here, "wptserve")) sys.path.insert(0, os.path.join(here, "wptserve"))
......
...@@ -427,6 +427,8 @@ class Session(object): ...@@ -427,6 +427,8 @@ class Session(object):
if self.session_id is not None: if self.session_id is not None:
return return
self.transport.close()
body = {"capabilities": {}} body = {"capabilities": {}}
if self.requested_capabilities is not None: if self.requested_capabilities is not None:
...@@ -452,6 +454,7 @@ class Session(object): ...@@ -452,6 +454,7 @@ class Session(object):
pass pass
finally: finally:
self.session_id = None self.session_id = None
self.transport.close()
def send_command(self, method, url, body=None, timeout=None): def send_command(self, method, url, body=None, timeout=None):
""" """
......
...@@ -560,10 +560,29 @@ class Chrome(Browser): ...@@ -560,10 +560,29 @@ class Chrome(Browser):
os.remove(installer_path) os.remove(installer_path)
return self.find_nightly_binary(dest) return self.find_nightly_binary(dest)
def install_mojojs(self, dest): def install_mojojs(self, dest, channel, browser_binary):
url = self._latest_chromium_snapshot_url() + "mojojs.zip" if channel == "nightly":
url = self._latest_chromium_snapshot_url() + "mojojs.zip"
else:
chrome_version = self.version(binary=browser_binary)
assert chrome_version, "Cannot determine the version of Chrome"
# Remove channel suffixes (e.g. " dev").
chrome_version = chrome_version.split(' ')[0]
url = "https://storage.googleapis.com/chrome-wpt-mojom/%s/linux64/mojojs.zip" % chrome_version
last_url_file = os.path.join(dest, "mojojs", "gen", "DOWNLOADED_FROM")
if os.path.exists(last_url_file):
with open(last_url_file, "rt") as f:
last_url = f.read().strip()
if last_url == url:
self.logger.info("Mojo bindings already up to date")
return
rmtree(os.path.join(dest, "mojojs", "gen"))
self.logger.info("Downloading Mojo bindings from %s" % url) self.logger.info("Downloading Mojo bindings from %s" % url)
unzip(get(url).raw, dest) unzip(get(url).raw, dest)
with open(last_url_file, "wt") as f:
f.write(url)
def _chromedriver_platform_string(self): def _chromedriver_platform_string(self):
platform = self.platforms.get(uname[0]) platform = self.platforms.get(uname[0])
......
...@@ -312,6 +312,7 @@ class FirefoxAndroid(BrowserSetup): ...@@ -312,6 +312,7 @@ class FirefoxAndroid(BrowserSetup):
class Chrome(BrowserSetup): class Chrome(BrowserSetup):
name = "chrome" name = "chrome"
browser_cls = browser.Chrome browser_cls = browser.Chrome
experimental_channels = ("dev", "canary", "nightly")
def setup_kwargs(self, kwargs): def setup_kwargs(self, kwargs):
browser_channel = kwargs["browser_channel"] browser_channel = kwargs["browser_channel"]
...@@ -321,9 +322,14 @@ class Chrome(BrowserSetup): ...@@ -321,9 +322,14 @@ class Chrome(BrowserSetup):
kwargs["binary"] = binary kwargs["binary"] = binary
else: else:
raise WptrunError("Unable to locate Chrome binary") raise WptrunError("Unable to locate Chrome binary")
if browser_channel == "nightly": # TODO(Hexcles): Enable this everywhere when Chrome 86 becomes stable.
if browser_channel in self.experimental_channels:
try: try:
self.browser.install_mojojs(self.venv.path) self.browser.install_mojojs(
dest=self.venv.path,
channel=browser_channel,
browser_binary=kwargs["binary"],
)
kwargs["enable_mojojs"] = True kwargs["enable_mojojs"] = True
logger.info("MojoJS enabled") logger.info("MojoJS enabled")
except Exception as e: except Exception as e:
...@@ -350,7 +356,7 @@ class Chrome(BrowserSetup): ...@@ -350,7 +356,7 @@ class Chrome(BrowserSetup):
kwargs["webdriver_binary"] = webdriver_binary kwargs["webdriver_binary"] = webdriver_binary
else: else:
raise WptrunError("Unable to locate or install chromedriver binary") raise WptrunError("Unable to locate or install chromedriver binary")
if browser_channel in ("dev", "canary", "nightly"): if browser_channel in self.experimental_channels:
logger.info("Automatically turning on experimental features for Chrome Dev/Canary or Chromium trunk") logger.info("Automatically turning on experimental features for Chrome Dev/Canary or Chromium trunk")
kwargs["binary_args"].append("--enable-experimental-web-platform-features") kwargs["binary_args"].append("--enable-experimental-web-platform-features")
# HACK(Hexcles): work around https://github.com/web-platform-tests/wpt/issues/16448 # HACK(Hexcles): work around https://github.com/web-platform-tests/wpt/issues/16448
......
...@@ -197,7 +197,7 @@ class FileHandler(object): ...@@ -197,7 +197,7 @@ class FileHandler(object):
raise HTTPException(404) raise HTTPException(404)
def get_headers(self, request, path): def get_headers(self, request, path):
rv = (self.load_headers(request, os.path.join(os.path.split(path)[0], "__dir__")) + rv = (self.load_headers(request, os.path.join(os.path.dirname(path), "__dir__")) +
self.load_headers(request, path)) self.load_headers(request, path))
if not any(key.lower() == b"content-type" for (key, _) in rv): if not any(key.lower() == b"content-type" for (key, _) in rv):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment