1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/network/tests/test_tcpsocket_enabled_no_perm.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test to ensure TCPSocket permission enabled and no tcp-socket perm does not allow open</title> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.10 +</head> 1.11 +<body> 1.12 +<p id="display"></p> 1.13 +<div id="content" style="display: none"> 1.14 +</div> 1.15 +<pre id="test"> 1.16 +<script type="application/javascript"> 1.17 + 1.18 +/** Test to ensure TCPSocket permission being turned on enables 1.19 + navigator.mozTCPSocket, but mozTCPSocket.open does not work 1.20 + in content. 1.21 +**/ 1.22 +SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", true); 1.23 + 1.24 +ok('mozTCPSocket' in navigator, "navigator.mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true"); 1.25 + 1.26 +try { 1.27 + navigator.mozTCPSocket.open('localhost', 80); 1.28 + throw new Error("Error: navigator.mozTCPSocket.open should raise for content that does not have the tcp-socket permission"); 1.29 +} catch (e) { 1.30 + ok(true, "navigator.mozTCPSocket.open should raise for content that does not have the tcp-socket permission"); 1.31 +} 1.32 + 1.33 +SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", false); 1.34 + 1.35 +</script> 1.36 +</pre> 1.37 +</body> 1.38 +</html>