test_url_data.html (1220B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test URL API - data:plain</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 <body> 10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1018682">Mozilla Bug 1018682</a> 11 12 <script type="application/javascript"> 13 14 var base = new URL("data:text/plain,"); 15 16 let relative; 17 try { 18 relative = new URL("a", base); 19 ok(false, "Relative URL from a data:text/plain should not work."); 20 } catch (e) { 21 ok(true, "Relative URL from a data:text/plain should not work."); 22 } 23 24 base.protocol = "chrome:"; 25 is(base.protocol, "chrome:", "The protocol should be changed from data to chrome."); 26 27 try { 28 relative = new URL("a", base); 29 ok(true, "Relative URL from a chrome: should work."); 30 } catch (e) { 31 ok(false, "Relative URL from a chrome: should work."); 32 } 33 34 base.protocol = "http:"; 35 ok(true, "Protocol: http not changed (special scheme)"); 36 is(base.href, "chrome://text/plain,", "Base URL is correct"); 37 38 relative = new URL("a", base); 39 ok(relative, "This works."); 40 is(relative.href, "chrome://text/a", "Relative URL is correct"); 41 42 </script> 43 44 </body> 45 </html>