Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move real-browser-only tests out of the main tests.

  • Loading branch information...
commit 87195b26c760889c43da8d1e05f69959620c99ce 1 parent 870bb80
@domenic domenic authored
View
7 package.json
@@ -20,12 +20,15 @@
"scripts": {
"lint": "jshint setImmediate.js",
"test": "mocha test/tests.js",
- "test-browser": "zuul --server 9000 test/tests.js --wwwroot test/"
+ "test-browser": "opener http://localhost:9000 && zuul --server 9000 test/tests.js --wwwroot test/",
+ "test-browser-only": "opener http://localhost:9007/test/browserOnly/index.html && http-server . -p 9007"
},
"devDependencies": {
"jshint": ">= 0.9.1",
"mocha": ">= 1.7.4",
- "zuul": ">= 0.0.1"
+ "zuul": ">= 0.0.1",
+ "http-server": ">= 0.5.3",
+ "opener": ">= 1.1.0"
},
"testling": {
"browsers": {
View
16 test/browserOnly/index.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>Real-Browser Only setImmediate Tests</title>
+ <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
+ </head>
+ <body>
+ <div id="mocha"></div>
+ <script src="../../node_modules/mocha/mocha.js"></script>
+ <script>mocha.setup({ ui: "bdd", slow: Infinity });</script>
+ <script src="../../setImmediate.js"></script>
+ <script src="./tests.js"></script>
+ <script>mocha.run();</script>
+ </body>
+</html>
View
0  test/selfClose.htm → test/browserOnly/selfClose.htm
File renamed without changes
View
45 test/browserOnly/tests.js
@@ -0,0 +1,45 @@
+"use strict";
+/*global setImmediate: false, specify: false, window: false */
+
+function assert(condition) {
+ if (!condition) {
+ throw new Error("Assertion failed");
+ }
+}
+assert.strictEqual = function (x, y) {
+ if (x !== y) {
+ throw new Error(x + " !== " + y);
+ }
+};
+
+specify("Modal dialogs block handlers", function (done) {
+ // Try to launch the less-annoying self-closing-window modal dialog; if that's not an option, fall back to alert.
+ var showTheDialog = window.showModalDialog ?
+ function () {
+ window.showModalDialog("selfClose.htm");
+ }
+ : function () {
+ window.alert("Please press OK to continue the test; we needed a modal dialog.");
+ };
+
+ var dialogClosed = false;
+ setImmediate(function () {
+ showTheDialog();
+ dialogClosed = true;
+ });
+
+ setImmediate(function () {
+ assert(dialogClosed);
+ done();
+ });
+});
+
+if (typeof window.Worker === "function") {
+ specify("When inside a web worker context, setImmediate calls the passed handler", function (done) {
+ var worker = new window.Worker("worker.js");
+ worker.addEventListener("message", function (event) {
+ assert.strictEqual(event.data, "TEST");
+ done();
+ }, false);
+ });
+}
View
4 test/worker.js → test/browserOnly/worker.js
@@ -1,5 +1,5 @@
-importScripts("../setImmediate.js");
+importScripts("../../setImmediate.js");
setImmediate(function () {
self.postMessage("TEST");
-});
+});
View
34 test/tests.js
@@ -78,37 +78,3 @@ specify("`clearImmediate` does not interfere with handlers other than the one wi
done();
}, 100);
});
-
-if (typeof window !== "undefined") {
- specify.skip("Modal dialogs block handlers", function (done) {
- // Try to launch the less-annoying self-closing-window modal dialog; if that's not an option, fall back to alert.
- var showTheDialog = window.showModalDialog ?
- function () {
- window.showModalDialog("selfClose.htm");
- }
- : function () {
- window.alert("Please press OK to continue the test; we needed a modal dialog.");
- };
-
- var dialogClosed = false;
- setImmediate(function () {
- showTheDialog();
- dialogClosed = true;
- });
-
- setImmediate(function () {
- assert(dialogClosed);
- done();
- });
- });
-}
-
-if (typeof window !== "undefined" && typeof window.Worker === "function") {
- specify.skip("When inside a web worker context, setImmediate calls the passed handler", function (done) {
- var worker = new window.Worker("worker.js");
- worker.addEventListener("message", function (event) {
- assert.strictEqual(event.data, "TEST");
- done();
- }, false);
- });
-}
Please sign in to comment.
Something went wrong with that request. Please try again.