Fix screenshot directory resolution under Bazel CI sandboxing in resultdb-reporter.mjs

When web-test-runner executes inside a CI Tryjob wrapper (like
kitchen-checkout or Bazel sandboxing), the process current working
directory (PWD) is set to the repo root rather than the polygerrit-ui
subdirectory.

Because getExistingDir('screenshots/Chromium/failed') previously
evaluated paths relative to PWD, fs.existsSync() returned false in CI
sandboxes where screenshots reside in
polygerrit-ui/screenshots/Chromium/failed/.

This change updates resultdb-reporter.mjs to resolve the screenshots
directory unconditionally relative to the absolute path of
import.meta.url, ensuring robust and universal side-by-side screenshot
uploading across all Tryjob environments.

Google-bug-id: b/510899910
Release-Notes: skip
Change-Id: I2c1b034781de5c0fbfeae951102f06182816d2b0
diff --git a/polygerrit-ui/resultdb-reporter.mjs b/polygerrit-ui/resultdb-reporter.mjs
index 63f2c70..26c54a9 100644
--- a/polygerrit-ui/resultdb-reporter.mjs
+++ b/polygerrit-ui/resultdb-reporter.mjs
@@ -1,5 +1,8 @@
 import fs from 'fs';
 import path from 'path';
+import { URL } from 'url';
+
+const uiDir = path.dirname(new URL(import.meta.url).pathname);
 
 function getExistingDir(dirPath) {
   if (fs.existsSync(dirPath)) return dirPath;
@@ -27,7 +30,7 @@
 
 function attachSideBySideScreenshots(test, testFile, artifacts) {
   try {
-    const failedDir = getExistingDir('screenshots/Chromium/failed');
+    const failedDir = getExistingDir(path.join(uiDir, 'screenshots/Chromium/failed'));
     if (!failedDir) return '';
 
     const files = fs.readdirSync(failedDir).filter(f => f.endsWith('.png') && !f.endsWith('-diff.png'));
@@ -56,7 +59,7 @@
     if (!bestFile) return '';
 
     const actualPath = path.join(failedDir, bestFile);
-    const baselineDir = getExistingDir('screenshots/baseline/Chromium');
+    const baselineDir = getExistingDir(path.join(uiDir, 'screenshots/baseline/Chromium'));
     const baselinePath = baselineDir ? path.join(baselineDir, bestFile) : null;
 
     let html = '';