Skip to content

Instantly share code, notes, and snippets.

@hallvors
Last active November 5, 2015 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallvors/aeda242d8c1461fda5f7 to your computer and use it in GitHub Desktop.
Save hallvors/aeda242d8c1461fda5f7 to your computer and use it in GitHub Desktop.
Boar testing experiment
"use strict";
var assert = require('assert');
var request = require('request');
require('should');
var serviceURL, released, instance;
//Running simple http server here you can see when tab becomes available
require('http').createServer((req, resp) => {
let body = '';
req.on('data', (chunck) => {
body += chunck.toString();
});
req.once('end', () => {
console.info('Got request for hub url %s with `%s` body', req.url, body);
});
if(req.url === '/announceTab' && !released) {
instance.release();
released = true;
}
resp.write('{}');
resp.end();
}).listen(8779);
beforeEach(function(done){
this.timeout(10000);
instance = new (require('../').Summoner)('gecko', '127.0.0.1', 8778, 8779, (error, data) => {
if(error) {
throw error;
}
serviceURL = data.url;
console.info('Tab released it can be access using ' + data.url);
done();
});
});
describe('plugins', function() {
describe('window.orientation', function () {
it('page with getter', function(done){
console.log(serviceURL + '/open')
request.post(serviceURL + '/open', {
headers: {'Content-type': 'application/json', 'Accept': 'text/plain'},
body: JSON.stringify({"url": "data:text/html,<script>var foo=window.orientation</script><p>Hello test</p>", "waitForResources":false})
}, function(err, response, body){
// Why is body 'Bad request' here??
request.get(serviceURL + '/getPluginsResults', {}, function(err, response, body) {
var data = JSON.parse(body);
data.results['window-orientation-usage'].should.equal(true);
request.post(serviceURL + '/destroy', {}, function(){
done();
});
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment