File tree 7 files changed +121
-0
lines changed
7 files changed +121
-0
lines changed Original file line number Diff line number Diff line change @@ -604,3 +604,14 @@ new_local_repository(
604
604
visibility = ["//visibility:public"],)""" ,
605
605
path = "empty" ,
606
606
)
607
+
608
+ # ========================================================================================
609
+ # Web Platform Tests
610
+
611
+ http_archive (
612
+ name = "wpt" ,
613
+ build_file = "//:build/BUILD.wpt" ,
614
+ integrity = "sha256-6mp9wOEkWuACXvSDmf1pL2Dlj5ruukYwQzwkNgcpCdI=" ,
615
+ strip_prefix = "wpt-merge_pr_47718" ,
616
+ url = "https://github.com/web-platform-tests/wpt/archive/refs/tags/merge_pr_47718.tar.gz" ,
617
+ )
Original file line number Diff line number Diff line change
1
+ filegroup(
2
+ name = "url",
3
+ srcs = glob(
4
+ include = ["url/**/*"],
5
+ allow_empty = True,
6
+ ),
7
+ visibility = ["//visibility:public"],
8
+ )
Original file line number Diff line number Diff line change
1
+ load ("//:build/wd_test.bzl" , "wd_test" )
2
+
3
+ wd_test (
4
+ name = "url-test" ,
5
+ src = "url-test.wd-test" ,
6
+ args = ["--experimental" ],
7
+ data = [
8
+ "url-test.js" ,
9
+ "//src/wpt:wpt-test-harness" ,
10
+ "@wpt//:url" ,
11
+ ],
12
+ )
Original file line number Diff line number Diff line change
1
+ import { strictEqual } from 'assert' ;
2
+
3
+ // The harness has no exports of it's own but does modify the global
4
+ // scope to include the additional stuff the Web Platform Tests expect.
5
+ import * as harness from 'harness' ;
6
+
7
+ export const test = {
8
+ async test ( ) {
9
+ // The tests will be run when the module is imported. Note that
10
+ // there are limitations to this in that the module is not allowed
11
+ // to perform any I/O... so any test that requires setTimeout,
12
+ // for instance, will fail... this also means we cannot run
13
+ // fetch tests from WPT... sad face.
14
+ const foo = await import ( 'url-origin.any.js' ) ;
15
+
16
+ if ( globalThis . errors . length > 0 ) {
17
+ for ( const err of globalThis . errors ) {
18
+ console . error ( err ) ;
19
+ }
20
+ throw new Error ( 'Test failed' ) ;
21
+ }
22
+ } ,
23
+ } ;
Original file line number Diff line number Diff line change
1
+ using Workerd = import "/workerd/workerd.capnp";
2
+
3
+ const unitTests :Workerd.Config = (
4
+ services = [
5
+ ( name = "url-test-test",
6
+ worker = (
7
+ modules = [
8
+ (name = "worker", esModule = embed "url-test.js"),
9
+ (name = "harness",
10
+ esModule = embed "../../../../../workerd/src/wpt/harness.js"),
11
+ (name = "url-origin.any.js",
12
+ esModule = embed "../../../../../wpt/url/url-origin.any.js"),
13
+ (name = "resources/urltestdata.json",
14
+ json = embed "../../../../../wpt/url/resources/urltestdata.json"),
15
+ (name = "resources/urltestdata-javascript-only.json",
16
+ json = embed "../../../../../wpt/url/resources/urltestdata-javascript-only.json"),
17
+ ],
18
+ bindings = [
19
+ (name = "wpt", service = "wpt"),
20
+ ],
21
+ compatibilityDate = "2024-07-01",
22
+ compatibilityFlags = ["nodejs_compat_v2"],
23
+ )
24
+ ),
25
+ (
26
+ name = "wpt",
27
+ disk = ".",
28
+ )
29
+ ],
30
+ );
Original file line number Diff line number Diff line change
1
+ filegroup (
2
+ name = "wpt-test-harness" ,
3
+ srcs = glob (
4
+ include = ["**/*" ],
5
+ allow_empty = True ,
6
+ ),
7
+ visibility = ["//visibility:public" ],
8
+ )
Original file line number Diff line number Diff line change
1
+ import { strictEqual } from 'node:assert' ;
2
+
3
+ globalThis . fetch = async ( url ) => {
4
+ const { default : data } = await import ( url ) ;
5
+ return {
6
+ async json ( ) {
7
+ return data ;
8
+ } ,
9
+ } ;
10
+ } ;
11
+
12
+ globalThis . promise_test = ( callback ) => {
13
+ callback ( ) ;
14
+ } ;
15
+
16
+ globalThis . assert_equals = ( a , b , c ) => {
17
+ strictEqual ( a , b , c ) ;
18
+ } ;
19
+
20
+ globalThis . test = ( callback , message ) => {
21
+ try {
22
+ callback ( ) ;
23
+ } catch ( err ) {
24
+ const aerr = new AggregateError ( [ err ] , message ) ;
25
+ globalThis . errors . push ( aerr ) ;
26
+ }
27
+ } ;
28
+
29
+ globalThis . errors = [ ] ;
You can’t perform that action at this time.
0 commit comments