File tree 2 files changed +36
-15
lines changed
2 files changed +36
-15
lines changed Original file line number Diff line number Diff line change 2
2
3
3
/* The following tests are copied from WPT. Modifications to them should be
4
4
upstreamed first. Refs:
5
- https://github.com/w3c/web-platform-tests/blob/ed4bb727ed /url/urltestdata.json
5
+ https://github.com/w3c/web-platform-tests/blob/88b75886e /url/urltestdata.json
6
6
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
7
7
*/
8
8
module . exports =
@@ -6529,27 +6529,34 @@ module.exports =
6529
6529
"search" : "?a" ,
6530
6530
"hash" : "#%GH"
6531
6531
} ,
6532
- "Bad bases " ,
6532
+ "URLs that require a non-about:blank base. (Also serve as invalid base tests.) " ,
6533
6533
{
6534
- "input" : "test-a.html " ,
6535
- "base" : "a " ,
6534
+ "input" : "a " ,
6535
+ "base" : "about:blank " ,
6536
6536
"failure" : true
6537
6537
} ,
6538
6538
{
6539
- "input" : "test-a-slash.html " ,
6540
- "base" : "a/ " ,
6539
+ "input" : "a/ " ,
6540
+ "base" : "about:blank " ,
6541
6541
"failure" : true
6542
6542
} ,
6543
6543
{
6544
- "input" : "test-a-slash-slash.html " ,
6545
- "base" : "a// " ,
6544
+ "input" : "a// " ,
6545
+ "base" : "about:blank " ,
6546
6546
"failure" : true
6547
6547
} ,
6548
+ "Bases that don't fail to parse but fail to be bases" ,
6548
6549
{
6549
6550
"input" : "test-a-colon.html" ,
6550
6551
"base" : "a:" ,
6551
6552
"failure" : true
6552
6553
} ,
6554
+ {
6555
+ "input" : "test-a-colon-b.html" ,
6556
+ "base" : "a:b" ,
6557
+ "failure" : true
6558
+ } ,
6559
+ "Other base URL tests, that must succeed" ,
6553
6560
{
6554
6561
"input" : "test-a-colon-slash.html" ,
6555
6562
"base" : "a:/" ,
@@ -6578,11 +6585,6 @@ module.exports =
6578
6585
"search" : "" ,
6579
6586
"hash" : ""
6580
6587
} ,
6581
- {
6582
- "input" : "test-a-colon-b.html" ,
6583
- "base" : "a:b" ,
6584
- "failure" : true
6585
- } ,
6586
6588
{
6587
6589
"input" : "test-a-colon-slash-b.html" ,
6588
6590
"base" : "a:/b" ,
Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ const fixtures = require('../common/fixtures');
12
12
13
13
// Tests below are not from WPT.
14
14
const tests = require ( fixtures . path ( 'url-tests' ) ) ;
15
- const failureTests = tests . filter ( ( test ) => test . failure ) . concat ( [
15
+
16
+ const originalFailures = tests . filter ( ( test ) => test . failure ) ;
17
+
18
+ const typeFailures = [
16
19
{ input : '' } ,
17
20
{ input : 'test' } ,
18
21
{ input : undefined } ,
@@ -25,7 +28,23 @@ const failureTests = tests.filter((test) => test.failure).concat([
25
28
{ input : 'test' , base : null } ,
26
29
{ input : 'http://nodejs.org' , base : null } ,
27
30
{ input : ( ) => { } }
28
- ] ) ;
31
+ ] ;
32
+
33
+ // See https://github.com/w3c/web-platform-tests/pull/10955
34
+ // > If `failure` is true, parsing `about:blank` against `base`
35
+ // > must give failure. This tests that the logic for converting
36
+ // > base URLs into strings properly fails the whole parsing
37
+ // > algorithm if the base URL cannot be parsed.
38
+ const aboutBlankFailures = originalFailures
39
+ . map ( ( test ) => ( {
40
+ input : 'about:blank' ,
41
+ base : test . input ,
42
+ failure : true
43
+ } ) ) ;
44
+
45
+ const failureTests = originalFailures
46
+ . concat ( typeFailures )
47
+ . concat ( aboutBlankFailures ) ;
29
48
30
49
const expectedError = common . expectsError (
31
50
{ code : 'ERR_INVALID_URL' , type : TypeError } , failureTests . length ) ;
You can’t perform that action at this time.
0 commit comments