Do not include test path in test metadata (#37949)

* Use base test name to get expected metadata

With this change, expectation data for tests will be keyed by the
base test name, instead of the test id which also contains the test path
relative to the test root. In the file system metadata file only keeps
the base test name.
diff --git a/tools/wpt/tests/test_update_expectations.py b/tools/wpt/tests/test_update_expectations.py
index a278cb1..92022e9 100644
--- a/tools/wpt/tests/test_update_expectations.py
+++ b/tools/wpt/tests/test_update_expectations.py
@@ -115,16 +115,14 @@
 
     firefox_expected = manifestexpected.get_manifest(metadata_path,
                                                      test_path,
-                                                     "/",
                                                      run_info_firefox)
     # Default expected isn't stored
     with pytest.raises(KeyError):
-        assert firefox_expected.get_test(test_id).get("expected")
-    assert firefox_expected.get_test(test_id).get_subtest(subtest_name).expected == "FAIL"
+        assert firefox_expected.get_test(test_id.rpartition('/')[-1]).get("expected")
+    assert firefox_expected.get_test(test_id.rpartition('/')[-1]).get_subtest(subtest_name).expected == "FAIL"
 
     chrome_expected = manifestexpected.get_manifest(metadata_path,
                                                     test_path,
-                                                    "/",
                                                     run_info_chrome)
-    assert chrome_expected.get_test(test_id).expected == "ERROR"
-    assert chrome_expected.get_test(test_id).get_subtest(subtest_name).expected == "NOTRUN"
+    assert chrome_expected.get_test(test_id.rpartition('/')[-1]).expected == "ERROR"
+    assert chrome_expected.get_test(test_id.rpartition('/')[-1]).get_subtest(subtest_name).expected == "NOTRUN"
diff --git a/tools/wptrunner/wptrunner/manifestexpected.py b/tools/wptrunner/wptrunner/manifestexpected.py
index 0d92a48..51ce343 100644
--- a/tools/wptrunner/wptrunner/manifestexpected.py
+++ b/tools/wptrunner/wptrunner/manifestexpected.py
@@ -1,8 +1,6 @@
 # mypy: allow-untyped-defs
 
-import os
 from collections import deque
-from urllib.parse import urljoin
 
 from .wptmanifest.backends import static
 from .wptmanifest.backends.base import ManifestItem
@@ -222,26 +220,22 @@
 
 
 class ExpectedManifest(ManifestItem):
-    def __init__(self, node, test_path, url_base):
+    def __init__(self, node, test_path):
         """Object representing all the tests in a particular manifest
 
         :param name: Name of the AST Node associated with this object.
                      Should always be None since this should always be associated with
                      the root node of the AST.
         :param test_path: Path of the test file associated with this manifest.
-        :param url_base: Base url for serving the tests in this manifest
         """
         name = node.data
         if name is not None:
             raise ValueError("ExpectedManifest should represent the root node")
         if test_path is None:
             raise ValueError("ExpectedManifest requires a test path")
-        if url_base is None:
-            raise ValueError("ExpectedManifest requires a base url")
         ManifestItem.__init__(self, node)
         self.child_map = {}
         self.test_path = test_path
-        self.url_base = url_base
 
     def append(self, child):
         """Add a test to the manifest"""
@@ -260,11 +254,6 @@
         return self.child_map.get(test_id)
 
     @property
-    def url(self):
-        return urljoin(self.url_base,
-                       "/".join(self.test_path.split(os.path.sep)))
-
-    @property
     def disabled(self):
         return bool_prop("disabled", self)
 
@@ -413,7 +402,7 @@
 
     @property
     def id(self):
-        return urljoin(self.parent.url, self.name)
+        return self.name
 
     @property
     def disabled(self):
@@ -503,13 +492,12 @@
         return True
 
 
-def get_manifest(metadata_root, test_path, url_base, run_info):
+def get_manifest(metadata_root, test_path, run_info):
     """Get the ExpectedManifest for a particular test path, or None if there is no
     metadata stored for that test path.
 
     :param metadata_root: Absolute path to the root of the metadata directory
     :param test_path: Path to the test(s) relative to the test root
-    :param url_base: Base url for serving the tests in this manifest
     :param run_info: Dictionary of properties of the test run for which the expectation
                      values should be computed.
     """
@@ -519,8 +507,7 @@
             return static.compile(f,
                                   run_info,
                                   data_cls_getter=data_cls_getter,
-                                  test_path=test_path,
-                                  url_base=url_base)
+                                  test_path=test_path)
     except OSError:
         return None
 
