File tree 4 files changed +86
-19
lines changed
html/browsers/history/the-location-interface
4 files changed +86
-19
lines changed Original file line number Diff line number Diff line change 9
9
[
10
10
'x' ,
11
11
'data' ,
12
- // 'mailto' opens an email client in Firefox...
12
+ // 'mailto' opens an email client in Chrome and Firefox and then ends up passing anyway ...
13
13
'file' ,
14
14
'ftp' ,
15
15
'http+x'
16
16
] . forEach ( ( val ) => {
17
17
async_test ( ( t ) => {
18
18
// HTTP URL <iframe>
19
19
const frame = document . createElement ( "iframe" )
20
+ t . add_cleanup ( ( ) => frame . remove ( ) )
20
21
frame . src = "/common/blank.html"
21
22
frame . onload = t . step_func ( ( ) => {
22
23
frame . contentWindow . location . protocol = val
25
26
assert_equals ( frame . contentWindow . location . host , location . host )
26
27
assert_equals ( frame . contentWindow . location . port , location . port )
27
28
t . done ( )
28
- } , 500 )
29
+ // Matches the timeout from location-protocol-setter-non-broken-weird.html which suggests
30
+ // that 4 seconds is enough for a navigation to complete.
31
+ } , 4000 )
29
32
} )
30
33
document . body . appendChild ( frame )
31
34
} , "Set HTTP URL frame location.protocol to " + val )
32
35
33
36
async_test ( ( t ) => {
34
37
// data URL <iframe>
35
38
const dataFrame = document . createElement ( "iframe" )
39
+ t . add_cleanup ( ( ) => dataFrame . remove ( ) )
36
40
const channel = new MessageChannel ( )
37
41
dataFrame . src = `data:text/html,<script>
38
42
onmessage = (e) => {
42
46
} catch(e) {
43
47
result = true
44
48
}
45
- setTimeout(() => e.ports[0].postMessage([result, location.protocol]), 100 )
49
+ setTimeout(() => e.ports[0].postMessage([result, location.protocol]), 4000 )
46
50
}
47
51
<\/script>`
48
52
dataFrame . onload = t . step_func ( ( ) => {
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < title > Set location.protocol to the scheme it already was</ title >
3
+ < script src =/resources/testharness.js > </ script >
4
+ < script src =/resources/testharnessreport.js > </ script >
5
+ < div id =log > </ div >
6
+ < iframe src =/common/blank.html > </ iframe >
7
+ < iframe src =/common/blank.html > </ iframe >
8
+ < iframe src =/common/blank.html > </ iframe >
9
+ < iframe src =/common/blank.html > </ iframe >
10
+ < script >
11
+ self . onload = ( ) => {
12
+ [
13
+ "http" ,
14
+ "ht\x0Atp" ,
15
+ "http\x0A" ,
16
+ "\x09ht\x09\x0AtP"
17
+ ] . forEach ( ( val , index ) => {
18
+ async_test ( t => {
19
+ self [ index ] . frameElement . onload = t . step_func_done ( ( ) => {
20
+ assert_equals ( self [ index ] . location . protocol , "http:" ) ;
21
+ } ) ;
22
+ self [ index ] . location . protocol = val ;
23
+ } , `Set location.protocol to ${ encodeURI ( val ) } (percent-encoded here for clarity)` ) ;
24
+ } ) ;
25
+ }
26
+ </ script >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
- < title > Set location.protocol to broken schemes</ title >
2
+ < title > Set location.protocol to schemes that throw </ title >
3
3
< script src =/resources/testharness.js > </ script >
4
4
< script src =/resources/testharnessreport.js > </ script >
5
5
< div id =log > </ div >
32
32
}
33
33
</script> "> </ iframe >
34
34
< script >
35
- // Tests with '\x0A' (i.e., '\n') don't conform to the URL Standard as of the
36
- // time of writing, as according to spec they should be ignored.
37
- // See https://github.com/whatwg/url/issues/609.
38
-
39
- let broken = [
35
+ const broken = [
40
36
'\x00' ,
41
37
'\x01' ,
42
- '\x0A' ,
38
+ '\x09' , // becomes the empty string
39
+ '\x0A' , // becomes the empty string
40
+ '\x0C' ,
41
+ '\x0D' ,
43
42
'\x20' ,
44
43
'\x21' ,
45
44
'\x7F' ,
49
48
'†' ,
50
49
'\x00x' ,
51
50
'\x01x' ,
52
- '\x0Ax' ,
53
51
'\x20x' ,
54
52
'\x21x' ,
55
53
'\x7Fx' ,
59
57
'†x' ,
60
58
'\x00X' ,
61
59
'\x01X' ,
62
- '\x0AX' ,
63
60
'\x20X' ,
64
61
'\x21X' ,
65
62
'\x7FX' ,
69
66
'†X' ,
70
67
'x\x00' ,
71
68
'x\x01' ,
72
- 'x\x0A' ,
73
69
'x\x20' ,
74
70
'x\x21' ,
75
71
'x\x7F' ,
78
74
'x†' ,
79
75
'X\x00' ,
80
76
'X\x01' ,
81
- 'X\x0A' ,
82
77
'X\x20' ,
83
78
'X\x21' ,
84
79
'X\x7F' ,
85
80
'X\x80' ,
86
81
'X\xFF' ,
87
82
'X†' ,
88
- 'a\x0A' ,
89
- 'a+-.\x0A'
90
- ]
91
- ; broken . forEach ( ( val ) => {
83
+ ] ;
84
+
85
+ broken . forEach ( val => {
92
86
test ( ( ) => {
93
87
assert_throws_dom ( "SyntaxError" , ( ) => { location . protocol = val } )
94
- } , encodeURI ( val ) + " (percent-encoded) is not a scheme" )
88
+ } , ` ${ encodeURI ( val ) } (percent-encoded here for clarity ) is not a scheme` )
95
89
} )
96
90
let c = 0
97
91
async_test ( ( t ) => {
Original file line number Diff line number Diff line change 269
269
"protocol" : " https:" ,
270
270
"port" : " "
271
271
}
272
+ },
273
+ {
274
+ "comment" : " Tab and newline are stripped" ,
275
+ "href" : " http://test/" ,
276
+ "new_value" : " h\u000A\u000A tt\u0009 ps" ,
277
+ "expected" : {
278
+ "href" : " https://test/" ,
279
+ "protocol" : " https:" ,
280
+ "port" : " "
281
+ }
282
+ },
283
+ {
284
+ "comment" : " Non-tab/newline C0 controls result in no-op" ,
285
+ "href" : " http://test/" ,
286
+ "new_value" : " https\u0000 " ,
287
+ "expected" : {
288
+ "href" : " http://test/" ,
289
+ "protocol" : " http:"
290
+ }
291
+ },
292
+ {
293
+ "href" : " http://test/" ,
294
+ "new_value" : " https\u000C " ,
295
+ "expected" : {
296
+ "href" : " http://test/" ,
297
+ "protocol" : " http:"
298
+ }
299
+ },
300
+ {
301
+ "href" : " http://test/" ,
302
+ "new_value" : " https\u000D " ,
303
+ "expected" : {
304
+ "href" : " http://test/" ,
305
+ "protocol" : " http:"
306
+ }
307
+ },
308
+ {
309
+ "href" : " http://test/" ,
310
+ "new_value" : " https\u0020 " ,
311
+ "expected" : {
312
+ "href" : " http://test/" ,
313
+ "protocol" : " http:"
314
+ }
272
315
}
273
316
],
274
317
"username" : [
You can’t perform that action at this time.
0 commit comments