Bug 803493 - Move WebRTC Mochitests from dom/tests/mochitests/media to /dom/media/tests/mochitest. r=ted
authorHenrik Skupin <hskupin@mozilla.com>
Sat, 27 Oct 2012 13:51:48 -0400
changeset 111745 3e02a25a5e7d99c8a4e006d30da92c7594fb608a
parent 111744 cf52e5234e911e55e9de514fcd7be8b729d9c21e
child 111746 dcf78e64e1bd32c776699cb5d58b41ea9020a7b4
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersted
bugs803493
milestone19.0a1
Bug 803493 - Move WebRTC Mochitests from dom/tests/mochitests/media to /dom/media/tests/mochitest. r=ted
dom/Makefile.in
dom/media/tests/mochitest/Makefile.in
dom/media/tests/mochitest/head.js
dom/media/tests/mochitest/test_getUserMedia_exceptions.html
dom/tests/mochitest/Makefile.in
dom/tests/mochitest/media/Makefile.in
dom/tests/mochitest/media/head.js
dom/tests/mochitest/media/test_getUserMedia_exceptions.html
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -94,15 +94,16 @@ PARALLEL_DIRS += \
 endif
 
 # bindings/test is here, because it needs to build after bindings/, and
 # we build subdirectories before ourselves.
 TEST_DIRS += \
   tests \
   imptests \
   bindings/test \
