test_anchor_query_encoding.html (1412B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="windows-1251"> 5 <title>Testing <a>.href (windows-1251)</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 <script type="text/javascript"> 9 10 const UTF_8 = '%C3%A5'; 11 const WINDOWS_1251 = '%26%23229%3B'; 12 13 function test_scheme(url, expected) { 14 var a = document.createElement('a'); 15 a.setAttribute('href', url); 16 ok(a.href.includes(expected), `Expected: ${expected}, Actual: ${a.href}`); 17 } 18 19 add_task(async function test_bug1883033() { 20 // Scheme http (getting <a>.href) 21 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 22 test_scheme("http://example.invalid/?x=\u00E5", WINDOWS_1251); 23 24 // Scheme https (getting <a>.href) 25 test_scheme("https://example.invalid/?x=\u00E5", WINDOWS_1251); 26 27 // If encoding is not UTF-8 and url’s scheme is "ws" or "wss", 28 // then encoding should be set to UTF-8. 29 // Scheme ws (getting <a>.href) 30 test_scheme("ws://example.invalid/?x=\u00E5", UTF_8); 31 32 // Scheme wss (getting <a>.href) 33 test_scheme("wss://example.invalid/?x=\u00E5", UTF_8); 34 35 // If encoding is not UTF-8 and url is not special, 36 // then encoding should be UTF-8. 37 // Scheme ssh (getting <a>.href) 38 test_scheme("ssh://foo/?x=\u00E5", UTF_8); 39 }); 40 </script> 41 </head> 42 <body> 43 </body> 44 </html>