Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #48, do not inject HTML into served JS files.

Add a functional test that requires a JS file served by Yeti.
  • Loading branch information...
commit f25fdb93ef6e68adfb6dac4c1e3e39a271fe8f8f 1 parent 6e7c4b3
@reid reid authored
View
2  lib/hub/test-server.js
@@ -45,12 +45,12 @@ TestServer.prototype.serve = function (server, filename, buffer) {
switch (headers["Content-Type"]) {
case "text/html":
injectScript = true;
+ headers["Content-Type"] += "; charset=utf-8";
break;
case "application/javascript":
case "application/xml":
case "text/css":
case "text/plain":
- injectScript = true;
headers["Content-Type"] += "; charset=utf-8";
break;
}
View
5 test/fixture/local-js.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<title>Yeti Local JS Test</title>
+<p>This test requires external JavaScript that will be served by Yeti's server.</p>
+<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.4.1/build/yui-base/yui-base-min.js&3.4.1/build/oop/oop-min.js&3.4.1/build/event-custom-base/event-custom-base-min.js&3.4.1/build/event-base/event-base-min.js&3.4.1/build/event-simulate/event-simulate-min.js&3.4.1/build/event-custom-complex/event-custom-complex-min.js&3.4.1/build/substitute/substitute-min.js&3.4.1/build/json-stringify/json-stringify-min.js&3.4.1/build/test/test-min.js"></script>
+<script src="local-js.js"></script>
View
16 test/fixture/local-js.js
@@ -0,0 +1,16 @@
+YUI().use("test", function (Y) {
+ var LocalJSTestCase = new Y.Test.Case({
+ name: "Yeti Local JS Test Case",
+ testOk: function () {
+ Y.Assert.areEqual(1, 1);
+ }
+ });
+
+ var LocalJSSuite = new Y.Test.Suite("Yeti Local JS Test Suite");
+
+ LocalJSSuite.add(LocalJSTestCase);
+
+ Y.Test.Runner.add(LocalJSSuite);
+
+ Y.Test.Runner.run();
+});
View
11 test/functional.js
@@ -68,7 +68,7 @@ function visitorContext() {
}, 20000),
batch = lastTopic.client.createBatch({
basedir: __dirname + "/fixture",
- tests: ["basic.html"]
+ tests: ["basic.html", "local-js.html"]
});
batch.on("agentResult", function (agent, details) {
@@ -111,15 +111,16 @@ function visitorContext() {
"the agentComplete event fired once": function (topic) {
assert.strictEqual(topic.agentCompleteFires, 1);
},
- "the agentSeen event fired 3 times": function (topic) {
+ "the agentSeen event fired 4 times": function (topic) {
// 1. Capture page.
// 2. Test page.
- // 3. Return to capture page.
- assert.strictEqual(topic.agentSeenFires, 3);
+ // 3. Another test page.
+ // 4. Return to capture page.
+ assert.strictEqual(topic.agentSeenFires, 4);
},
"the agentResults are well-formed": function (topic) {
assert.isArray(topic.agentResults);
- assert.strictEqual(topic.agentResults.length, 1);
+ assert.strictEqual(topic.agentResults.length, 2);
var result = topic.agentResults[0];
Please sign in to comment.
Something went wrong with that request. Please try again.