File tree Expand file tree Collapse file tree 2 files changed +36
-15
lines changed Expand file tree Collapse file tree 2 files changed +36
-15
lines changed Original file line number Diff line number Diff line change 22
33/* The following tests are copied from WPT. Modifications to them should be
44 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
66 License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
77*/
88module . exports =
@@ -6529,27 +6529,34 @@ module.exports =
65296529 "search" : "?a" ,
65306530 "hash" : "#%GH"
65316531 } ,
6532- "Bad bases " ,
6532+ "URLs that require a non-about:blank base. (Also serve as invalid base tests.) " ,
65336533 {
6534- "input" : "test-a.html " ,
6535- "base" : "a " ,
6534+ "input" : "a " ,
6535+ "base" : "about:blank " ,
65366536 "failure" : true
65376537 } ,
65386538 {
6539- "input" : "test-a-slash.html " ,
6540- "base" : "a/ " ,
6539+ "input" : "a/ " ,
6540+ "base" : "about:blank " ,
65416541 "failure" : true
65426542 } ,
65436543 {
6544- "input" : "test-a-slash-slash.html " ,
6545- "base" : "a// " ,
6544+ "input" : "a// " ,
6545+ "base" : "about:blank " ,
65466546 "failure" : true
65476547 } ,
6548+ "Bases that don't fail to parse but fail to be bases" ,
65486549 {
65496550 "input" : "test-a-colon.html" ,
65506551 "base" : "a:" ,
65516552 "failure" : true
65526553 } ,
6554+ {
6555+ "input" : "test-a-colon-b.html" ,
6556+ "base" : "a:b" ,
6557+ "failure" : true
6558+ } ,
6559+ "Other base URL tests, that must succeed" ,
65536560 {
65546561 "input" : "test-a-colon-slash.html" ,
65556562 "base" : "a:/" ,
@@ -6578,11 +6585,6 @@ module.exports =
65786585 "search" : "" ,
65796586 "hash" : ""
65806587 } ,
6581- {
6582- "input" : "test-a-colon-b.html" ,
6583- "base" : "a:b" ,
6584- "failure" : true
6585- } ,
65866588 {
65876589 "input" : "test-a-colon-slash-b.html" ,
65886590 "base" : "a:/b" ,
Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ const fixtures = require('../common/fixtures');
1212
1313// Tests below are not from WPT.
1414const 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 = [
1619 { input : '' } ,
1720 { input : 'test' } ,
1821 { input : undefined } ,
@@ -25,7 +28,23 @@ const failureTests = tests.filter((test) => test.failure).concat([
2528 { input : 'test' , base : null } ,
2629 { input : 'http://nodejs.org' , base : null } ,
2730 { 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 ) ;
2948
3049const expectedError = common . expectsError (
3150 { code : 'ERR_INVALID_URL' , type : TypeError } , failureTests . length ) ;
You can’t perform that action at this time.
0 commit comments