|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test to ensure TCPSocket permission enabled and no tcp-socket perm does not allow open</title> |
|
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
7 </head> |
|
8 <body> |
|
9 <p id="display"></p> |
|
10 <div id="content" style="display: none"> |
|
11 </div> |
|
12 <pre id="test"> |
|
13 <script type="application/javascript"> |
|
14 |
|
15 /** Test to ensure TCPSocket permission being turned on enables |
|
16 navigator.mozTCPSocket, but mozTCPSocket.open does not work |
|
17 in content. |
|
18 **/ |
|
19 SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", true); |
|
20 |
|
21 ok('mozTCPSocket' in navigator, "navigator.mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true"); |
|
22 |
|
23 try { |
|
24 navigator.mozTCPSocket.open('localhost', 80); |
|
25 throw new Error("Error: navigator.mozTCPSocket.open should raise for content that does not have the tcp-socket permission"); |
|
26 } catch (e) { |
|
27 ok(true, "navigator.mozTCPSocket.open should raise for content that does not have the tcp-socket permission"); |
|
28 } |
|
29 |
|
30 SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", false); |
|
31 |
|
32 </script> |
|
33 </pre> |
|
34 </body> |
|
35 </html> |