Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into content-type-body
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jan 18, 2016
2 parents 88ed535 + 4e00ced commit 46a8e77
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 69 deletions.
5 changes: 4 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"esnext": true,
"eqnull": true,
"browser": true,
"worker": true
"worker": true,
"globals": {
"JSON": false
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "whatwg-fetch",
"description": "A window.fetch polyfill.",
"version": "0.10.1",
"main": "fetch.js",
"repository": "github/fetch",
Expand All @@ -12,10 +13,10 @@
"devDependencies": {
"bower": "1.3.8",
"chai": "1.10.0",
"jshint": "2.5.2",
"jshint": "2.8.0",
"mocha-phantomjs": "3.5.2",
"mocha": "2.1.0",
"phantomjs": "1.9.13"
"phantomjs": "1.9.19"
},
"files" : [
"LICENSE",
Expand Down
15 changes: 13 additions & 2 deletions script/phantomjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ node ./script/server $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT

node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test.html"
node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test-worker.html"
STATUS=0

run() {
node ./node_modules/.bin/mocha-phantomjs \
-s localToRemoteUrlAccessEnabled=true \
-s webSecurityEnabled=false \
"$@" || STATUS=$?
}

run "http://localhost:$port/"
run "http://localhost:$port/test/test-worker.html"

exit $STATUS
2 changes: 1 addition & 1 deletion script/saucelabs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ job="$(./script/saucelabs-api --raw "js-tests" <<JSON
"tags": ["$TRAVIS_PULL_REQUEST", "$TRAVIS_BRANCH"],
"tunnel-identifier": "$TRAVIS_JOB_NUMBER",
"platforms": [["$SAUCE_PLATFORM", "$SAUCE_BROWSER", "$SAUCE_VERSION"]],
"url": "http://localhost:$port/test/test.html",
"url": "http://localhost:$port/",
"framework": "mocha"
}
JSON
Expand Down
9 changes: 7 additions & 2 deletions script/server
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ var types = {
txt: 'text/plain'
};

http.createServer(function(req, res) {
server = http.createServer(function(req, res) {
var pathname = url.parse(req.url).pathname;
var route = routes[pathname];
if (route) {
route(res, req);
} else {
if (pathname == '/') pathname = '/test/test.html'
fs.readFile(__dirname + '/..' + pathname, function(err, data) {
if (err) {
res.writeHead(404, {'Content-Type': types.txt});
Expand All @@ -140,4 +141,8 @@ http.createServer(function(req, res) {
}
});
}
}).listen(port);
});

console.warn("Started test server on localhost:" + port);
server.listen(port);

21 changes: 4 additions & 17 deletions test/.jshintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": true,
"undef": true,
"unused": true,
"trailing": true,
"asi": true,
"boss": true,
"esnext": true,
"extends": "../.jshintrc",
"es3": false,
"strict": false,
"sub": true,
"eqnull": true,
"browser": true,
"worker": true,
"globals": {
"fetch": false,
"Headers": false,
Expand All @@ -26,6 +12,7 @@
"chai": false,
"suite": false,
"setup": false,
"suiteSetup": false,
"test": false,
"assert": false
}
Expand Down
6 changes: 3 additions & 3 deletions test/test-worker.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<head>
<meta charset="utf-8">
<title>Fetch Worker Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>

<script>
mocha.setup('tdd')

var worker = new Worker('worker.js')
var worker = new Worker('/test/worker.js')

worker.addEventListener('message', function(e) {
switch (e.data.name) {
Expand Down
21 changes: 12 additions & 9 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
<head>
<meta charset="utf-8">
<title>Fetch Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="/node_modules/chai/chai.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>
<script>
mocha.setup('tdd')
self.assert = chai.assert
if (self.mocha && mocha.setup) {
mocha.setup('tdd')
self.assert = chai.assert
} else {
document.write('<p>Error: please run <code>make</code> to install dependencies and try again.</p>')
}
</script>

<script src="../bower_components/es6-promise/promise.js"></script>
<script src="../fetch.js"></script>

<script src="test.js"></script>
<script src="/bower_components/es6-promise/promise.js"></script>
<script src="/test/test.js"></script>
<script src="/fetch.js"></script>

<script>
if (self.mochaPhantomJS) {
Expand Down
Loading

0 comments on commit 46a8e77

Please sign in to comment.