forked from mozilla/fathom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Travis now runs a local HTTP server[1] in a background process, and the functional test opens a locally hosted test page. I also moved all functional test files to a new directory: test/functional Finally, since test scripts are never going to be imported as ES6 modules, I made the test a .js file rather than a .jsm. Note: if I were to leave it as a .jsm, I would have wanted to change the 'require' statements to 'import' statements to keep consistent with the other .mjs files. These .mjs files get transpiled via Babel into CommonJS .js files (i.e. using 'require' statements) as a build step. [1]: I did quite a lot of deliberation about whether an HTTP server would be sufficient (compared to an HTTPS server) and determined it was. Ultimately, I adhered to one of the principles of extreme programming (thanks Daniel): don't add functionality until it's necessary. Here is my reasoning (I spoke with a Mozilla security engineer who works on certificates): * TravisCI's default environment runs each build on a [single machine](https://docs.travis-ci.com/user/reference/trusty/#using-trusty) * This means we are running the server on the loopback interface, and there shouldn't be much risk -- particularly since we don't have any secrets. * The only downside is there are some [DOM APIs that only work in secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts/features_restricted_to_secure_contexts) -- none of which we are using currently. But Firefox is working on enabling these APIs in this case where everything is on the same machine.
- Loading branch information
1 parent
8711868
commit 34c04b0
Showing
5 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
**/*.js | ||
!/rollup.config.js | ||
!/trainees.js | ||
!/test/functional/* | ||
/cli/build | ||
/cli/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link rel="shortcut icon" href=""> | ||
<title></title> | ||
</head> | ||
<body> | ||
<h1 id="title">Functional Testing Page - isVisible</h1> | ||
<img id="image" src="https://www.mozilla.org/media/protocol/img/logos/mozilla/white.612a25fa976b.svg"> | ||
<script> | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const http = require('http'); | ||
const fs = require('fs'); | ||
const url = require('url'); | ||
|
||
const PORT = 8000; | ||
|
||
const server = http.createServer((request, response) => { | ||
const path = url.parse(request.url).pathname; | ||
fs.readFile(__dirname + path, 'utf8', (error, data) => { | ||
if (error) { | ||
response.writeHead(404); | ||
response.write(`There was an error: ${error.errno}, ${error.code}`); | ||
response.end(); | ||
} else { | ||
response.writeHead(200, {'Content-Type': 'text/html'}); | ||
response.write(data); | ||
response.end(); | ||
} | ||
}); | ||
}); | ||
server.listen(PORT); | ||
console.log(`Serving from ${__dirname} at http://localhost:${PORT}...`); |