Skip to content

Instantly share code, notes, and snippets.

@hamiltont
Created September 6, 2014 14:56
Show Gist options
  • Save hamiltont/7b149024a1a31ee30fa6 to your computer and use it in GitHub Desktop.
Save hamiltont/7b149024a1a31ee30fa6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var fs = require("fs");
var som = fs.readFileSync("./api.js", "utf-8");
var jsdom = require("jsdom");
function onError(error) {
console.log("ERROR: " + error.code + ": "+ error.message);
}
function onComplete(testResult) {
console.log('complete');
console.log(testResult);
}
jsdom.env({
html: '<html><body>test</body></html>',
src: [som],
done: function (errors, window) {
console.log("loaded");
window.console = console;
window.location.host = "hamiltont.me";
window.location.hostname = "hamiltont.me";
console.log("Triggering load finished");
console.log("Trying method two...");
var evt = window.document.createEvent ("MessageEvent");
evt["data"] = "";
evt["origin"] = "http://speedof.me";
evt["source"] = window;
window.receiveMessage(evt);
var SomApi = window.SomApi;
var s3H = window.s3H;
SomApi.account = "--removed--"; //your API Key here
SomApi.domainName = "hamiltont.me"; //your domain or sub-domain here
SomApi.config.sustainTime = 4;
SomApi.onTestCompleted = onComplete;
SomApi.onError = onError;
SomApi.config.progress.enabled = false;
console.log("Working with...");
console.log(SomApi);
SomApi.startTest();
console.log('Done?');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment