Skip to content

Commit 5beb481

Browse files
committed
Abandon <iframe> test isolation hack now that we have dumpCache.
This cuts the running time of `grunt phantom:run` from 4.4s to 3.1s on my machine, because we no longer have to load/execute a separate instance of `react-test.js` in a separate `<iframe>` for each test.
1 parent 7ef5172 commit 5beb481

File tree

5 files changed

+16
-45
lines changed

5 files changed

+16
-45
lines changed

grunt/config/populist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var jasmine = {
1111

1212
var test = {
1313
rootDirectory: "build/modules",
14-
args: ["test/all:"],
14+
args: ["test/all:harness"],
1515
requires: [
1616
"**/__tests__/*-test.js"
1717
],

src/test/all.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ var Ap = Array.prototype;
66
var slice = Ap.slice;
77
var Fp = Function.prototype;
88

9-
var global = Function("return this")();
10-
global.require = require;
11-
129
if (!Fp.bind) {
1310
// PhantomJS doesn't support Function.prototype.bind natively, so
1411
// polyfill it whenever this module is required.
@@ -58,3 +55,7 @@ require("reactComponentExpect");
5855
require("mocks");
5956
require("mock-modules");
6057
require("./mock-timers");
58+
59+
exports.enableTest = function(testID) {
60+
require("../" + testID);
61+
};

test/frame.html

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/index.html

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
<html>
33
<head>
44
<link rel="stylesheet" type="text/css" href="jasmine.css" />
5-
<style type="text/css">
6-
iframe {
7-
visibility: hidden;
8-
position: absolute;
9-
left: -1000px;
10-
top: -1000px;
11-
}
12-
</style>
135
<script src="jasmine.js"></script>
14-
<script>
15-
window.onload = function() {
16-
jasmine.getEnv().execute();
17-
};
18-
</script>
6+
<script src="react-test.js"></script>
197
</head>
208
<body>
9+
<script>
10+
ENABLE_TESTS_HERE
11+
jasmine.getEnv().execute();
12+
</script>
2113
</body>
2214
</html>

test/phantom-harness.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ while (argv.length > 0) {
3434
rest.push(arg);
3535
}
3636

37-
// Dynamically interpolate the individual test <iframe>s.
37+
// Dynamically enable the individual tests.
3838
var indexHtml = fs.read("index.html").replace(
39-
/<body>([\s\S]*?)<\/body>/im,
40-
function(outer, inner) {
41-
return "<body>" + tests.map(function(test) {
42-
return '\n <iframe src="frame.html" test=' +
43-
JSON.stringify(test) + '></iframe>';
44-
}).join("") + inner + "</body>";
39+
/^(\s*)ENABLE_TESTS_HERE/m,
40+
function(placeholder, leadingSpace) {
41+
return leadingSpace + tests.map(function(testID) {
42+
return "harness.enableTest(" + JSON.stringify(testID) + ");";
43+
}).join("\n" + leadingSpace);
4544
}
4645
);
4746

@@ -63,9 +62,6 @@ server.listen(port, function(req, res) {
6362
file = "../build/" + file;
6463
break;
6564

66-
case "frame.html":
67-
break;
68-
6965
case "":
7066
default:
7167
file = "index.html";

0 commit comments

Comments
 (0)