diff --git a/tools/wptrunner/wptrunner/testloader.py b/tools/wptrunner/wptrunner/testloader.py
index 0cb5f49..0e24c0d 100644
--- a/tools/wptrunner/wptrunner/testloader.py
+++ b/tools/wptrunner/wptrunner/testloader.py
@@ -267,7 +267,7 @@
     def get_test(self, manifest_file, manifest_test, inherit_metadata, test_metadata):
         if test_metadata is not None:
             inherit_metadata.append(test_metadata)
-            test_metadata = test_metadata.get_test(manifest_test.id)
+            test_metadata = test_metadata.get_test(manifest_test.id.rpartition('/')[-1])
 
         return wpttest.from_manifest(manifest_file, manifest_test, inherit_metadata, test_metadata)
 
@@ -287,7 +287,7 @@
     def load_metadata(self, test_manifest, metadata_path, test_path):
         inherit_metadata = self.load_dir_metadata(test_manifest, metadata_path, test_path)
         test_metadata = manifestexpected.get_manifest(
-            metadata_path, test_path, test_manifest.url_base, self.run_info)
+            metadata_path, test_path, self.run_info)
         return inherit_metadata, test_metadata
 
     def iter_tests(self):
diff --git a/tools/wptrunner/wptrunner/tests/test_manifestexpected.py b/tools/wptrunner/wptrunner/tests/test_manifestexpected.py
index 03f4fe8..e47a347 100644
--- a/tools/wptrunner/wptrunner/tests/test_manifestexpected.py
+++ b/tools/wptrunner/wptrunner/tests/test_manifestexpected.py
@@ -31,6 +31,5 @@
     manifest = manifestexpected.static.compile(f,
                                                {},
                                                data_cls_getter=manifestexpected.data_cls_getter,
-                                               test_path="test/test.html",
-                                               url_base="/")
-    assert manifest.get_test("/test/test.html").fuzzy == expected
+                                               test_path="test/test.html")
+    assert manifest.get_test("test.html").fuzzy == expected
diff --git a/tools/wptrunner/wptrunner/tests/test_wpttest.py b/tools/wptrunner/wptrunner/tests/test_wpttest.py
index 272fffd..d11b3a2 100644
--- a/tools/wptrunner/wptrunner/tests/test_wpttest.py
+++ b/tools/wptrunner/wptrunner/tests/test_wpttest.py
@@ -108,11 +108,10 @@
     test_metadata = manifestexpected.static.compile(BytesIO(test_name),
                                                     condition,
                                                     data_cls_getter=manifestexpected.data_cls_getter,
-                                                    test_path=test_path,
-                                                    url_base="/")
+                                                    test_path=test_path)
 
     test = next(iter(tests[index][2])) if iterate else tests[index][2].pop()
-    return wpttest.from_manifest(tests, test, inherit_metadata, test_metadata.get_test(test.id))
+    return wpttest.from_manifest(tests, test, inherit_metadata, test_metadata.get_test(test.id.rpartition('/')[-1]))
 
 
 def test_run_info():
@@ -222,11 +221,10 @@
     test_metadata = manifestexpected.static.compile(BytesIO(test_fuzzy),
                                                     {},
                                                     data_cls_getter=manifestexpected.data_cls_getter,
-                                                    test_path="a/fuzzy.html",
-                                                    url_base="/")
+                                                    test_path="a/fuzzy.html")
 
     test = next(manifest.iterpath(to_os_path("a/fuzzy.html")))
-    test_obj = wpttest.from_manifest(manifest, test, [], test_metadata.get_test(test.id))
+    test_obj = wpttest.from_manifest(manifest, test, [], test_metadata.get_test(test.id.rpartition('/')[-1]))
 
     assert test_obj.fuzzy == {('/a/fuzzy.html', '/a/fuzzy-ref.html', '=='): [[2, 3], [10, 15]]}
     assert test_obj.fuzzy_override == {'/a/fuzzy-ref.html': ((1, 1), (200, 200))}