Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 69 additions & 2 deletions build/wpt_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def wpt_test(name, wpt_directory, config, compat_date = "", compat_flags = [], a
harness = "//src/wpt:harness@js"
wpt_cacert = "@wpt//:tools/certs/cacert.pem"
wpt_common = "@wpt//:common@module"
wpt_resources = "@wpt//:resources@module"
wpt_interfaces = "@wpt//:interfaces@module"

if compat_date == "":
compat_date = "2999-12-31"
Expand All @@ -62,6 +64,8 @@ def wpt_test(name, wpt_directory, config, compat_date = "", compat_flags = [], a
autogates = autogates,
wpt_cacert = wpt_cacert,
wpt_common = wpt_common,
wpt_resources = wpt_resources,
wpt_interfaces = wpt_interfaces,
compat_flags = compat_flags + ["experimental", "nodejs_compat", "unsupported_process_actual_platform"],
)

Expand All @@ -72,6 +76,8 @@ def wpt_test(name, wpt_directory, config, compat_date = "", compat_flags = [], a
harness, # e.g. wpt/harness/*.ts
wpt_cacert, # i.e. "wpt/tools/certs/cacert.pem",
wpt_common, # i.e. "wpt/common/**"
wpt_resources, # i.e. "wpt/resources/**"
wpt_interfaces, # i.e. "wpt/interfaces/**"
]

wd_test(
Expand Down Expand Up @@ -231,11 +237,15 @@ def _wpt_wd_test_gen_impl(ctx):
src = ctx.actions.declare_file("{}.wd-test".format(ctx.attr.test_name))
base = ctx.attr.wpt_directory[WPTModuleInfo].base

# Generate bindings for test directory files plus common/**/*.js
# Generate bindings for test directory files plus common/**/*.js, resources/**/*.js, and interfaces/**/*.idl
bindings = generate_external_bindings(src, base, ctx.attr.wpt_directory.files)
common_base = ctx.attr.wpt_common[WPTModuleInfo].base
common_bindings = generate_common_bindings(src, common_base, ctx.attr.wpt_common.files)
all_bindings = bindings + ",\n" + common_bindings if bindings and common_bindings else (bindings or common_bindings)
resources_base = ctx.attr.wpt_resources[WPTModuleInfo].base
resources_bindings = generate_resources_bindings(src, resources_base, ctx.attr.wpt_resources.files)
interfaces_base = ctx.attr.wpt_interfaces[WPTModuleInfo].base
interfaces_bindings = generate_interfaces_bindings(src, interfaces_base, ctx.attr.wpt_interfaces.files)
all_bindings = ",\n".join([b for b in [bindings, common_bindings, resources_bindings, interfaces_bindings] if b])
ctx.actions.write(
output = src,
content = WPT_WD_TEST_TEMPLATE.format(
Expand Down Expand Up @@ -271,6 +281,10 @@ _wpt_wd_test_gen = rule(
"wpt_cacert": attr.label(allow_single_file = True),
# Target specifying the WPT common directory module
"wpt_common": attr.label(),
# Target specifying the WPT resources directory module
"wpt_resources": attr.label(),
# Target specifying the WPT interfaces directory module
"wpt_interfaces": attr.label(),
# A list of autogates to specify in the generated wd-test file
"autogates": attr.string_list(),
# A list of compatibility flags to specify in the generated wd-test file
Expand Down Expand Up @@ -392,6 +406,59 @@ def generate_common_bindings(wd_test_file, base, files):

return ",\n".join(result)

def generate_resources_bindings(wd_test_file, base, files):
"""
Generates appropriate bindings for each file in the WPT resources module.
Files are prefixed with /resources/ path.

Only JS files are included. Also adds an alias for /resources/WebIDLParser.js
which points to /resources/webidl2/lib/webidl2.js (matching the WPT server
rewrite rule in tools/serve/serve.py).
"""

result = []
webidl2_file = None

for file in files.to_list():
if file.extension != "js":
# Skip non-JS files
continue

relative_path = module_relative_path(base, file)
file_path = wd_test_relative_path(wd_test_file, file)
result.append('(name = "/resources/{}", text = embed "{}")'.format(relative_path, file_path))

# Track the webidl2.js file for the alias
if relative_path == "webidl2/lib/webidl2.js":
webidl2_file = file_path

# Add the WebIDLParser.js alias (WPT server rewrites this to webidl2/lib/webidl2.js)
if webidl2_file:
result.append('(name = "/resources/WebIDLParser.js", text = embed "{}")'.format(webidl2_file))

return ",\n".join(result)

def generate_interfaces_bindings(wd_test_file, base, files):
"""
Generates appropriate bindings for each file in the WPT interfaces module.
Files are prefixed with /interfaces/ path.

Only IDL files are included (*.idl) which are used by idlharness tests.
"""

result = []

for file in files.to_list():
if file.extension != "idl":
# Skip non-IDL files
continue

relative_path = module_relative_path(base, file)
file_path = wd_test_relative_path(wd_test_file, file)
result.append('(name = "/interfaces/{}", text = embed "{}")'.format(relative_path, file_path))

return ",\n".join(result)

def generate_harness_modules(wd_test_file, files):
"""
Generates a module entry for each file in the harness package
Expand Down
75 changes: 73 additions & 2 deletions src/wpt/WebCryptoAPI-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,79 @@ export default {
],
},
'idlharness.https.any.js': {
comment: 'Test file /resources/WebIDLParser.js not found.',
disabledTests: true,
comment: 'TODO investigate this',
expectedFailures: [
'Crypto interface: existence and properties of interface object',
'Crypto interface object length',
'Crypto interface object name',
'Crypto interface: existence and properties of interface prototype object',
'Crypto interface: existence and properties of interface prototype object\'s "constructor" property',
"Crypto interface: existence and properties of interface prototype object's @@unscopables property",
'Crypto interface: attribute subtle',
'Crypto interface: operation getRandomValues(ArrayBufferView)',
'Crypto interface: operation randomUUID()',
'Crypto must be primary interface of crypto',
'Stringification of crypto',
'Crypto interface: crypto must inherit property "subtle" with the proper type',
'Crypto interface: crypto must inherit property "getRandomValues(ArrayBufferView)" with the proper type',
'Crypto interface: calling getRandomValues(ArrayBufferView) on crypto with too few arguments must throw TypeError',
'Crypto interface: crypto must inherit property "randomUUID()" with the proper type',
'CryptoKey interface: existence and properties of interface object',
'CryptoKey interface object length',
'CryptoKey interface object name',
'CryptoKey interface: existence and properties of interface prototype object',
'CryptoKey interface: existence and properties of interface prototype object\'s "constructor" property',
"CryptoKey interface: existence and properties of interface prototype object's @@unscopables property",
'CryptoKey interface: attribute type',
'CryptoKey interface: attribute extractable',
'CryptoKey interface: attribute algorithm',
'CryptoKey interface: attribute usages',
'SubtleCrypto interface: existence and properties of interface object',
'SubtleCrypto interface object length',
'SubtleCrypto interface object name',
'SubtleCrypto interface: existence and properties of interface prototype object',
'SubtleCrypto interface: existence and properties of interface prototype object\'s "constructor" property',
"SubtleCrypto interface: existence and properties of interface prototype object's @@unscopables property",
'SubtleCrypto interface: operation encrypt(AlgorithmIdentifier, CryptoKey, BufferSource)',
'SubtleCrypto interface: operation decrypt(AlgorithmIdentifier, CryptoKey, BufferSource)',
'SubtleCrypto interface: operation sign(AlgorithmIdentifier, CryptoKey, BufferSource)',
'SubtleCrypto interface: operation verify(AlgorithmIdentifier, CryptoKey, BufferSource, BufferSource)',
'SubtleCrypto interface: operation digest(AlgorithmIdentifier, BufferSource)',
'SubtleCrypto interface: operation generateKey(AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
'SubtleCrypto interface: operation deriveKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
'SubtleCrypto interface: operation deriveBits(AlgorithmIdentifier, CryptoKey, optional unsigned long?)',
'SubtleCrypto interface: operation importKey(KeyFormat, (BufferSource or JsonWebKey), AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
'SubtleCrypto interface: operation exportKey(KeyFormat, CryptoKey)',
'SubtleCrypto interface: operation wrapKey(KeyFormat, CryptoKey, CryptoKey, AlgorithmIdentifier)',
'SubtleCrypto interface: operation unwrapKey(KeyFormat, BufferSource, CryptoKey, AlgorithmIdentifier, AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
'SubtleCrypto must be primary interface of crypto.subtle',
'Stringification of crypto.subtle',
'SubtleCrypto interface: crypto.subtle must inherit property "encrypt(AlgorithmIdentifier, CryptoKey, BufferSource)" with the proper type',
'SubtleCrypto interface: calling encrypt(AlgorithmIdentifier, CryptoKey, BufferSource) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "decrypt(AlgorithmIdentifier, CryptoKey, BufferSource)" with the proper type',
'SubtleCrypto interface: calling decrypt(AlgorithmIdentifier, CryptoKey, BufferSource) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "sign(AlgorithmIdentifier, CryptoKey, BufferSource)" with the proper type',
'SubtleCrypto interface: calling sign(AlgorithmIdentifier, CryptoKey, BufferSource) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "verify(AlgorithmIdentifier, CryptoKey, BufferSource, BufferSource)" with the proper type',
'SubtleCrypto interface: calling verify(AlgorithmIdentifier, CryptoKey, BufferSource, BufferSource) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "digest(AlgorithmIdentifier, BufferSource)" with the proper type',
'SubtleCrypto interface: calling digest(AlgorithmIdentifier, BufferSource) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "generateKey(AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type',
'SubtleCrypto interface: calling generateKey(AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "deriveKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type',
'SubtleCrypto interface: calling deriveKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "deriveBits(AlgorithmIdentifier, CryptoKey, optional unsigned long?)" with the proper type',
'SubtleCrypto interface: calling deriveBits(AlgorithmIdentifier, CryptoKey, optional unsigned long?) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "importKey(KeyFormat, (BufferSource or JsonWebKey), AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type',
'SubtleCrypto interface: calling importKey(KeyFormat, (BufferSource or JsonWebKey), AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "exportKey(KeyFormat, CryptoKey)" with the proper type',
'SubtleCrypto interface: calling exportKey(KeyFormat, CryptoKey) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "wrapKey(KeyFormat, CryptoKey, CryptoKey, AlgorithmIdentifier)" with the proper type',
'SubtleCrypto interface: calling wrapKey(KeyFormat, CryptoKey, CryptoKey, AlgorithmIdentifier) on crypto.subtle with too few arguments must throw TypeError',
'SubtleCrypto interface: crypto.subtle must inherit property "unwrapKey(KeyFormat, BufferSource, CryptoKey, AlgorithmIdentifier, AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type',
'SubtleCrypto interface: calling unwrapKey(KeyFormat, BufferSource, CryptoKey, AlgorithmIdentifier, AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError',
'Window interface: attribute crypto',
],
},

'import_export/crashtests/importKey-unsettled-promise.https.any.js': {},
Expand Down
22 changes: 20 additions & 2 deletions src/wpt/compression-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,26 @@ export default {
],
},
'idlharness.https.any.js': {
comment: 'Test file /resources/WebIDLParser.js not found',
disabledTests: true,
comment:
'Workers expose globals differently than browsers - these interface tests fail',
expectedFailures: [
'CompressionStream interface: existence and properties of interface object',
'CompressionStream interface object length',
'CompressionStream interface object name',
'CompressionStream interface: existence and properties of interface prototype object',
'CompressionStream interface: existence and properties of interface prototype object\'s "constructor" property',
"CompressionStream interface: existence and properties of interface prototype object's @@unscopables property",
'CompressionStream must be primary interface of new CompressionStream("deflate")',
'Stringification of new CompressionStream("deflate")',
'DecompressionStream interface: existence and properties of interface object',
'DecompressionStream interface object length',
'DecompressionStream interface object name',
'DecompressionStream interface: existence and properties of interface prototype object',
'DecompressionStream interface: existence and properties of interface prototype object\'s "constructor" property',
"DecompressionStream interface: existence and properties of interface prototype object's @@unscopables property",
'DecompressionStream must be primary interface of new DecompressionStream("deflate")',
'Stringification of new DecompressionStream("deflate")',
],
},
'third_party/pako/pako_inflate.min.js': {},
} satisfies TestRunnerConfig;
55 changes: 53 additions & 2 deletions src/wpt/encoding-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,59 @@ export default {
expectedFailures: ['encodeInto() and a detached output buffer'],
},
'idlharness.any.js': {
comment: 'Test file /resources/WebIDLParser.js not found',
disabledTests: true,
comment:
'Workers expose globals differently than browsers - these interface tests fail',
expectedFailures: [
'TextDecoder interface: existence and properties of interface object',
'TextDecoder interface object length',
'TextDecoder interface object name',
'TextDecoder interface: existence and properties of interface prototype object',
'TextDecoder interface: existence and properties of interface prototype object\'s "constructor" property',
"TextDecoder interface: existence and properties of interface prototype object's @@unscopables property",
'TextDecoder interface: operation decode(optional AllowSharedBufferSource, optional TextDecodeOptions)',
'TextDecoder interface: attribute encoding',
'TextDecoder interface: attribute fatal',
'TextDecoder interface: attribute ignoreBOM',
'TextDecoder must be primary interface of new TextDecoder()',
'Stringification of new TextDecoder()',
'TextDecoder interface: new TextDecoder() must inherit property "decode(optional AllowSharedBufferSource, optional TextDecodeOptions)" with the proper type',
'TextDecoder interface: calling decode(optional AllowSharedBufferSource, optional TextDecodeOptions) on new TextDecoder() with too few arguments must throw TypeError',
'TextDecoder interface: new TextDecoder() must inherit property "encoding" with the proper type',
'TextDecoder interface: new TextDecoder() must inherit property "fatal" with the proper type',
'TextDecoder interface: new TextDecoder() must inherit property "ignoreBOM" with the proper type',
'TextEncoder interface: existence and properties of interface object',
'TextEncoder interface object length',
'TextEncoder interface object name',
'TextEncoder interface: existence and properties of interface prototype object',
'TextEncoder interface: existence and properties of interface prototype object\'s "constructor" property',
"TextEncoder interface: existence and properties of interface prototype object's @@unscopables property",
'TextEncoder interface: operation encode(optional USVString)',
'TextEncoder interface: operation encodeInto(USVString, Uint8Array)',
'TextEncoder interface: attribute encoding',
'TextEncoder must be primary interface of new TextEncoder()',
'Stringification of new TextEncoder()',
'TextEncoder interface: new TextEncoder() must inherit property "encode(optional USVString)" with the proper type',
'TextEncoder interface: calling encode(optional USVString) on new TextEncoder() with too few arguments must throw TypeError',
'TextEncoder interface: new TextEncoder() must inherit property "encodeInto(USVString, Uint8Array)" with the proper type',
'TextEncoder interface: calling encodeInto(USVString, Uint8Array) on new TextEncoder() with too few arguments must throw TypeError',
'TextEncoder interface: new TextEncoder() must inherit property "encoding" with the proper type',
'TextDecoderStream interface: existence and properties of interface object',
'TextDecoderStream interface object length',
'TextDecoderStream interface object name',
'TextDecoderStream interface: existence and properties of interface prototype object',
'TextDecoderStream interface: existence and properties of interface prototype object\'s "constructor" property',
"TextDecoderStream interface: existence and properties of interface prototype object's @@unscopables property",
'TextDecoderStream interface: attribute encoding',
'TextDecoderStream interface: attribute fatal',
'TextDecoderStream interface: attribute ignoreBOM',
'TextEncoderStream interface: existence and properties of interface object',
'TextEncoderStream interface object length',
'TextEncoderStream interface object name',
'TextEncoderStream interface: existence and properties of interface prototype object',
'TextEncoderStream interface: existence and properties of interface prototype object\'s "constructor" property',
"TextEncoderStream interface: existence and properties of interface prototype object's @@unscopables property",
'TextEncoderStream interface: attribute encoding',
],
},
'iso-2022-jp-decoder.any.js': {
comment: 'TODO investigate this',
Expand Down
Loading