dom/network/tests/test_tcpsocket_enabled_with_perm.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/network/tests/test_tcpsocket_enabled_with_perm.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test to ensure TCPSocket permission enabled and open works with tcp-socket perm</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, and mozTCPSocket.open works when
    1.20 +  the tcp-socket permission has been granted.
    1.21 +**/
    1.22 +SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", true);
    1.23 +SpecialPowers.addPermission("tcp-socket", true, document);
    1.24 +
    1.25 +ok('mozTCPSocket' in navigator, "navigator.mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
    1.26 +
    1.27 +ok(navigator.mozTCPSocket.open('localhost', 80), "navigator.mozTCPSocket.open should work for content that has the tcp-socket permission");
    1.28 +
    1.29 +SpecialPowers.setBoolPref("dom.mozTCPSocket.enabled", false);
    1.30 +
    1.31 +</script>
    1.32 +</pre>
    1.33 +</body>
    1.34 +</html>

mercurial