Skip to content

Commit

Permalink
fix(snippet): Always use full url path for scripts - fixes #437
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Feb 17, 2015
1 parent ccd688d commit 14bd6f5
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/connect-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var connectUtils = {
}

if (!override && (options.get("server") || options.get("proxy"))) {
script = scriptPath;
script = getPath(scriptPath, options.get("port"));
}

template = template
Expand Down Expand Up @@ -90,8 +90,8 @@ var connectUtils = {

return {
host: external
? "hostname"
: "host",
? "hostname"
: "host",
namespace: (function (external) {

return external
Expand Down
62 changes: 62 additions & 0 deletions test/fixtures/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>Forms</title>
<link rel="stylesheet" href="assets/style.css"/>
<base href="http://www.google.com/" />

</head>
<body>
<div class="container">
<h1>Browser Sync Ghost Mode: Form sync</h1>

<p>Links: synced</p>
<a href="index.html">Hompage</a>

<form id="form-01">
<p><label for="name">Text Inputs: synced</label></p>
<input type="text" name="name" value="" id="name"/>

<p><label for="email">Email Inputs: synced</label></p>
<input type="email" name="email" value="" id="email"/>
<p><label for="password">Passwords Inputs: synced</label></p>
<input type="password" name="password" value="" id="password"/>

<p><label for="country">Select Boxes: synced</label></p>
<select name="country" id="country">
<option value="uk">Uk</option>
<option value="spain">Spain</option>
<option value="france">France</option>
</select>

<p>Radio Buttons: synced </p>

<p>
<label for="confirm-1">Yes</label>
<input type="radio" name="confirm" id="confirm-1" value="1"/>
<label for="confirm-0">No</label>
<input type="radio" name="confirm" id="confirm-0" value="0"/>
</p>

<p>Check Boxes: synced</p>

<div>
<label for="option-1">Option 1</label>
<input type="checkbox" name="checkbox" id="option-1">
<label for="option-2">Option 2</label>
<input type="checkbox" name="checkbox" id="option-2">
</div>

<p><label for="message">Text Areas: synced</label></p>
<textarea name="message" id="message" cols="30" rows="10"></textarea>

<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>

</div>
</body>
</html>
3 changes: 2 additions & 1 deletion test/protractor/config.single.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports.config = {
"tests/actions.scroll.js",
"tests/server.interactions.js",
"tests/proxy.interactions.js",
"tests/with.socket.io.js"
"tests/with.baseurl.js",
//"tests/with.socket.io.js"
]
};
40 changes: 40 additions & 0 deletions test/protractor/tests/with.baseurl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use strict";

var init = require("../bs.init");

describe("works when base url set in HTML", function () {
var instance;
var urls;
beforeEach(function () {
browser.ignoreSynchronization = true;
if (instance) {
return;
}
var config = {
server: {
baseDir: "test/fixtures",
routes: {
"/lib": "./lib"
}
},
open: false,
logLevel: "silent",
ui: false
};
init(protractor, config).then(function (bs) {
instance = bs;
urls = instance.getOption("urls").toJS();
});
});
it("should ", function () {

browser.get(urls.local + "/base.html");

assertScripts();
});
});

function assertScripts () {
expect(element(by.id("__bs_script__")).isPresent()).toBeTruthy();
expect(element(by.id("__bs_notify__")).isPresent()).toBeTruthy();
}
2 changes: 1 addition & 1 deletion test/specs/instances/multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("E2E server test", function () {
.set("accept", "text/html")
.expect(200)
.end(function (err, res) {
assert.include(res.text, snippet);
assert.isTrue(res.text.indexOf(snippet2) > -1);
done();
});
});
Expand Down

0 comments on commit 14bd6f5

Please sign in to comment.