dom/network/tests/test_tcpsocket_enabled_with_perm.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:a9a2a47384c4
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test to ensure TCPSocket permission enabled and open works with tcp-socket perm</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, and mozTCPSocket.open works when
17 the tcp-socket permission has been granted.
18 **/
19 SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", true);
20 SpecialPowers.addPermission("tcp-socket", true, document);
21
22 ok('mozTCPSocket' in navigator, "navigator.mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
23
24 ok(navigator.mozTCPSocket.open('localhost', 80), "navigator.mozTCPSocket.open should work for content that has the tcp-socket permission");
25
26 SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", false);
27
28 </script>
29 </pre>
30 </body>
31 </html>

mercurial