+  media/tests/mochitest \
   $(NULL)
 
 ifneq (,$(filter gtk2 cocoa windows android qt os2,$(MOZ_WIDGET_TOOLKIT)))
 TEST_DIRS += plugins/test
 endif
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/Makefile.in
@@ -0,0 +1,18 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DEPTH = @DEPTH@
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+relativesrcdir = @relativesrcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MOCHITEST_FILES	= \
+  test_getUserMedia_exceptions.html \
+  head.js \
+  $(NULL)
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/head.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var Cc = SpecialPowers.Cc;
+var Ci = SpecialPowers.Ci;
+var Cr = SpecialPowers.Cr;
+
+/**
+ * Setup any Mochitest for WebRTC by enabling the preference for
+ * peer connections. As by bug 797979 it will also enable mozGetUserMedia().
+ * Additionally, we disable the permissions prompt for these mochitests.
+ *
+ * @param {Function} aCallback Test method to execute after initialization
+ */
+function runTest(aCallback) {
+  SimpleTest.waitForExplicitFinish();
+
+  SpecialPowers.pushPrefEnv({'set': [['media.peerconnection.enabled', true],
+                            ['media.navigator.permission.disabled', true]]},
+                            aCallback);
+}
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_exceptions.html
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=795367
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test mozGetUserMedia Exceptions</title>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="head.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795367">Test mozGetUserMedia Exceptions</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/**
+  These tests verify that the appropriate exception is thrown when incorrect
+  values are provided to the immediate mozGetUserMedia call.
+*/
+var exceptionTests = [
+  // Each test here verifies that a caller is required to have all
+  // three arguments in order to call mozGetUserMedia
+  { params: undefined,
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
+    message: "no arguments specified" },
+  { params: [{video: true, fake: true}],
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
+    message: "one argument specified" },
+  { params: [{video: true, fake: true}, unexpectedCall],
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
+    message: "two arguments specified" },
+
+  // Each test here verifies that providing an incorret object
+  // type to any mozGetUserMedia parameter should throw
+  // the correct exception specified
+  { params: [1, unexpectedCall, unexpectedCall],
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
+    message: "wrong object type as first parameter" },
+  { params: [{video: true, fake: true}, 1, unexpectedCall],
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
+    message: "wrong object type as second parameter" },
+  { params: [{video: true, fake: true}, unexpectedCall, 1],
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
+    message: "wrong object type as third parameter" }
+];
+
+/**
+ * A callback function that is only called if a particular
+ * exception was not thrown, resulting in the test failing.
+ *
+ * @param  {MediaStream} argument ignored
+ */
+function unexpectedCall(obj) {
+  ok(false, "Callback should not have been called");
+}
+
+/**
+ * Starts the test run by running through each exception
+ * test by verifying that the correct exception type specified
+ * is thrown on the mozGetUserMedia call with the parameters
+ * specified.
+ */
+runTest(function () {
+  exceptionTests.forEach(function (test) {
+    var exception = false;
+    try {
+      navigator.mozGetUserMedia.apply(navigator, test.params);
+    } catch (e) {
+      exception = (e.result === test.error);
+    }
+    ok(exception, "Exception for " + test.message);
+  });
+
+  SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/dom/tests/mochitest/Makefile.in
+++ b/dom/tests/mochitest/Makefile.in
@@ -17,17 +17,16 @@ DIRS	+= \
 	dom-level2-html \
 	ajax \
 	bugs \
 	chrome \
 	general \
 	whatwg \
 	geolocation \
 	localstorage \
-	media \
 	orientation \
 	sessionstorage \
 	storageevent \
 	pointerlock \
 	webapps \
 	$(NULL)
 
 #needs IPC support, also tests do not run successfully in Firefox for now
deleted file mode 100644
--- a/dom/tests/mochitest/media/Makefile.in
+++ /dev/null
@@ -1,18 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES	= \
-  test_getUserMedia_exceptions.html \
-  head.js \
-  $(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/dom/tests/mochitest/media/head.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-var Cc = SpecialPowers.Cc;
-var Ci = SpecialPowers.Ci;
-var Cr = SpecialPowers.Cr;
-
-/**
- * Setup any Mochitest for WebRTC by enabling the preference for
- * peer connections. As by bug 797979 it will also enable mozGetUserMedia().
- * Additionally, we disable the permissions prompt for these mochitests.
- *
- * @param {Function} aCallback Test method to execute after initialization
- */
-function runTest(aCallback) {
-  SimpleTest.waitForExplicitFinish();
-
-  SpecialPowers.pushPrefEnv({'set': [['media.peerconnection.enabled', true],
-                            ['media.navigator.permission.disabled', true]]},
-                            aCallback);
-}
deleted file mode 100644
--- a/dom/tests/mochitest/media/test_getUserMedia_exceptions.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=795367
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test mozGetUserMedia Exceptions</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="head.js"></script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795367">Test mozGetUserMedia Exceptions</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/**
-  These tests verify that the appropriate exception is thrown when incorrect
-  values are provided to the immediate mozGetUserMedia call.
-*/
-var exceptionTests = [
-  // Each test here verifies that a caller is required to have all
-  // three arguments in order to call mozGetUserMedia
-  { params: undefined,
-    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
-    message: "no arguments specified" },
-  { params: [{video: true, fake: true}],
-    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
-    message: "one argument specified" },
-  { params: [{video: true, fake: true}, unexpectedCall],
-    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
-    message: "two arguments specified" },
-
-  // Each test here verifies that providing an incorret object
-  // type to any mozGetUserMedia parameter should throw
-  // the correct exception specified
-  { params: [1, unexpectedCall, unexpectedCall],
-    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
-    message: "wrong object type as first parameter" },
-  { params: [{video: true, fake: true}, 1, unexpectedCall],
-    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
-    message: "wrong object type as second parameter" },
-  { params: [{video: true, fake: true}, unexpectedCall, 1],
-    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
-    message: "wrong object type as third parameter" }
-];
-
-/**
- * A callback function that is only called if a particular
- * exception was not thrown, resulting in the test failing.
- *
- * @param  {MediaStream} argument ignored
- */
-function unexpectedCall(obj) {
-  ok(false, "Callback should not have been called");
-}
-
-/**
- * Starts the test run by running through each exception
- * test by verifying that the correct exception type specified
- * is thrown on the mozGetUserMedia call with the parameters
- * specified.
- */
-runTest(function () {
-  exceptionTests.forEach(function (test) {
-    var exception = false;
-    try {
-      navigator.mozGetUserMedia.apply(navigator, test.params);
-    } catch (e) {
-      exception = (e.result === test.error);
-    }
-    ok(exception, "Exception for " + test.message);
-  });
-
-  SimpleTest.finish();
-});
-
-</script>
-</pre>
-</body>
-</html>