diff --git a/docs/writing-tests/testdriver.md b/docs/writing-tests/testdriver.md index ca24a345beb58c..c2787b6be90db4 100644 --- a/docs/writing-tests/testdriver.md +++ b/docs/writing-tests/testdriver.md @@ -38,7 +38,7 @@ The api in `test_driver.bidi` provides access to the ### Markup ### -To use WebDriver BiDi, enable the `bidi` feature in `testdriver.js` by adding +To use WebDriver BiDi, enable the `bidi` feature in `testdriver.js` by adding the `feature=bidi` query string parameter. Details are in [RFC 214: Add testdriver features](https://github.com/web-platform-tests/rfcs/blob/master/rfcs/testdriver-features.md). ```html diff --git a/tools/lint/lint.py b/tools/lint/lint.py index 9447bb3f914639..1228d546e01ac6 100644 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -524,16 +524,23 @@ def check_parsed(repo_root: Text, path: Text, f: IO[bytes]) -> List[rules.Error] src = element.attrib["src"] def is_path_correct(script: Text, src: Text) -> bool: + """ + If the `src` relevant to the `script`, check that the `src` is the + correct path for `script`. + :param script: the script name to check the `src` for. + :param src: the included path. + :return: if the `src` irrelevant to the `script`, or if the `src` + path is the correct path. + """ if script == src: # The src does not provide the full path. return False if "/%s" % script not in src: - # The src is not related to the script. + # The src is not relevant to the script. return True - return src == "/resources/%s" % script or ("%s" % src).startswith( - "/resources/%s?" % script) + return ("%s" % src).startswith("/resources/%s" % script) def is_query_string_correct(script: Text, src: Text, allowed_query_string_params: Dict[str, List[str]]) -> bool: @@ -553,7 +560,7 @@ def is_query_string_correct(script: Text, src: Text, allowed parameter names and values are lists of allowed values for each parameter. - :return: if the query string does not contain any not-allowed + :return: if the query string is empty or contains only allowed params. """ if not ("%s" % src).startswith("/resources/%s?" % script): @@ -569,10 +576,6 @@ def is_query_string_correct(script: Text, src: Text, return False for param_name in query_string_params: - if ':' in param_name: - # Allow for vendor-specific query parameters. - continue - if param_name not in allowed_query_string_params: return False diff --git a/tools/lint/rules.py b/tools/lint/rules.py index c86f3943500ffc..6f3bacf49b99d5 100644 --- a/tools/lint/rules.py +++ b/tools/lint/rules.py @@ -276,7 +276,7 @@ class TestdriverPath(Rule): class TestdriverUnsupportedQueryParameter(Rule): name = "TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER" - description = "testdriver.js script seen with incorrect query parameters" + description = "testdriver.js script seen with unsupported query parameters" class TestdriverVendorPath(Rule): diff --git a/tools/lint/tests/test_file_lints.py b/tools/lint/tests/test_file_lints.py index 1ede163fad8f50..92270e38a69d70 100644 --- a/tools/lint/tests/test_file_lints.py +++ b/tools/lint/tests/test_file_lints.py @@ -508,7 +508,7 @@ def test_testdriver_unsupported_query_param(): if kind in ["web-lax", "web-strict"]: assert errors == [ ("TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER", - "testdriver.js script seen with incorrect query parameters", + "testdriver.js script seen with unsupported query parameters", filename, None), ] elif kind == "python": @@ -532,7 +532,11 @@ def test_testdriver_vendor_query_param(): check_errors(errors) if kind in ["web-lax", "web-strict"]: - assert errors == [] + assert errors == [ + ('TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER', + 'testdriver.js script seen with unsupported query parameters', + filename, None) + ] elif kind == "python": assert errors == [ ("PARSE-FAILED", "Unable to parse file", filename, 2), @@ -556,7 +560,7 @@ def test_testdriver_unsupported_feature(): if kind in ["web-lax", "web-strict"]: assert errors == [ ("TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER", - "testdriver.js script seen with incorrect query parameters", + "testdriver.js script seen with unsupported query parameters", filename, None), ] elif kind == "python": @@ -565,7 +569,7 @@ def test_testdriver_unsupported_feature(): ] -def test_testdriver_multiple_unsupported_features(): +def test_testdriver_multiple_with_unsupported_features(): code = b""" @@ -582,7 +586,7 @@ def test_testdriver_multiple_unsupported_features(): if kind == "web-lax": assert errors == [ ('TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER', - 'testdriver.js script seen with incorrect query parameters', + 'testdriver.js script seen with unsupported query parameters', filename, None) ] elif kind == "python": @@ -660,7 +664,7 @@ def test_testdriver_unsupported_empty_feature(): if kind in ["web-lax", "web-strict"]: assert errors == [ ("TESTDRIVER-UNSUPPORTED-QUERY-PARAMETER", - "testdriver.js script seen with incorrect query parameters", + "testdriver.js script seen with unsupported query parameters", filename, None), ] elif kind == "python":