Bug 1286530 - Switch UDP/TCP Socket mochitests to chrome draft
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Tue, 10 May 2016 10:39:56 +0200
changeset 387116 1c7a02a36bec9bb5e5aa653b3f32bd2c799b561a
parent 387115 738925365e95eee413847b835ac36b10f8b5a79e
child 387117 3ae567ce23ef85fa338a64eec850a91724232d29
push id22896
push userbmo:lissyx+mozillians@lissyx.dyndns.org
push dateWed, 13 Jul 2016 13:02:44 +0000
bugs1286530
milestone50.0a1
Bug 1286530 - Switch UDP/TCP Socket mochitests to chrome MozReview-Commit-ID: G4jpaUvgSMO
dom/network/tests/chrome.ini
dom/network/tests/mochitest.ini
dom/network/tests/test_tcpsocket_client_and_server_basics.html
dom/network/tests/test_tcpsocket_client_and_server_basics.js
dom/network/tests/test_tcpsocket_enabled_no_perm.html
dom/network/tests/test_tcpsocket_enabled_with_perm.html
dom/network/tests/test_tcpsocket_legacy.html
dom/network/tests/test_udpsocket.html
--- a/dom/network/tests/chrome.ini
+++ b/dom/network/tests/chrome.ini
@@ -1,7 +1,13 @@
 [DEFAULT]
 support-files =
   tcpsocket_test.jsm
   test_tcpsocket_client_and_server_basics.js
   add_task.js
+  file_udpsocket_iframe.html
 
-[test_tcpsocket_jsm.html]
\ No newline at end of file
+[test_tcpsocket_jsm.html]
+[test_tcpsocket_client_and_server_basics.html]
+[test_tcpsocket_enabled_with_perm.html]
+skip-if = toolkit == "gonk"
+[test_tcpsocket_legacy.html]
+[test_udpsocket.html]
--- a/dom/network/tests/mochitest.ini
+++ b/dom/network/tests/mochitest.ini
@@ -1,27 +1,20 @@
 [DEFAULT]
 support-files =
   add_task.js
-  file_udpsocket_iframe.html
-  test_tcpsocket_client_and_server_basics.js
 
 [test_network_basics.html]
 skip-if = toolkit == "gonk" || toolkit == 'android'
-[test_tcpsocket_client_and_server_basics.html]
 [test_tcpsocket_default_permissions.html]
 skip-if = toolkit == "gonk"
 [test_tcpsocket_enabled_no_perm.html]
 skip-if = toolkit == "gonk"
-[test_tcpsocket_enabled_with_perm.html]
-skip-if = toolkit == "gonk"
-[test_tcpsocket_legacy.html]
 [test_networkstats_alarms.html]
 skip-if = toolkit != "gonk"
 [test_networkstats_basics.html]
 skip-if = toolkit != "gonk"
 [test_networkstats_disabled.html]
 skip-if = toolkit != "gonk"
 [test_networkstats_enabled_no_perm.html]
 skip-if = toolkit != "gonk"
 [test_networkstats_enabled_perm.html]
 skip-if = toolkit != "gonk"
-[test_udpsocket.html]
\ No newline at end of file
--- a/dom/network/tests/test_tcpsocket_client_and_server_basics.html
+++ b/dom/network/tests/test_tcpsocket_client_and_server_basics.html
@@ -5,18 +5,18 @@ Core tests for TCPSocket and TCPServerSo
 separate xpcshell incarnations.  This migration and cleanup occurred as part
 of bug 1084245 in order to get coverage of the tests from content.
 
 https://bugzilla.mozilla.org/show_bug.cgi?id=1084245
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 1084245</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="add_task.js"></script>
   <script type="application/javascript">
     function createServer(port, options, backlog) {
       return new TCPServerSocket(port, options, backlog);
     }
 
     function createSocket(host, port, options) {
       return new TCPSocket(host, port, options);
--- a/dom/network/tests/test_tcpsocket_client_and_server_basics.js
+++ b/dom/network/tests/test_tcpsocket_client_and_server_basics.js
@@ -150,31 +150,16 @@ function defer() {
     deferred.resolve = resolve;
     deferred.reject = reject;
   });
   return deferred;
 }
 
 
 function* test_basics() {
-  if (enablePrefsAndPermissions()) {
-    // Enable our use of TCPSocket
-    let prefDeferred = defer();
-    SpecialPowers.pushPrefEnv(
-      { set: [ ['dom.mozTCPSocket.enabled', true] ] },
-      prefDeferred.resolve);
-    yield prefDeferred.promise;
-
-    let permDeferred = defer();
-    SpecialPowers.pushPermissions(
-      [ { type: 'tcp-socket', allow: true, context: document } ],
-      permDeferred.resolve);
-    yield permDeferred.promise;
-  }
-
   // See bug 903830; in e10s mode we never get to find out the localPort if we
   // let it pick a free port by choosing 0.  This is the same port the xpcshell
   // test was using.
   let serverPort = 8085;
 
   // - Start up a listening socket.
   let listeningServer = createServer(serverPort,
                                      { binaryType: 'arraybuffer' },
--- a/dom/network/tests/test_tcpsocket_enabled_no_perm.html
+++ b/dom/network/tests/test_tcpsocket_enabled_no_perm.html
@@ -14,16 +14,17 @@
 
 /** Test to ensure TCPSocket preference being turned on does not enable
   navigator.mozTCPSocket.
 **/
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.pushPrefEnv({"set": [['dom.mozTCPSocket.enabled', true]]}, runTest);
 function runTest() {
   is('TCPSocket' in this, false, "TCPSocket should not be accessible if dom.mozTCPSocket.enabled is true");
-  is('mozTCPSocket' in navigator, false, "mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
+  is('TCPServerSocket' in this, false, "TCPServerSocket should not be accessible if dom.mozTCPSocket.enabled is true");
+  is('mozTCPSocket' in navigator, false, "mozTCPSocket should not be accessible if dom.mozTCPSocket.enabled is true");
 
   SimpleTest.finish();
 }
 </script>
 </pre>
 </body>
 </html>
--- a/dom/network/tests/test_tcpsocket_enabled_with_perm.html
+++ b/dom/network/tests/test_tcpsocket_enabled_with_perm.html
@@ -1,30 +1,28 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test to ensure TCPSocket permission enabled and open works with tcp-socket perm</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test to ensure TCPSocket permission being turned on enables 
   navigator.mozTCPSocket, and mozTCPSocket.open works when
   the tcp-socket permission has been granted.
 **/
 SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [['dom.mozTCPSocket.enabled', true]]}, function() {
-  SpecialPowers.pushPermissions([{type: "tcp-socket", allow: true, context: document}], runTest);
-});
+SpecialPowers.pushPrefEnv({"set": [['dom.mozTCPSocket.enabled', true]]}, runTest);
 
 function runTest() {
   ok('TCPSocket' in this, "TCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
 
   ok(new TCPSocket('localhost', 80), "TCPSocket constructor should work for content that has the tcp-socket permission");
   ok(navigator.mozTCPSocket.open('localhost', 80), "navigator.mozTCPSocket.open should work for content that has the tcp-socket permission");
   // This just helps the test harness clean up quickly
   SpecialPowers.forceCC();
--- a/dom/network/tests/test_tcpsocket_legacy.html
+++ b/dom/network/tests/test_tcpsocket_legacy.html
@@ -1,38 +1,32 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 Test of legacy navigator interface for opening TCPSocket/TCPServerSocket.
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 885982</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1084245">Mozilla Bug 1084245</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 </pre>
 <script>
   SimpleTest.waitForExplicitFinish();
   SpecialPowers.pushPrefEnv(
     { set: [ ['dom.mozTCPSocket.enabled', true] ] },
-    setPerms);
-
-  function setPerms() {
-    SpecialPowers.pushPermissions(
-      [ { type: 'tcp-socket', allow: true, context: document } ],
-      runTest);
-  }
+    runTest);
 
   function runTest() {
     // See bug 903830; in e10s mode we never get to find out the localPort if we
     // let it pick a free port by choosing 0.  This is the same port the xpcshell
     // test was using.
     var serverPort = 8085;
 
     var listeningServer = navigator.mozTCPSocket.listen(serverPort,
--- a/dom/network/tests/test_udpsocket.html
+++ b/dom/network/tests/test_udpsocket.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test UDPSocket API</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <iframe id="iframe"></iframe>
 <pre id="test">
 <script type="application/javascript;version=1.8">
@@ -386,23 +386,20 @@ function runTest() {
   })
   .catch(function(err) {
     ok(false, 'test failed due to: ' + err);
     SimpleTest.finish();
   });
 }
 
 window.addEventListener('load', function () {
-  SpecialPowers.pushPermissions([
-    {type: 'udp-socket', allow: true, context: document}], function() {
-    SpecialPowers.pushPrefEnv({
-      'set': [
-        ['dom.udpsocket.enabled', true],
-        ['browser.sessionhistory.max_total_viewers', 10]
-      ]
-    }, runTest);
-  });
+  SpecialPowers.pushPrefEnv({
+    'set': [
+      ['dom.udpsocket.enabled', true],
+      ['browser.sessionhistory.max_total_viewers', 10]
+    ]
+  }, runTest);
 });
 
 </script>
 </pre>
 </body>
 </html>