Skip to content

Deno fails 64 out of 869 WPT URL tests #31760

@ryuapp

Description

@ryuapp

Version: Deno 2.6.3

Related: #30363

node-compat issue.
When testing URL by Web Platform tests with Deno, as many as 7.36% of the tests failed.
The URL tests pass 100% with Node.js and Bun. Therefore, Deno should also pass all these tests.

=== Results ===
Total: 869
Passed: 805 (92.64%)
Failed: 64 (7.36%)
WPT URL Test Runner Script
// WPT URL Test Runner written by Claude Code

interface URLTest {
  input: string;
  base?: string;
  failure?: boolean;
  href?: string;
  protocol?: string;
  hostname?: string;
  port?: string;
  pathname?: string;
  search?: string;
  hash?: string;
  username?: string;
  password?: string;
}

console.log("=== WPT URL Test Runner ===\n");

// Fetch official WPT URL test data
// The 3-Clause BSD License: https://github.com/web-platform-tests/wpt/blob/master/LICENSE.md
const response = await fetch(
  "https://raw.githubusercontent.com/web-platform-tests/wpt/master/url/resources/urltestdata.json",
);
const testData = await response.json();

// Filter out comment strings
const tests = testData.filter((test: unknown) =>
  typeof test !== "string"
) as URLTest[];

console.log(`Running ${tests.length} WPT URL tests...\n`);

let passed = 0;
let failed = 0;
const failures: { test: URLTest; reason: string }[] = [];

for (const test of tests) {
  try {
    const url = test.base
      ? new URL(test.input, test.base)
      : new URL(test.input);

    // Test expected to fail but succeeded
    if (test.failure) {
      failed++;
      failures.push({ test, reason: "Expected to fail but succeeded" });
      continue;
    }

    // Validate properties
    const errors: string[] = [];
    if (test.href && url.href !== test.href) {
      errors.push(`href: expected "${test.href}", got "${url.href}"`);
    }
    if (test.protocol && url.protocol !== test.protocol) {
      errors.push(
        `protocol: expected "${test.protocol}", got "${url.protocol}"`,
      );
    }
    if (test.hostname !== undefined && url.hostname !== test.hostname) {
      errors.push(
        `hostname: expected "${test.hostname}", got "${url.hostname}"`,
      );
    }
    if (test.port !== undefined && url.port !== test.port) {
      errors.push(`port: expected "${test.port}", got "${url.port}"`);
    }
    if (test.pathname && url.pathname !== test.pathname) {
      errors.push(
        `pathname: expected "${test.pathname}", got "${url.pathname}"`,
      );
    }
    if (test.search !== undefined && url.search !== test.search) {
      errors.push(`search: expected "${test.search}", got "${url.search}"`);
    }
    if (test.hash !== undefined && url.hash !== test.hash) {
      errors.push(`hash: expected "${test.hash}", got "${url.hash}"`);
    }
    if (test.username !== undefined && url.username !== test.username) {
      errors.push(
        `username: expected "${test.username}", got "${url.username}"`,
      );
    }
    if (test.password !== undefined && url.password !== test.password) {
      errors.push(
        `password: expected "${test.password}", got "${url.password}"`,
      );
    }

    if (errors.length > 0) {
      failed++;
      failures.push({
        test,
        reason: errors.join("\n  "),
      });
    } else {
      passed++;
    }
  } catch (e) {
    // Test expected to fail
    if (test.failure) {
      passed++;
    } else {
      failed++;
      failures.push({
        test,
        reason: `Unexpected error: ${
          e instanceof Error ? e.message : String(e)
        }`,
      });
    }
  }
}

// Results
console.log("=== Results ===");
console.log(`Total: ${tests.length}`);
console.log(
  `Passed: ${passed} (${((passed / tests.length) * 100).toFixed(2)}%)`,
);
console.log(
  `Failed: ${failed} (${((failed / tests.length) * 100).toFixed(2)}%)`,
);

// Show failures
if (failures.length > 0) {
  console.log(`\n=== Failures (${failures.length}) ===`);
  for (const { test, reason } of failures) {
    console.log(
      `\nInput: "${test.input}"${test.base ? ` (base: "${test.base}")` : ""}`,
    );
    console.log(`  ${reason}`);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ext/webrelated to the ext/web crate

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions