Comparing version 13.1.1 to 13.1.2
@@ -148,3 +148,3 @@ var util = require("util"), EventEmitter = require("events").EventEmitter, vfs = require("./vfs"), VirtualFS = vfs.VirtualFS, errMsgBuilder = require("./err_msg_builder"), ERR = require("./server_errs"); | ||
Api.prototype.listDirectory = function() { | ||
var path = null, callback = null; | ||
var path = null, vfsPath = [], callback = null; | ||
if (arguments.length === 2) { | ||
@@ -156,3 +156,5 @@ path = arguments[0]; | ||
} | ||
var vfsPath = path || []; | ||
if (path && path !== "/") { | ||
vfsPath = path; | ||
} | ||
if (typeof vfsPath === "string") { | ||
@@ -159,0 +161,0 @@ vfsPath = vfs.getPlatformDependentPath(vfsPath); |
@@ -393,4 +393,4 @@ var path = require("path"), util = require("util"), http = require("http"), EventEmitter = require("events").EventEmitter, express = require("express"), io = require("socket.io"), ejs = require("ejs"), WorkerPool = require("./worker_pool").WorkerPool, errMsgBuilder = require("./err_msg_builder"), ERR = require("./server_errs"); | ||
ControlPanel.prototype._createFixture = function(req, res) { | ||
var urlPath = req.param("curPath") || "", fixtureName = req.param("fixtureName"), fixturePage = req.param("fixturePage"), filename = req.param("filename"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.createFixture(vfsPath, fixtureName, filename, fixturePage, function(err) { | ||
var urlPath = req.param("curPath") || "", fixtureName = req.param("fixtureName"), fixturePage = req.param("fixturePage"), filename = req.param("filename"), fixtureUsername = req.param("fixtureUsername"), fixturePassword = req.param("fixturePassword"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.createFixture(vfsPath, fixtureName, filename, fixturePage, fixtureUsername, fixturePassword, function(err) { | ||
if (!err) { | ||
@@ -407,4 +407,4 @@ res.status(204); | ||
ControlPanel.prototype._createFixtureInDir = function(req, res) { | ||
var urlPath = req.param("curPath") || "", fixtureName = req.param("fixtureName"), fixturePage = req.param("fixturePage"), filename = req.param("filename"), dirName = req.param("dirName"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.createFixtureInDir(vfsPath, dirName, fixtureName, filename, fixturePage, function(err) { | ||
var urlPath = req.param("curPath") || "", fixtureName = req.param("fixtureName"), fixturePage = req.param("fixturePage"), fixtureUsername = req.param("fixtureUsername"), fixturePassword = req.param("fixturePassword"), filename = req.param("filename"), dirName = req.param("dirName"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.createFixtureInDir(vfsPath, dirName, fixtureName, filename, fixturePage, fixtureUsername, fixturePassword, function(err) { | ||
if (!err) { | ||
@@ -421,4 +421,4 @@ res.status(204); | ||
ControlPanel.prototype._editFixture = function(req, res) { | ||
var urlPath = req.param("curPath") || "", newName = req.param("newName"), newPage = req.param("newPage"), oldFilename = req.param("oldFilename"), newFilename = req.param("newFilename"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.editFixture(vfsPath, oldFilename, newFilename, newName, newPage, function(err) { | ||
var urlPath = req.param("curPath") || "", newName = req.param("newName"), newPage = req.param("newPage"), oldFilename = req.param("oldFilename"), newFilename = req.param("newFilename"), newUsername = req.param("newUsername"), newPassword = req.param("newPassword"), vfsPath = urlPath ? decodeURI(urlPath).split("/") : []; | ||
this.vfs.editFixture(vfsPath, oldFilename, newFilename, newName, newPage, newUsername, newPassword, function(err) { | ||
if (!err) { | ||
@@ -425,0 +425,0 @@ res.status(204); |
@@ -1,2 +0,2 @@ | ||
var url = require("url"), util = require("util"), ERR = require("./server_errs"), CLIENT_ERR = require("./../shared/client_errs"); | ||
var url = require("url"), util = require("util"), FixtureCode = require("../fixture_code"), ERR = require("./server_errs"), CLIENT_ERR = require("./../shared/client_errs"); | ||
@@ -70,99 +70,107 @@ exports.UNKNOW_ERR_MSG = "UNKNOWN_ERROR"; | ||
case ERR.FIXTURE_FILE_READ_FILE_FAILED: | ||
case FixtureCode.ErrCodes.READ_FILE_FAILED: | ||
m('Failed to read test file "%s."', err.filename); | ||
break; | ||
case ERR.FIXTURE_FILE_PARSING_FAILED: | ||
case FixtureCode.ErrCodes.JAVASCRIPT_PARSING_FAILED: | ||
m("(line %s): %s", err.parserErr && err.parserErr.line, err.parserErr && err.parserErr.message); | ||
break; | ||
case ERR.FIXTURE_FILE_FIXTURE_DIRECTIVE_REDEFINITION: | ||
m("(line %s): @fixture directive redefinition. @fixture directive should be used once per test file.", err.line); | ||
case FixtureCode.ErrCodes.AUTH_DIRECTIVE_REDEFINITION: | ||
m("(line %s): @auth directive redefinition. @auth directive should be used once per test fixture file.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_PAGE_DIRECTIVE_REDEFINITION: | ||
m("(line %s): @page directive redefinition. @page directive should be used once per test file.", err.line); | ||
case FixtureCode.ErrCodes.FIXTURE_DIRECTIVE_REDEFINITION: | ||
m("(line %s): @fixture directive redefinition. @fixture directive should be used once per test fixture file.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_REQUIRED_FILE_ALREADY_INCLUDED: | ||
case FixtureCode.ErrCodes.PAGE_DIRECTIVE_REDEFINITION: | ||
m("(line %s): @page directive redefinition. @page directive should be used once per test fixture file.", err.line); | ||
break; | ||
case FixtureCode.ErrCodes.INVALID_NETWORK_AUTHENTICATION_CREDENTIALS_FORMAT: | ||
m("(line %s): network authentication credentials have incorrect format. @auth directive should use the " + 'following format: "@auth username:password".', err.line); | ||
break; | ||
case FixtureCode.ErrCodes.REQUIRED_FILE_ALREADY_INCLUDED: | ||
m('(line %s): Required file "%s" is already included.', err.line, err.req); | ||
break; | ||
case ERR.FIXTURE_FILE_MISPLACED_DIRECTIVE: | ||
case FixtureCode.ErrCodes.MISPLACED_DIRECTIVE: | ||
m("(line %s): Misplaced directive. Directives (@fixture, @page, etc.) should be declared " + "on a global scope.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_MISPLACED_TEST_DIRECTIVE: | ||
case FixtureCode.ErrCodes.MISPLACED_TEST_DECLARATION: | ||
m("(line %s): Misplaced test directive. Tests should be declared on a global scope.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_DUPLICATE_TEST_NAME: | ||
case FixtureCode.ErrCodes.DUPLICATE_TEST_NAME: | ||
m('(line %s): Test with name "%s" is alredy defined.', err.line, err.testName); | ||
break; | ||
case ERR.FIXTURE_FILE_TEST_NAME_CHANGED_TO_ALREADY_USED: | ||
case FixtureCode.ErrCodes.TEST_NAME_CHANGED_TO_ALREADY_USED: | ||
m('Test with name "%s" is alredy defined.', err.testName); | ||
break; | ||
case ERR.FIXTURE_FILE_EMPTY_TEST_NAME: | ||
case FixtureCode.ErrCodes.EMPTY_TEST_NAME: | ||
m("(line %s): Test name is not set.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_INVALID_TEST_ASSIGNMENT: | ||
case FixtureCode.ErrCodes.INVALID_TEST_ASSIGNMENT: | ||
m("(line %s): Invalid test assignment. Test should be an object.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_TEST_STEP_IS_NOT_A_FUNCTION: | ||
case FixtureCode.ErrCodes.TEST_STEP_IS_NOT_A_FUNCTION: | ||
m("(line %s): Test step is not a function.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_ACTION_FUNC_IS_NOT_A_LAST_ENTRY: | ||
case FixtureCode.ErrCodes.ACTION_FUNC_IS_NOT_A_LAST_ENTRY: | ||
m("(line %s): Action function call is not the last statement. Test step should not contain " + "any statements after a action function call.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_TEST_STEP_IS_EMPTY: | ||
case FixtureCode.ErrCodes.TEST_STEP_IS_EMPTY: | ||
m("(line %s): Test step doesn't contain any code.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_FIXTURE_DIRECTIVE_IS_UNDEFINED: | ||
case FixtureCode.ErrCodes.FIXTURE_DIRECTIVE_IS_UNDEFINED: | ||
m("%s: Fixture name is undefined. Test file should contain @fixture directive.", err.filename); | ||
break; | ||
case ERR.FIXTURE_FILE_PAGE_DIRECTIVE_IS_UNDEFINED: | ||
case FixtureCode.ErrCodes.PAGE_DIRECTIVE_IS_UNDEFINED: | ||
m("%s: Page URL is undefined. Test file should contain @page directive.", err.filename); | ||
break; | ||
case ERR.FIXTURE_FILE_ASYNC_FUNC_CALL: | ||
case FixtureCode.ErrCodes.ASYNC_FUNC_CALL: | ||
m("(line %s): Async function call. Test steps should not contain async functions calls, " + "use act.wait() instead.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_ACTION_FUNC_CALL_IN_SHARED_CODE: | ||
case FixtureCode.ErrCodes.ACTION_FUNC_CALL_IN_SHARED_CODE: | ||
m("An action function cannot be called from the shared code. It can be used within a " + "test step only.", err.filename, err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_FAILED_LOAD_REQUIRE: | ||
case FixtureCode.ErrCodes.FAILED_LOAD_REQUIRE: | ||
m('%s: Failed load required file "%s".', err.filename, err.req); | ||
break; | ||
case ERR.FIXTURE_FILE_MODULE_NOT_FOUND: | ||
case FixtureCode.ErrCodes.MODULE_NOT_FOUND: | ||
m('(line %s): Required module "%s" does not exists.', err.line, err.moduleName); | ||
break; | ||
case ERR.FIXTURE_FILE_TEST_IS_EMPTY: | ||
case FixtureCode.ErrCodes.TEST_IS_EMPTY: | ||
m("(line %s): Test doesn't contain any code.", err.line); | ||
break; | ||
case ERR.FIXTURE_FILE_WRITE_FILE_FAILED: | ||
case FixtureCode.ErrCodes.WRITE_FILE_FAILED: | ||
m('Failed to write test fixture code to the "%s" file.', err.filename); | ||
break; | ||
case ERR.FIXTURE_FILE_INVALID_FILE_FORMAT: | ||
case FixtureCode.ErrCodes.INVALID_FILE_FORMAT: | ||
m('Failed to perform the operation because the "%s" test fixture file is not valid.', err.filename); | ||
break; | ||
case ERR.FIXTURE_FILE_ELEMENT_SELECTOR_PARSING_FAILED: | ||
case FixtureCode.ErrCodes.ELEMENT_SELECTOR_PARSING_FAILED: | ||
m("Failed to generate test code due to a syntax error in an element selector: %s", err.parserErr && err.parserErr.message); | ||
break; | ||
case ERR.FIXTURE_FILE_TEST_IS_NOT_FOUND: | ||
case FixtureCode.ErrCodes.TEST_IS_NOT_FOUND: | ||
m("Test %s is not found in this fixture", err.testName); | ||
@@ -192,11 +200,11 @@ break; | ||
case ERR.PROXY_ORIGIN_SERVER_CONNECTION_TERMINATED: | ||
m('Failed to perform a request for the "%s" resource because origin server connection was unexpectedly ' + "terminated.", err.ctx && err.ctx.originResourceInfo.url); | ||
m('Failed to perform a request for the "%s" resource because origin server connection was unexpectedly ' + "terminated.", err.originUrl); | ||
break; | ||
case ERR.PROXY_CANT_RESOLVE_ORIGIN_URL: | ||
m('Failed to find DNS-record for the "%s" resource.', err.ctx && err.ctx.originResourceInfo.url); | ||
m('Failed to find DNS-record for the "%s" resource.', err.originUrl); | ||
break; | ||
case ERR.PROXY_XHR_REQUEST_SAME_ORIGIN_POLICY_VIOLATION: | ||
m('XMLHttpRequest from page "%s" to URL "%s" violates Same Origin Policy. XMLHttpRequest URL domain ' + "should match the current page domain", err.ctx && err.ctx.originResourceInfo.reqOrigin, err.ctx && err.ctx.originResourceInfo.url); | ||
m('XMLHttpRequest from page "%s" to URL "%s" violates Same Origin Policy. XMLHttpRequest URL domain ' + "should match the current page domain", err.reqOrigin, err.xhrReqUrl); | ||
break; | ||
@@ -424,2 +432,10 @@ | ||
break; | ||
case CLIENT_ERR.API_INCORRECT_SELECT_ACTION_ARGUMENTS: | ||
m('Error on step "%s": select action parameters contains incorrect value.', err.stepName); | ||
break; | ||
case CLIENT_ERR.API_INCORRECT_WAIT_ACTION_FIRST_ARGUMENT: | ||
m('Error on step "%s": wait action first parameter contains incorrect value.', err.stepName); | ||
break; | ||
} | ||
@@ -426,0 +442,0 @@ return msg; |
@@ -201,2 +201,9 @@ var zlib = require("zlib"), whacko = require("whacko"), iconv = require("iconv-lite"), sharedConst = require("./../shared/const"), urlUtil = require("./../shared/url_util"), pageProc = require("./../shared/page_processor"), ERR = require("./server_errs"); | ||
}); | ||
}; | ||
exports.injectInJSON = function(chunks, encoding, charset, callback) { | ||
inject(chunks, encoding, charset, callback, function(rawData) { | ||
var isJSONP = !pageProc.isJSON(rawData); | ||
return isJSONP ? pageProc.processScript(rawData, true) : rawData; | ||
}); | ||
}; |
@@ -1,3 +0,22 @@ | ||
var http = require("http"), https = require("https"), url = require("url"), util = require("util"), os = require("os"), dns = require("dns"), EventEmitter = require("events").EventEmitter, assets = require("./assets"), injector = require("./injector"), urlUtil = require("./../shared/url_util"), sharedConst = require("./../shared/const"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"); | ||
var dns = require("dns"), EventEmitter = require("events").EventEmitter, http = require("http"), https = require("https"), os = require("os"), url = require("url"), util = require("util"), webauth = require("webauth"), assets = require("./assets"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"), exec = require("child_process").exec, injector = require("./injector"), sharedConst = require("./../shared/const"), urlUtil = require("./../shared/url_util"); | ||
var httpAgent = new http.Agent(), httpsAgent = new https.Agent(); | ||
httpAgent.maxSockets = httpsAgent.maxSockets = 128; | ||
var curUserDomain = "", curUserWorkstation = "", isWin = !!os.platform().match(/^win/); | ||
if (isWin) { | ||
exec("echo %userdomain%", function(error, domain) { | ||
if (!error) { | ||
curUserDomain = domain.replace(/\s/g, ""); | ||
} | ||
}); | ||
exec("hostname", function(error, hostname) { | ||
if (!error) { | ||
curUserWorkstation = hostname.replace(/\s/g, ""); | ||
} | ||
}); | ||
} | ||
function getContentLength(bodyChunks) { | ||
@@ -29,2 +48,3 @@ var length = 0; | ||
this.ownerDependentListeners = { | ||
authRequired: {}, | ||
beforeProxyResponse: {}, | ||
@@ -34,2 +54,3 @@ error: {}, | ||
}; | ||
this.evtListeners = []; | ||
this.port = port; | ||
@@ -39,3 +60,4 @@ this.hostname = hostname; | ||
this.server = http.createServer(function(req, res) { | ||
var isXhr = !!req.headers[sharedConst.XHR_REQUEST_MARKER_HEADER], ctx = { | ||
var parsedProxyUrl = urlUtil.parseProxyUrl(req.url); | ||
var isXhr = !!req.headers[sharedConst.XHR_REQUEST_MARKER_HEADER], isIFrame = parsedProxyUrl && parsedProxyUrl.isIFrame, ctx = { | ||
jobInfo: null, | ||
@@ -53,2 +75,3 @@ req: req, | ||
isXhr: isXhr, | ||
isIFrame: isIFrame, | ||
isPageReqCandidate: !isXhr && testForPageMime(req.headers["accept"]), | ||
@@ -87,2 +110,6 @@ originReqErr: false | ||
Proxy.prototype.addEventListener = function(ownerToken, listener) { | ||
this.evtListeners[ownerToken] = listener; | ||
}; | ||
Proxy.prototype._emitOwnerDependentEvent = function(evtName, ownerToken) { | ||
@@ -100,3 +127,3 @@ var params = Array.prototype.slice.call(arguments, 2), eventListeners = this.ownerDependentListeners[evtName]; | ||
Proxy.prototype._emitOwnerDependentErrorEvent = function(ctx, errObj) { | ||
Proxy.prototype._emitOwnerDependentErrorEvent = function(ctx, err) { | ||
if (!ctx.jobInfo || !this._hasOwnerDependentListener("error", ctx.jobInfo.ownerToken)) { | ||
@@ -106,8 +133,8 @@ ctx.res.statusCode = 500; | ||
} else { | ||
this._emitOwnerDependentEvent("error", ctx.jobInfo.ownerToken, errObj); | ||
this._emitOwnerDependentEvent("error", ctx.jobInfo.ownerToken, ctx, err); | ||
} | ||
}; | ||
Proxy.prototype.getProxyUrl = function(originUrl, jobUid, jobOwnerToken) { | ||
return urlUtil.getProxyUrl(originUrl, this.hostname, this.port, jobUid, jobOwnerToken); | ||
Proxy.prototype.getProxyUrl = function(originUrl, jobUid, jobOwnerToken, isIFrame) { | ||
return urlUtil.getProxyUrl(originUrl, this.hostname, this.port, jobUid, jobOwnerToken, isIFrame); | ||
}; | ||
@@ -117,3 +144,3 @@ | ||
var proxy = this; | ||
return function(resourceUrl) { | ||
return function(resourceUrl, isIFrame) { | ||
var baseUrl = urlUtil.getBaseUrl(); | ||
@@ -123,3 +150,3 @@ baseUrl = baseUrl ? url.resolve(ctx.originResourceInfo.url, baseUrl) : ""; | ||
try { | ||
return proxy.getProxyUrl(resolvedUrl, ctx.jobInfo.uid, ctx.jobInfo.ownerToken); | ||
return proxy.getProxyUrl(resolvedUrl, ctx.jobInfo.uid, ctx.jobInfo.ownerToken, isIFrame); | ||
} catch (err) { | ||
@@ -203,13 +230,5 @@ return resourceUrl; | ||
} | ||
var jobInfo = { | ||
uid: ctx.jobInfo.uid, | ||
ownerToken: ctx.jobInfo.ownerToken | ||
}; | ||
var getOriginUrl = function() { | ||
var reqInfo = urlUtil.parseProxyUrl(msg.url); | ||
return reqInfo ? url.format(reqInfo.originResourceInfo) : msg.url; | ||
}; | ||
var sendServiceResponse = function(res) { | ||
if (res !== null && typeof res !== "undefined") { | ||
ctx.res.end(JSON.stringify(res)); | ||
var sendServiceResponse = function(data) { | ||
if (data !== null && typeof data !== "undefined") { | ||
ctx.res.end(JSON.stringify(data)); | ||
} else { | ||
@@ -219,15 +238,11 @@ ctx.res.end(); | ||
}; | ||
switch (msg.cmd) { | ||
case cmd.SET_COOKIE: | ||
var proxy = this, originUrl = getOriginUrl(); | ||
if (msg.cmd === cmd.SET_COOKIE) { | ||
var proxy = this, reqInfo = urlUtil.parseProxyUrl(msg.url), originUrl = reqInfo ? url.format(reqInfo.originResourceInfo) : msg.url, jobInfo = { | ||
uid: ctx.jobInfo.uid, | ||
ownerToken: ctx.jobInfo.ownerToken | ||
}; | ||
this.cookieShelf.setCookieByClient(jobInfo, originUrl, msg.cookie, function() { | ||
proxy.cookieShelf.getClientCookieString(jobInfo, originUrl, sendServiceResponse); | ||
}); | ||
break; | ||
case cmd.GET_COOKIE: | ||
this.cookieShelf.getClientCookieString(jobInfo, getOriginUrl(), sendServiceResponse); | ||
break; | ||
default: | ||
} else { | ||
this._emitOwnerDependentEvent("serviceMsg", ctx.jobInfo.ownerToken, msg, ctx, sendServiceResponse); | ||
@@ -264,3 +279,3 @@ } | ||
code: ERR.PROXY_CANT_RESOLVE_ORIGIN_URL, | ||
ctx: ctx | ||
originUrl: ctx.originResourceInfo.url | ||
}); | ||
@@ -284,2 +299,3 @@ return; | ||
ctx.originReqOptions.headers = {}; | ||
ctx.originReqOptions.agent = ctx.originResourceInfo.protocol === "https:" ? httpsAgent : httpAgent; | ||
var proxy = this; | ||
@@ -319,7 +335,28 @@ Object.keys(ctx.req.headers).forEach(function(field) { | ||
Proxy.prototype._getAuthCredentials = function(jobInfo) { | ||
var result = null; | ||
if (this.evtListeners[jobInfo.ownerToken]) { | ||
result = this.evtListeners[jobInfo.ownerToken].getAuthCredentials(jobInfo.uid); | ||
} | ||
if (result) { | ||
result.domain = result.domain || curUserDomain; | ||
result.workstation = result.workstation || curUserWorkstation; | ||
return result; | ||
} | ||
}; | ||
Proxy.prototype._sendOriginRequest = function(ctx) { | ||
var proxy = this, protocolInterface = ctx.originResourceInfo.protocol === "https:" ? https : http; | ||
var proxy = this, isHttps = ctx.originResourceInfo.protocol === "https:", protocolInterface = isHttps ? https : http; | ||
var credentials = proxy._getAuthCredentials(ctx.jobInfo); | ||
ctx.originReq = protocolInterface.request(ctx.originReqOptions, function(originRes) { | ||
ctx.originRes = originRes; | ||
proxy._onOriginResponse(ctx); | ||
if (originRes.statusCode === 401 && credentials) { | ||
ctx.originReq.abort(); | ||
webauth.auth(ctx.originReqOptions, credentials, function(targetRes) { | ||
ctx.originRes = targetRes; | ||
proxy._onOriginResponse(ctx); | ||
}, isHttps, originRes); | ||
} else { | ||
proxy._onOriginResponse(ctx); | ||
} | ||
}); | ||
@@ -362,3 +399,4 @@ ctx.originReq.on("error", function() { | ||
code: ERR.PROXY_XHR_REQUEST_SAME_ORIGIN_POLICY_VIOLATION, | ||
ctx: ctx | ||
reqOrigin: ctx.originResourceInfo.reqOrigin, | ||
xhrReqUrl: ctx.originResourceInfo.url | ||
}); | ||
@@ -386,2 +424,4 @@ ctx.res.statusCode = 0; | ||
return contentType.indexOf("text/cache-manifest") !== -1; | ||
}, isJSON = function() { | ||
return contentType.indexOf("application/json") !== -1; | ||
}; | ||
@@ -412,3 +452,12 @@ if (isCssResource()) { | ||
} else { | ||
callback(); | ||
if (isJSON()) { | ||
injector.injectInJSON(ctx.originResBodyChunks, ctx.originResContentInfo.encoding, ctx.originResContentInfo.charset, function(err, processedJSON) { | ||
if (!err) { | ||
ctx.originResBodyChunks = [ processedJSON ]; | ||
} | ||
callback(); | ||
}); | ||
} else { | ||
callback(); | ||
} | ||
} | ||
@@ -434,3 +483,3 @@ } | ||
code: ERR.PROXY_ORIGIN_SERVER_CONNECTION_TERMINATED, | ||
ctx: ctx | ||
originUrl: ctx.originResourceInfo.url | ||
}); | ||
@@ -437,0 +486,0 @@ return; |
@@ -1,4 +0,4 @@ | ||
var path = require("path"), url = require("url"), fs = require("fs"), util = require("util"), uuid = require("node-uuid"), injector = require("./injector"), fixtureFile = require("./fixture_file"), errMsgBuilder = require("./err_msg_builder"), assets = require("./assets"), urlUtil = require("../shared/url_util"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"); | ||
var fs = require("fs"), path = require("path"), url = require("url"), util = require("util"), uuid = require("node-uuid"), assets = require("./assets"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"), errMsgBuilder = require("./err_msg_builder"), FixtureCode = require("../fixture_code/"), injector = require("./injector"), urlUtil = require("../shared/url_util"); | ||
var SERVER_ERROR_PAGE_HTML_TEMPLATE = "<!DOCTYPE html>" + "<html>" + "<head>" + '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' + "<title></title>" + '<style type="text/css">%s</style> ' + '<script type="text/javascript">%s</script>' + "</head>" + "<body></body>" + "</html>"; | ||
var RECORDER_PAGE_HTML_TEMPLATE = "<!DOCTYPE html>" + "<html>" + "<head>" + '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' + "<title></title>" + '<style type="text/css">%s</style> ' + '<script type="text/javascript">%s</script>' + "</head>" + "<body></body>" + "</html>"; | ||
@@ -14,2 +14,4 @@ var Recorder = exports.Recorder = function(proxy, vfs, cookieShelf) { | ||
this.serverErrorPageJsTmpl = new assets.JsTemplate(path.join(__dirname, "../_compiled_/client_runtime/recorder_server_err_page.jstmpl")); | ||
this.authenticationPageJsTmpl = new assets.JsTemplate(path.join(__dirname, "../_compiled_/client_runtime/authentication_page.jstmpl")); | ||
this.proxy.addEventListener(Recorder.JOB_OWNER_TOKEN, this); | ||
this.proxy.addOwnerDependentEventListener("beforeProxyResponse", Recorder.JOB_OWNER_TOKEN, this._onBeforeProxyResponse.bind(this)); | ||
@@ -30,13 +32,21 @@ this.proxy.addOwnerDependentEventListener("error", Recorder.JOB_OWNER_TOKEN, this._onProxyError.bind(this)); | ||
proxyCtx.res.setHeader("content-type", "text/html"); | ||
proxyCtx.res.end(util.format(SERVER_ERROR_PAGE_HTML_TEMPLATE, assets.getClientUICss(), serverErrorPageJs)); | ||
proxyCtx.res.end(util.format(RECORDER_PAGE_HTML_TEMPLATE, assets.getClientUICss(), serverErrorPageJs)); | ||
}; | ||
Recorder.prototype._onProxyError = function(err) { | ||
var ctx = err.ctx, recording = this.recordings[ctx.jobInfo.uid]; | ||
if (recording && (ctx.originResContentInfo && ctx.originResContentInfo.isPage || ctx.isPageReqCandidate)) { | ||
this._redirectToServerErrorPage(ctx, recording.returnUrl); | ||
return; | ||
} | ||
Recorder.prototype._redirectToAuthenticationPage = function(proxyCtx, returnUrl, currentCredentials) { | ||
var parsedProxyUrl = urlUtil.parseProxyUrl(proxyCtx.req.url), authenticationPageJs = this.authenticationPageJsTmpl.getJs({ | ||
credentials: currentCredentials ? currentCredentials.username + ":" + currentCredentials.password : "", | ||
returnUrl: returnUrl, | ||
originUrl: parsedProxyUrl ? url.format(parsedProxyUrl.originResourceInfo) : "" | ||
}); | ||
proxyCtx.res.statusCode = 401; | ||
proxyCtx.res.setHeader("content-type", "text/html"); | ||
proxyCtx.res.end(util.format(RECORDER_PAGE_HTML_TEMPLATE, assets.getClientUICss(), authenticationPageJs)); | ||
}; | ||
Recorder.prototype.getAuthCredentials = function(jobUID) { | ||
var recording = this.recordings[jobUID]; | ||
return recording ? recording.authCredentials : null; | ||
}; | ||
Recorder.prototype._onBeforeProxyResponse = function(ctx, callback) { | ||
@@ -49,3 +59,7 @@ var recording = this.recordings[ctx.jobInfo.uid]; | ||
} | ||
if (ctx.originRes.statusCode >= 400 && !ctx.isXhr) { | ||
if (ctx.originRes.statusCode === 401 && ctx.originResContentInfo.isPage) { | ||
this._redirectToAuthenticationPage(ctx, recording.returnUrl, recording.authCredentials); | ||
return; | ||
} | ||
if (ctx.originRes.statusCode >= 400 && !ctx.isXhr && !ctx.isIFrame) { | ||
this._redirectToServerErrorPage(ctx, recording.returnUrl); | ||
@@ -61,2 +75,9 @@ return; | ||
Recorder.prototype._onProxyError = function(proxyCtx, err) { | ||
var recording = this.recordings[proxyCtx.jobInfo.uid]; | ||
if (recording && (proxyCtx.originResContentInfo && proxyCtx.originResContentInfo.isPage || proxyCtx.isPageReqCandidate)) { | ||
this._redirectToServerErrorPage(proxyCtx, recording.returnUrl); | ||
} | ||
}; | ||
Recorder.prototype._onServiceMsg = function(msg, proxyCtx, callback) { | ||
@@ -120,2 +141,17 @@ var recording = this.recordings[proxyCtx.jobInfo.uid], res = null; | ||
case cmd.AUTH_CREDENTIALS_SET: | ||
var vfs = this.vfs; | ||
vfs.getRealPath(recording.fixturePath, recording.fixtureFileName, function(fileName) { | ||
FixtureCode.CodeGenerator.editDirectives(fileName, { | ||
auth: msg.credentials | ||
}, function(err) { | ||
if (err) { | ||
callback(errMsgBuilder.build(err)); | ||
return; | ||
} | ||
vfs.forceBuild(callback); | ||
}); | ||
}); | ||
return; | ||
default: | ||
@@ -136,3 +172,3 @@ break; | ||
jobOwnerToken: Recorder.JOB_OWNER_TOKEN, | ||
cookieCache: cookie.replace(/'/g, "\\'"), | ||
cookie: cookie.replace(/'/g, "\\'"), | ||
originHost: proxyCtx.originResourceInfo.host, | ||
@@ -170,7 +206,8 @@ originProtocol: proxyCtx.originResourceInfo.protocol, | ||
recorder.recordings[recordingUid] = { | ||
uid: recordingUid, | ||
authCredentials: fixture.authCredentials, | ||
fixtureFileName: fixture.fileName, | ||
fixturePath: fixture.path, | ||
fixtureFileName: fixture.fileName, | ||
returnUrl: returnUrl, | ||
stepsInfo: [] | ||
stepsInfo: [], | ||
uid: recordingUid | ||
}; | ||
@@ -231,3 +268,3 @@ try { | ||
vfs.removeFSWatchers(); | ||
fixtureFile.addTestCode(fileName, testName, recording.stepsInfo, function(err) { | ||
FixtureCode.CodeGenerator.addTest(fileName, testName, recording.stepsInfo, function(err) { | ||
if (!err && recorder.recordings[recordingUid]) { | ||
@@ -234,0 +271,0 @@ delete recorder.recordings[recordingUid]; |
@@ -31,52 +31,2 @@ exports.API_TESTS_TARGET_NOT_EXIST = "API_TESTS_TARGET_NOT_EXIST"; | ||
exports.FIXTURE_FILE_READ_FILE_FAILED = "FIXTURE_FILE_READ_FILE_FAILED"; | ||
exports.FIXTURE_FILE_PARSING_FAILED = "FIXTURE_FILE_PARSING_FAILED"; | ||
exports.FIXTURE_FILE_FIXTURE_DIRECTIVE_REDEFINITION = "FIXTURE_FILE_FIXTURE_DIRECTIVE_REDEFINITION"; | ||
exports.FIXTURE_FILE_PAGE_DIRECTIVE_REDEFINITION = "FIXTURE_FILE_PAGE_DIRECTIVE_REDEFINITION"; | ||
exports.FIXTURE_FILE_REQUIRED_FILE_ALREADY_INCLUDED = "FIXTURE_FILE_REQUIRED_FILE_ALREADY_INCLUDED"; | ||
exports.FIXTURE_FILE_MISPLACED_DIRECTIVE = "FIXTURE_FILE_MISPLACED_DIRECTIVE"; | ||
exports.FIXTURE_FILE_MISPLACED_TEST_DIRECTIVE = "FIXTURE_FILE_MISPLACED_TEST_DIRECTIVE"; | ||
exports.FIXTURE_FILE_DUPLICATE_TEST_NAME = "FIXTURE_FILE_DUPLICATE_TEST_NAME"; | ||
exports.FIXTURE_FILE_EMPTY_TEST_NAME = "FIXTURE_FILE_EMPTY_TEST_NAME"; | ||
exports.FIXTURE_FILE_INVALID_TEST_ASSIGNMENT = "FIXTURE_FILE_INVALID_TEST_ASSIGNMENT"; | ||
exports.FIXTURE_FILE_TEST_STEP_IS_NOT_A_FUNCTION = "FIXTURE_FILE_TEST_STEP_IS_NOT_A_FUNCTION"; | ||
exports.FIXTURE_FILE_ACTION_FUNC_IS_NOT_A_LAST_ENTRY = "FIXTURE_FILE_ACTION_FUNC_IS_NOT_A_LAST_ENTRY"; | ||
exports.FIXTURE_FILE_TEST_STEP_IS_EMPTY = "FIXTURE_FILE_TEST_STEP_IS_EMPTY"; | ||
exports.FIXTURE_FILE_TEST_IS_EMPTY = "FIXTURE_FILE_TEST_IS_EMPTY"; | ||
exports.FIXTURE_FILE_FIXTURE_DIRECTIVE_IS_UNDEFINED = "FIXTURE_FILE_FIXTURE_DIRECTIVE_IS_UNDEFINED"; | ||
exports.FIXTURE_FILE_PAGE_DIRECTIVE_IS_UNDEFINED = "FIXTURE_FILE_PAGE_DIRECTIVE_IS_UNDEFINED"; | ||
exports.FIXTURE_FILE_ASYNC_FUNC_CALL = "FIXTURE_FILE_ASYNC_FUNC_CALL"; | ||
exports.FIXTURE_FILE_ACTION_FUNC_CALL_IN_SHARED_CODE = "FIXTURE_FILE_ACTION_FUNC_CALL_IN_SHARED_CODE"; | ||
exports.FIXTURE_FILE_FAILED_LOAD_REQUIRE = "FIXTURE_FILE_FAILED_LOAD_REQUIRE"; | ||
exports.FIXTURE_FILE_MODULE_NOT_FOUND = "FIXTURE_FILE_MODULE_NOT_FOUND"; | ||
exports.FIXTURE_FILE_WRITE_FILE_FAILED = "FIXTURE_FILE_WRITE_FILE_FAILED"; | ||
exports.FIXTURE_FILE_INVALID_FILE_FORMAT = "FIXTURE_FILE_INVALID_FILE_FORMAT"; | ||
exports.FIXTURE_FILE_ELEMENT_SELECTOR_PARSING_FAILED = "FIXTURE_FILE_ELEMENT_SELECTOR_PARSING_FAILED"; | ||
exports.FIXTURE_FILE_TEST_IS_NOT_FOUND = "FIXTURE_FILE_TEST_IS_NOT_FOUND"; | ||
exports.FIXTURE_FILE_TEST_NAME_CHANGED_TO_ALREADY_USED = "FIXTURE_FILE_TEST_NAME_CHANGED_TO_ALREADY_USED"; | ||
exports.INJECTOR_RESOURCE_DECODING_FAILED = "INJECTOR_RESOURCE_DECODING_FAILED"; | ||
@@ -106,18 +56,18 @@ | ||
exports.SUITE_READ_DIR_FAILED = "SUITE_READ_DIR_FAILED"; | ||
exports.SUITE_GET_FILE_STATS_FAILED = "SUITE_GET_FILE_STATS_FAILED"; | ||
exports.SUITE_READ_CFG_FILE_FAILED = "SUITE_READ_CFG_FILE_FAILED"; | ||
exports.SUITE_CFG_FILE_PARSING_FAILED = "SUITE_CFG_FILE_PARSING_FAILED"; | ||
exports.SUITE_CFG_PROPERTY_IS_NOT_STRING = "SUITE_CFG_PROPERTY_IS_NOT_STRING"; | ||
exports.SUITE_CFG_INVALID_PROPERTY_FORMAT = "SUITE_CFG_INVALID_PROPERTY_FORMAT"; | ||
exports.SUITE_CFG_MODULE_IS_NOT_ARRAY = "SUITE_CFG_MODULE_IS_NOT_ARRAY"; | ||
exports.SUITE_CFG_INVALID_PROPERTY_FORMAT = "SUITE_CFG_INVALID_PROPERTY_FORMAT"; | ||
exports.SUITE_CFG_PROPERTY_IS_NOT_STRING = "SUITE_CFG_PROPERTY_IS_NOT_STRING"; | ||
exports.SUITE_CFG_UNSUPPORTED_PROPERTY = "SUITE_CFG_UNSUPPORTED_PROPERTY"; | ||
exports.SUITE_GET_FILE_STATS_FAILED = "SUITE_GET_FILE_STATS_FAILED"; | ||
exports.SUITE_READ_CFG_FILE_FAILED = "SUITE_READ_CFG_FILE_FAILED"; | ||
exports.SUITE_READ_DIR_FAILED = "SUITE_READ_DIR_FAILED"; | ||
exports.TEST_RUNNER_MAX_TEST_RUN_RESTARTS = "TEST_RUNNER_MAX_TEST_RUN_RESTARTS"; | ||
@@ -124,0 +74,0 @@ |
@@ -1,2 +0,2 @@ | ||
var fs = require("fs"), path = require("path"), url = require("url"), util = require("util"), fixtureFile = require("./fixture_file"), uuid = require("node-uuid"), async = require("async"), revalidator = require("revalidator"), ERR = require("./server_errs"); | ||
var fs = require("fs"), path = require("path"), url = require("url"), util = require("util"), FixtureCode = require("../fixture_code/"), uuid = require("node-uuid"), async = require("async"), revalidator = require("revalidator"), ERR = require("./server_errs"); | ||
@@ -68,3 +68,4 @@ var FIXTURE_FILE_NAME_PATTERN = /\.test\.js$/, CFG_FILE_NAME = "test_config.json", CFG_SCHEMA = { | ||
function analyzeFixtureFile(filePath, callback, modules, requiresCache) { | ||
fixtureFile.translate(filePath, function(errs, out) { | ||
var compiler = new FixtureCode.Compiler(filePath, modules, requiresCache); | ||
compiler.compile(function(errs, out) { | ||
var fixtureUid = uuid.v4(), suite = { | ||
@@ -82,2 +83,3 @@ buildErrs: [], | ||
sharedJs: out.sharedJs, | ||
authCredentials: out.authCredentials, | ||
tests: [] | ||
@@ -102,2 +104,3 @@ }; | ||
sharedJs: "", | ||
authCredentials: null, | ||
tests: [] | ||
@@ -123,3 +126,3 @@ }; | ||
callback(suite); | ||
}, modules, requiresCache); | ||
}); | ||
} | ||
@@ -126,0 +129,0 @@ |
@@ -1,2 +0,2 @@ | ||
var EventEmitter = require("events").EventEmitter, path = require("path"), url = require("url"), util = require("util"), uuid = require("node-uuid"), injector = require("./injector"), assets = require("./assets"), cmd = require("../shared/service_msg_cmd"), CLIENT_ERR = require("../shared/client_errs"), ERR = require("./server_errs"); | ||
var EventEmitter = require("events").EventEmitter, path = require("path"), url = require("url"), util = require("util"), uuid = require("node-uuid"), assets = require("./assets"), CLIENT_ERR = require("../shared/client_errs"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"), injector = require("./injector"); | ||
@@ -27,2 +27,3 @@ var PAGE_ERROR_VERIFICATION_HTML_TEMPLATE = "/*" + "<!DOCTYPE html>" + "<html>" + "<head>" + "<title></title>" + '<script type="text/javascript">%s</script>' + "</head>" + "<body></body>" + "</html>" + "*/"; | ||
this.workerPool.on("workerDisconnected", this._onWorkerDisconnected.bind(this)); | ||
this.proxy.addEventListener(TestRunner.JOB_OWNER_TOKEN, this); | ||
this.proxy.addOwnerDependentEventListener("beforeProxyResponse", TestRunner.JOB_OWNER_TOKEN, this._onBeforeProxyResponse.bind(this)); | ||
@@ -44,2 +45,7 @@ this.proxy.addOwnerDependentEventListener("error", TestRunner.JOB_OWNER_TOKEN, this._onProxyError.bind(this)); | ||
TestRunner.prototype.getAuthCredentials = function(jobUID) { | ||
var testRun = this.testRuns[jobUID]; | ||
return testRun ? testRun.authCredentials : null; | ||
}; | ||
TestRunner.prototype._onBeforeProxyResponse = function(ctx, callback) { | ||
@@ -57,3 +63,3 @@ var testRun = this.testRuns[ctx.jobInfo.uid]; | ||
}; | ||
if (ctx.originResContentInfo.isPage) { | ||
if (ctx.originResContentInfo.isPage && !ctx.isIFrame) { | ||
this._addTestError(testRun, err); | ||
@@ -78,11 +84,11 @@ testRun.halted = true; | ||
TestRunner.prototype._onProxyError = function(err) { | ||
var ctx = err.ctx, testRun = this.testRuns[ctx.jobInfo.uid]; | ||
TestRunner.prototype._onProxyError = function(proxyCtx, err) { | ||
var testRun = this.testRuns[proxyCtx.jobInfo.uid]; | ||
if (testRun) { | ||
if (ctx.originResContentInfo && ctx.originResContentInfo.isPage) { | ||
if (proxyCtx.originResContentInfo && proxyCtx.originResContentInfo.isPage) { | ||
this._addTestError(testRun, err); | ||
testRun.halted = true; | ||
this.workerPool.redirectToWorkerIdle(ctx, testRun.workerName); | ||
this.workerPool.redirectToWorkerIdle(proxyCtx, testRun.workerName); | ||
} else { | ||
if (ctx.isPageReqCandidate) { | ||
if (proxyCtx.isPageReqCandidate) { | ||
var causeUid = this._addPossibleTestFailCause(testRun, err); | ||
@@ -96,6 +102,6 @@ var verificationJs = this.errHandlerJsTmpl.getJs({ | ||
}); | ||
proxyErrRes(ctx, util.format(PAGE_ERROR_VERIFICATION_HTML_TEMPLATE, verificationJs)); | ||
proxyErrRes(proxyCtx, util.format(PAGE_ERROR_VERIFICATION_HTML_TEMPLATE, verificationJs)); | ||
} else { | ||
this._addPossibleTestFailCause(testRun, err); | ||
proxyErrRes(ctx); | ||
proxyErrRes(proxyCtx); | ||
} | ||
@@ -107,3 +113,3 @@ } | ||
TestRunner.prototype._onServiceMsg = function(msg, proxyCtx, callback) { | ||
var res = null, testRun = this.testRuns[proxyCtx.jobInfo.uid]; | ||
var res = null, expectedInactivityDuration = null, testRun = this.testRuns[proxyCtx.jobInfo.uid]; | ||
if (testRun && !testRun.halted) { | ||
@@ -160,6 +166,10 @@ switch (msg.cmd) { | ||
case cmd.INACTIVITY_EXPECTED: | ||
expectedInactivityDuration = msg.duration; | ||
break; | ||
default: | ||
break; | ||
} | ||
this.workerPool.workerHeartbeat(testRun.workerName); | ||
this.workerPool.workerHeartbeat(testRun.workerName, expectedInactivityDuration); | ||
} | ||
@@ -172,3 +182,3 @@ callback(res); | ||
testRun.possibleFailCauses.push({ | ||
uid: uuid, | ||
uid: uid, | ||
type: type, | ||
@@ -189,3 +199,3 @@ err: err | ||
if (idx > -1) { | ||
testRun.possibleFailCauses[i].splice(idx, 1); | ||
testRun.possibleFailCauses.splice(idx, 1); | ||
} | ||
@@ -214,3 +224,3 @@ }; | ||
jobOwnerToken: TestRunner.JOB_OWNER_TOKEN, | ||
cookieCache: cookie.replace(/'/g, "\\'"), | ||
cookie: cookie.replace(/'/g, "\\'"), | ||
originHost: proxyCtx.originResourceInfo.host, | ||
@@ -279,17 +289,18 @@ originProtocol: proxyCtx.originResourceInfo.protocol, | ||
testUids.forEach(function(testUid) { | ||
var testRunUid = uuid.v4(), test = suite.tests[testUid]; | ||
var testRunUid = uuid.v4(), test = suite.tests[testUid], fixture = suite.fixtures[test.fixtureUid]; | ||
runner.testRuns[testRunUid] = { | ||
uid: testRunUid, | ||
taskUid: taskUid, | ||
workerName: workerName, | ||
test: test, | ||
fixture: suite.fixtures[test.fixtureUid], | ||
stepsSharedData: null, | ||
authCredentials: fixture.authCredentials, | ||
cursorPos: null, | ||
emulateCursor: emulateCursor, | ||
errs: [], | ||
fixture: fixture, | ||
halted: false, | ||
nextStep: null, | ||
halted: false, | ||
possibleFailCauses: [], | ||
errs: [], | ||
restartCount: 0, | ||
emulateCursor: emulateCursor | ||
stepsSharedData: null, | ||
taskUid: taskUid, | ||
test: test, | ||
uid: testRunUid, | ||
workerName: workerName | ||
}; | ||
@@ -296,0 +307,0 @@ worker.testRuns.push(testRunUid); |
@@ -1,2 +0,2 @@ | ||
var fs = require("fs"), path = require("path"), util = require("util"), uuid = require("node-uuid"), fixtureFile = require("./fixture_file"), EventEmitter = require("events").EventEmitter, async = require("async"), suite = require("./suite"), ERR = require("./server_errs"); | ||
var fs = require("fs"), path = require("path"), util = require("util"), uuid = require("node-uuid"), EventEmitter = require("events").EventEmitter, async = require("async"), suite = require("./suite"), FixtureCode = require("../fixture_code/"), ERR = require("./server_errs"); | ||
@@ -205,2 +205,4 @@ function validateBasePath(basePath) { | ||
page: fixture.page, | ||
username: fixture.authCredentials ? fixture.authCredentials.username : null, | ||
password: fixture.authCredentials ? fixture.authCredentials.password : null, | ||
tests: [] | ||
@@ -425,3 +427,3 @@ }; | ||
VirtualFS.prototype.editFixture = function(dirPath, oldFilename, newFilename, newName, newPage, callback) { | ||
VirtualFS.prototype.editFixture = function(dirPath, oldFilename, newFilename, newName, newPage, newUsername, newPassword, callback) { | ||
var vfs = this, renamePath = dirPath.slice(0); | ||
@@ -455,4 +457,9 @@ renamePath.push(oldFilename); | ||
vfs.removeFSWatchers(); | ||
if (oldPath === newPath) { | ||
fixtureFile.modifyFixtureDefinition(newPath, newName, newPage, function(err) { | ||
var updateFixtureCode = function() { | ||
var directives = { | ||
fixture: newName, | ||
page: newPage, | ||
auth: newUsername ? newUsername + ":" + newPassword : null | ||
}; | ||
FixtureCode.CodeGenerator.editDirectives(newPath, directives, function(err) { | ||
vfs.forceBuild(function() { | ||
@@ -462,2 +469,5 @@ callback(err); | ||
}); | ||
}; | ||
if (oldPath === newPath) { | ||
updateFixtureCode(); | ||
} else { | ||
@@ -478,7 +488,3 @@ vfs._pathExists(newPath, function(res) { | ||
} else { | ||
fixtureFile.modifyFixtureDefinition(newPath, newName, newPage, function(err) { | ||
vfs.forceBuild(function() { | ||
callback(err); | ||
}); | ||
}); | ||
updateFixtureCode(); | ||
} | ||
@@ -522,3 +528,3 @@ }); | ||
VirtualFS.prototype.createFixture = function(dirPath, name, filename, page, callback) { | ||
VirtualFS.prototype.createFixture = function(dirPath, name, filename, page, username, password, callback) { | ||
var vfs = this, fixturePath = dirPath.slice(0); | ||
@@ -543,6 +549,15 @@ fixturePath.push(filename); | ||
vfs.removeFSWatchers(); | ||
fixtureFile.create(filePath, name, page, function(err) { | ||
vfs.forceBuild(function() { | ||
callback(err); | ||
}); | ||
FixtureCode.CodeGenerator.createFixture(filePath, name, page, function(err) { | ||
var codeGenCallback = function(err) { | ||
vfs.forceBuild(function() { | ||
callback(err); | ||
}); | ||
}; | ||
if (!err && (username || password)) { | ||
FixtureCode.CodeGenerator.editDirectives(filePath, { | ||
auth: username + ":" + password | ||
}, codeGenCallback); | ||
} else { | ||
codeGenCallback(err); | ||
} | ||
}); | ||
@@ -552,3 +567,3 @@ }); | ||
VirtualFS.prototype.createFixtureInDir = function(dirPath, dirName, name, filename, page, callback) { | ||
VirtualFS.prototype.createFixtureInDir = function(dirPath, dirName, name, filename, page, username, password, callback) { | ||
var vfs = this, fixturePathArray = dirPath.slice(0); | ||
@@ -575,3 +590,3 @@ fixturePathArray.push(dirName); | ||
var createFixture = function() { | ||
vfs.createFixture(dirPathArray, name, filename, page, function(createFixtureErr) { | ||
vfs.createFixture(dirPathArray, name, filename, page, username, password, function(createFixtureErr) { | ||
callback(createFixtureErr); | ||
@@ -607,3 +622,3 @@ }); | ||
vfs.removeFSWatchers(); | ||
fixtureFile.deleteTest(filename, testName, function(res) { | ||
FixtureCode.CodeGenerator.deleteTest(filename, testName, function(res) { | ||
vfs.forceBuild(function() { | ||
@@ -619,3 +634,3 @@ callback(res); | ||
vfs.removeFSWatchers(); | ||
fixtureFile.renameTest(filename, oldName, newName, function(res) { | ||
FixtureCode.CodeGenerator.renameTest(filename, oldName, newName, function(res) { | ||
vfs.forceBuild(function() { | ||
@@ -622,0 +637,0 @@ callback(res); |
@@ -18,3 +18,3 @@ var async = require("async"), EventEmitter = require("events").EventEmitter, execFile = require("child_process").execFile, fs = require("fs"), path = require("path"), url = require("url"), util = require("util"), userAgentParser = require("useragent"), uuid = require("node-uuid"), ERR = require("./server_errs"); | ||
WorkerPool.WORKER_HEARTBEAT_TIMEOUT = 2 * 6e4; | ||
WorkerPool.WORKER_HEARTBEAT_TIMEOUT = 6e4; | ||
@@ -66,39 +66,66 @@ var WORKER_TYPE = WorkerPool.WORKER_TYPE = { | ||
WorkerPool.prototype._watchWorkerHeartbeat = function(workerName) { | ||
WorkerPool.prototype._disconnectWorker = function(workerName) { | ||
this.emit("workerDisconnected", { | ||
code: ERR.WORKER_POOL_WORKER_DISCONNECTED, | ||
name: workerName | ||
}, this.get(workerName)); | ||
delete this.workers[workerName]; | ||
}; | ||
WorkerPool.prototype._watchWorkerHeartbeat = function(workerName, expectedInactivityDuration) { | ||
var worker = this.get(workerName), workerPool = this; | ||
worker.heartbeatTimeout = setTimeout(function() { | ||
workerPool.emit("workerDisconnected", { | ||
code: ERR.WORKER_POOL_WORKER_DISCONNECTED, | ||
name: workerName | ||
}, worker); | ||
delete workerPool.workers[workerName]; | ||
}, WorkerPool.WORKER_HEARTBEAT_TIMEOUT); | ||
if (worker.type === WORKER_TYPE.NEW_BROWSER_WINDOW && !worker.currentTest && worker.testRuns.length) { | ||
var idleUrl = workerPool.getWorkerIdleUrl(workerName), browser = workerPool.config.browsers[worker.browserName], execParams = workerPool._getBrowserExecParams(browser, idleUrl); | ||
worker.browserProc.kill(); | ||
worker.browserProc = execFile(execParams.path, execParams.cmdArr, function(execError) { | ||
if (execError && execError.code === 127) { | ||
workerPool._disconnectWorker(workerName); | ||
} else { | ||
workerPool._watchWorkerHeartbeat(workerName); | ||
} | ||
}); | ||
} else { | ||
workerPool._disconnectWorker(workerName); | ||
} | ||
}, expectedInactivityDuration || WorkerPool.WORKER_HEARTBEAT_TIMEOUT); | ||
}; | ||
WorkerPool.prototype.workerHeartbeat = function(workerName) { | ||
WorkerPool.prototype.workerHeartbeat = function(workerName, expectedInactivityDuration) { | ||
var worker = this.get(workerName); | ||
if (worker) { | ||
clearTimeout(worker.heartbeatTimeout); | ||
this._watchWorkerHeartbeat(workerName); | ||
this._watchWorkerHeartbeat(workerName, expectedInactivityDuration); | ||
} | ||
}; | ||
WorkerPool.prototype._getAddWorkerUrl = function(workerName) { | ||
return url.format({ | ||
host: this.config.controlPanelHost, | ||
pathname: util.format(ADD_WORKER_URL_PATHNAME_PATTERN, encodeURIComponent(workerName)), | ||
protocol: "http", | ||
query: { | ||
auto_created: "1", | ||
type: WORKER_TYPE.NEW_BROWSER_WINDOW | ||
} | ||
}); | ||
}; | ||
WorkerPool.prototype.getRestartTestRunUrl = function(workerName) { | ||
var urlObj = this._getWorkerIdleUrlObj(workerName); | ||
urlObj.query = { | ||
restartTestRun: 1 | ||
}; | ||
return url.format(urlObj); | ||
return url.format({ | ||
host: this.config.controlPanelHost, | ||
pathname: util.format(WORKER_IDLE_URL_PATHNAME_PATTERN, workerName), | ||
protocol: "http", | ||
query: { | ||
restartTestRun: 1 | ||
} | ||
}); | ||
}; | ||
WorkerPool.prototype.getWorkerIdleUrl = function(workerName) { | ||
return url.format(this._getWorkerIdleUrlObj(workerName)); | ||
}; | ||
WorkerPool.prototype._getWorkerIdleUrlObj = function(workerName) { | ||
return { | ||
return url.format({ | ||
host: this.config.controlPanelHost, | ||
pathname: util.format(WORKER_IDLE_URL_PATHNAME_PATTERN, workerName), | ||
protocol: "http" | ||
}; | ||
}); | ||
}; | ||
@@ -146,6 +173,6 @@ | ||
browserProc: null, | ||
browserName: null, | ||
userAgent: userAgent, | ||
taskReport: null, | ||
currentTest: null, | ||
testFixtures: [], | ||
testRuns: [] | ||
@@ -205,16 +232,7 @@ }; | ||
WorkerPool.prototype._getBrowserExecParams = function(browser, workerName) { | ||
var addWorkerUrl = url.format({ | ||
host: this.config.controlPanelHost, | ||
pathname: util.format(ADD_WORKER_URL_PATHNAME_PATTERN, encodeURIComponent(workerName)), | ||
protocol: "http", | ||
query: { | ||
auto_created: "1", | ||
type: WORKER_TYPE.NEW_BROWSER_WINDOW | ||
} | ||
}); | ||
WorkerPool.prototype._getBrowserExecParams = function(browser, startupUrl) { | ||
var cmdArr = browser.cmd ? browser.cmd.split(" ") : []; | ||
if (process.platform === "darwin") { | ||
return { | ||
cmdArr: [ "-a", browser.path, addWorkerUrl, "--args" ].concat(cmdArr), | ||
cmdArr: [ "-a", browser.path, startupUrl, "--args" ].concat(cmdArr), | ||
path: "open" | ||
@@ -224,3 +242,3 @@ }; | ||
return { | ||
cmdArr: cmdArr.concat(addWorkerUrl), | ||
cmdArr: cmdArr.concat(startupUrl), | ||
path: browser.path | ||
@@ -234,3 +252,3 @@ }; | ||
starters.push(function(asyncCallback) { | ||
var workerName = workerPool._getUnusedWorkerName(browserName), browser = workerPool.config.browsers[browserName], execParams = workerPool._getBrowserExecParams(browser, workerName), added = false, addTimeout = null; | ||
var workerName = workerPool._getUnusedWorkerName(browserName), browser = workerPool.config.browsers[browserName], addWorkerUrl = workerPool._getAddWorkerUrl(workerName), execParams = workerPool._getBrowserExecParams(browser, addWorkerUrl), added = false, addTimeout = null; | ||
workerPool.workerAddedHandlers[workerName] = function(worker) { | ||
@@ -241,2 +259,3 @@ clearTimeout(addTimeout); | ||
worker.browserProc = browserProc; | ||
worker.browserName = browserName; | ||
done(); | ||
@@ -243,0 +262,0 @@ }; |
@@ -23,2 +23,4 @@ TestCafeClient = typeof TestCafeClient === "undefined" ? {} : TestCafeClient; | ||
root.URL_UTIL_PROTOCOL_IS_NOT_SUPPORTED = "CLIENT_URL_UTIL_PROTOCOL_IS_NOT_SUPPORTED"; | ||
root.API_INCORRECT_SELECT_ACTION_ARGUMENTS = "CLIENT_API_INCORRECT_SELECT_ACTION_ARGUMENTS"; | ||
root.API_INCORRECT_WAIT_ACTION_FIRST_ARGUMENT = "CLIENT_API_INCORRECT_WAIT_ACTION_FIRST_ARGUMENT"; | ||
})(); |
@@ -13,2 +13,3 @@ TestCafeClient = typeof TestCafeClient === "undefined" ? {} : TestCafeClient; | ||
root.DOM_SANDBOX_PROCESSED_FLAG = "tc-spf-c1208da2"; | ||
root.EVENT_SANDBOX_DISPATCH_EVENT_PREFIX = "tc-sdef-310efb6b"; | ||
root.RECORDING_FLAG = "tc-rf-08a3927b"; | ||
@@ -22,4 +23,5 @@ root.GLOBAL_ACTIONS_SIMULATION_FLAG = "tc-gasf-0acd97c8"; | ||
root.TEST_CAFE_UI_STYLESHEET_CLASSNAME = "ui-stylesheet" + root.TEST_CAFE_UI_CLASSNAME_POSTFIX; | ||
root.ACTION_FUNC_NAMES = [ "click", "rclick", "dblclick", "drag", "type", "wait", "hover", "press" ]; | ||
root.TEST_CAFE_PROPERTY_PREFIX = "tc-1b082a6cec-51966-"; | ||
root.ACTION_FUNC_NAMES = [ "click", "rclick", "dblclick", "drag", "type", "wait", "hover", "press", "select" ]; | ||
root.PROPERTIES_FOR_WRAPPING = [ "innerHTML", "src", "href", "action", "location", "domain", "cookie", "referrer", "URL", "onbeforeunload" ]; | ||
})(); |
@@ -7,3 +7,3 @@ TestCafeClient = typeof TestCafeClient === "undefined" ? {} : TestCafeClient; | ||
var TCC = TestCafeClient, isNode = typeof module !== "undefined" && module.exports, consts = isNode ? require("./const") : TCC, urlUtil = isNode ? require("./url_util") : TCC.urlUtil, root = isNode ? exports : TCC.pageProc; | ||
var CSS_URL_PROPERTY_VALUE_PATTERN = /(url\s*\(\s*)(?:(')([^\s']+)(')|(")([^\s"]+)(")|([^\s\)]+))(\s*\))|(@import\s+)(?:(')([^\s']+)(')|(")([^\s"]+)("))/g, EVENTS = [ "onblur", "onchange", "onclick", "oncontextmenu", "oncopy", "oncut", "ondblclick", "onerror", "onfocus", "onfocusin", "onfocusout", "onhashchange", "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onmousewheel", "onpaste", "onreset", "onresize", "onscroll", "onselect", "onsubmit", "ontextinput", "onunload", "onwheel" ], EVENT_HANDLERS_SELECTOR = "[" + EVENTS.join("],[") + "]", BOM_REGEX = new RegExp("^(\\xEF\\xBB\\xBF|" + "\\xFE\\xFF|" + "\\xFF\\xFE|" + "\\x00\\x00\\xFE\\xFF|" + "\\xFF\\xFE\\x00\\x00|" + "\\x2B\\x2F\\x76\\x38|" + "\\x2B\\x2F\\x76\\x39|" + "\\x2B\\x2F\\x76\\x2B|" + "\\x2B\\x2F\\x76\\x2F|" + "\\xF7\\x64\\x4C|" + "\\xDD\\x73\\x66\\x73|" + "\\x0E\\xFE\\xFF|" + "\\xFB\\xEE\\x28|" + "\\x84\\x31\\x95\\x33)"), URL_ATTR_REG_EX_FORMAT = "\\s({1}|{2})(?:\\s*=\\s*(\"([^\"]*)\"|'([^']*)')|(?=[\\s>/]))", TAG_REG_EX_FORMAT = "<(?:{0})[^<>]*" + URL_ATTR_REG_EX_FORMAT + "[^<>]*>"; | ||
var CSS_URL_PROPERTY_VALUE_PATTERN = /(url\s*\(\s*)(?:(')([^\s']+)(')|(")([^\s"]+)(")|([^\s\)]+))(\s*\))|(@import\s+)(?:(')([^\s']+)(')|(")([^\s"]+)("))/g, EVENTS = [ "onblur", "onchange", "onclick", "oncontextmenu", "oncopy", "oncut", "ondblclick", "onerror", "onfocus", "onfocusin", "onfocusout", "onhashchange", "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onmousewheel", "onpaste", "onreset", "onresize", "onscroll", "onselect", "onsubmit", "ontextinput", "onunload", "onwheel" ], EVENT_HANDLERS_SELECTOR = "[" + EVENTS.join("],[") + "]", BOM_REGEX = new RegExp("^(\\xEF\\xBB\\xBF|" + "\\xFE\\xFF|" + "\\xFF\\xFE|" + "\\x00\\x00\\xFE\\xFF|" + "\\xFF\\xFE\\x00\\x00|" + "\\x2B\\x2F\\x76\\x38|" + "\\x2B\\x2F\\x76\\x39|" + "\\x2B\\x2F\\x76\\x2B|" + "\\x2B\\x2F\\x76\\x2F|" + "\\xF7\\x64\\x4C|" + "\\xDD\\x73\\x66\\x73|" + "\\x0E\\xFE\\xFF|" + "\\xFB\\xEE\\x28|" + "\\x84\\x31\\x95\\x33)"), URL_ATTR_REG_EX_FORMAT = "\\s({1}|{2})(?:\\s*=\\s*(\"([^\"]*)\"|'([^']*)')|(?=[\\s>/]))", TAG_NAME_REG_EX_FORMAT = "<({0})[^<>]*", TAG_REG_EX_FORMAT = TAG_NAME_REG_EX_FORMAT + URL_ATTR_REG_EX_FORMAT + "[^<>]*>"; | ||
var wrapRegEx = new RegExp("(" + consts.PROPERTIES_FOR_WRAPPING.join("|") + ")(\\W|$)", "g"), wrappersBasis = []; | ||
@@ -118,3 +118,3 @@ for (var i = 0; i < consts.PROPERTIES_FOR_WRAPPING.length; i++) { | ||
if (urlUtil.isSupportedProtocol(resourceUrl)) { | ||
setAttr($el, pattern.urlAttr, resourceUrl ? urlReplacer(resourceUrl) : ""); | ||
setAttr($el, pattern.urlAttr, resourceUrl ? urlReplacer(resourceUrl, pattern.isIFrame) : ""); | ||
} else { | ||
@@ -139,3 +139,3 @@ setAttr($el, pattern.urlAttr, resourceUrl || ""); | ||
}, processIframe = function($el) { | ||
if (!isNode && !root.isCrossDomainIframe($el[0])) { | ||
if (!isNode && !root.isCrossDomainIframe($el[0]) && TCC.iframeWatch) { | ||
TCC.iframeWatch.overrideIframe($el); | ||
@@ -167,3 +167,3 @@ } | ||
var ELEMENT_PROCESSOR_PATTERNS = [ { | ||
selector: "a, link, image, area", | ||
selector: "a, link, image, area, base", | ||
urlAttr: "href", | ||
@@ -182,2 +182,3 @@ elementProcessors: [ processTargetBlank, processUrlAttrs ] | ||
urlAttr: "src", | ||
isIFrame: true, | ||
elementProcessors: [ processTargetBlank, processIframeUrl, processIframe ] | ||
@@ -214,3 +215,3 @@ }, { | ||
var getElementForSelectorCheck = function($el) { | ||
if (!isNode && TCC.util.isIE && TCC.util.browserVersion === 9 && $el[0].tagName.toLowerCase() === "script") { | ||
if (!isNode && $.browser.msie && parseInt($.browser.version, 10) === 9 && $el[0].tagName.toLowerCase() === "script") { | ||
var $clone = $(TCC.domSandbox.nativeMethods.cloneNode.call($el[0], false)); | ||
@@ -291,4 +292,9 @@ $clone[0].src = $clone[0].innerHTML = ""; | ||
}; | ||
root._removeWrapFromCssRule = function(css) { | ||
var prop = "src", propWrap = root.getWrapper(prop), cssRuleRegEx = new RegExp("({[^}]*)" + propWrap + "(\\s*:)", "g"); | ||
return css.replace(cssRuleRegEx, "$1" + prop + "$2"); | ||
}; | ||
root.processStylesheet = function(css, urlReplacer) { | ||
css = root.wrapProps(css); | ||
css = root._removeWrapFromCssRule(css); | ||
return css.replace(CSS_URL_PROPERTY_VALUE_PATTERN, function() { | ||
@@ -302,8 +308,8 @@ var prefix = arguments[1] || arguments[10], openQuote = arguments[2] || arguments[5] || arguments[11] || arguments[14] || "", resourceUrl = arguments[3] || arguments[6] || arguments[8] || arguments[12] || arguments[15], closeQuote = arguments[4] || arguments[7] || arguments[13] || arguments[16] || "", postfix = arguments[9] || ""; | ||
root.processHtml = function(html) { | ||
var replaceUrl = function(tagName, urlAttr) { | ||
var urlAttrWrap = root.getWrapper(urlAttr), tagRegEx = new RegExp(TAG_REG_EX_FORMAT.replace("{0}", tagName).replace("{1}", urlAttr).replace("{2}", urlAttrWrap), "gi"), tagMatches = html.match(tagRegEx) || []; | ||
var replaceUrl = function(tagNames, urlAttr) { | ||
var urlAttrWrap = root.getWrapper(urlAttr), tagRegEx = new RegExp(TAG_REG_EX_FORMAT.replace("{0}", tagNames).replace("{1}", urlAttr).replace("{2}", urlAttrWrap), "gi"), tagMatches = html.match(tagRegEx) || []; | ||
for (var i = 0; i < tagMatches.length; i++) { | ||
var tagStr = tagMatches[i], newTagStr = tagStr, urlAttrs = parseUrlAttrs(tagStr, urlAttr), attr = urlAttrs[urlAttrWrap] || urlAttrs[urlAttr], newAttrStr = ""; | ||
var tagNameRegEx = new RegExp(TAG_NAME_REG_EX_FORMAT.replace("{0}", tagNames), "gi"), tagStr = tagMatches[i], newTagStr = tagStr, urlAttrs = parseUrlAttrs(tagStr, urlAttr), attr = urlAttrs[urlAttrWrap] || urlAttrs[urlAttr], newAttrStr = "", tagName = tagNameRegEx.exec(tagStr)[1], isIFrame = tagName.toLowerCase() === "iframe"; | ||
if (!attr.empty) { | ||
var isOriginUrl = attr.value.indexOf(urlUtil.REQUEST_DESCRIPTOR_QUERY_KEY) === -1, proxyUrl = isOriginUrl && attr.value !== "" ? urlUtil.getProxyUrl(attr.value) : attr.value, originUrl = isOriginUrl ? attr.value : urlUtil.formatUrl(urlUtil.parseProxyUrl(attr.value).originResourceInfo); | ||
var isOriginUrl = attr.value.indexOf(urlUtil.REQUEST_DESCRIPTOR_QUERY_KEY) === -1, proxyUrl = isOriginUrl && attr.value !== "" ? urlUtil.convertToProxyUrl(attr.value, isIFrame) : attr.value, originUrl = isOriginUrl ? attr.value : urlUtil.formatUrl(urlUtil.parseProxyUrl(attr.value).originResourceInfo); | ||
proxyUrl = root.removeDomSandboxWrapperPrefixClutter(proxyUrl); | ||
@@ -310,0 +316,0 @@ originUrl = root.wrapProps(originUrl); |
@@ -13,2 +13,3 @@ TestCafeClient = typeof TestCafeClient === "undefined" ? {} : TestCafeClient; | ||
root.TEST_COMPLETE = "CMD_TEST_COMPLETE"; | ||
root.INACTIVITY_EXPECTED = "CMD_INACTIVITY_EXPECTED"; | ||
root.SET_STEPS_SHARED_DATA = "CMD_SET_STEPS_SHARED_DATA"; | ||
@@ -18,3 +19,2 @@ root.GET_STEPS_SHARED_DATA = "CMD_GET_STEPS_SHARED_DATA"; | ||
root.STEPS_INFO_SET = "CMD_STEPS_INFO_SET"; | ||
root.GET_COOKIE = "CMD_GET_COOKIE"; | ||
root.SET_COOKIE = "CMD_SET_COOKIE"; | ||
@@ -33,2 +33,3 @@ root.GET_CURSOR_POS = "CMD_GET_CURSOR_POS"; | ||
root.RESTART_RECORD = "CMD_RESTART_RECORD"; | ||
root.AUTH_CREDENTIALS_SET = "CMD_AUTH_CREDENTIALS_SET"; | ||
})(); |
@@ -191,3 +191,4 @@ TestCafeClient = typeof TestCafeClient === "undefined" ? {} : TestCafeClient; | ||
if (parsedOriginUrl) { | ||
if (parsedOriginUrl.protocol === parsedCheckedUrl.protocol && parsedOriginUrl.port.toString() === parsedCheckedUrl.port) { | ||
var portsEq = !parsedOriginUrl.port && !parsedCheckedUrl.port || parsedOriginUrl.port.toString() === parsedCheckedUrl.port; | ||
if (parsedOriginUrl.protocol === parsedCheckedUrl.protocol && portsEq) { | ||
if (parsedOriginUrl.hostname === parsedCheckedUrl.hostname) { | ||
@@ -211,4 +212,3 @@ return true; | ||
root.getOriginUrlObj = function(proxyUrl) { | ||
var proxyUrl = proxyUrl || location.toString(), parsedProxyUrl = root.parseProxyUrl(proxyUrl), parsedUrl = root.parseUrl(proxyUrl), query = proxyUrl ? parsedUrl.query : root.parseQuery(location.search); | ||
result = {}; | ||
var proxyUrl = proxyUrl || location.toString(), parsedProxyUrl = root.parseProxyUrl(proxyUrl), parsedUrl = root.parseUrl(proxyUrl), query = proxyUrl ? parsedUrl.query : root.parseQuery(location.search), result = {}; | ||
result.protocol = parsedProxyUrl ? parsedProxyUrl.originResourceInfo.protocol : TCC.ORIGIN_URL_OBJ.protocol; | ||
@@ -265,3 +265,6 @@ result.port = parsedProxyUrl ? parsedProxyUrl.originResourceInfo.port : TCC.ORIGIN_URL_OBJ.port; | ||
}; | ||
root.getProxyUrl = function(url, proxyHostname, proxyPort, jobUid, jobOwnerToken) { | ||
root.convertToProxyUrl = function(url, isIFrame) { | ||
return root.getProxyUrl(url, null, null, null, null, isIFrame); | ||
}; | ||
root.getProxyUrl = function(url, proxyHostname, proxyPort, jobUid, jobOwnerToken, isIFrame) { | ||
if (!isNode) { | ||
@@ -271,2 +274,3 @@ if (!root.isSupportedProtocol(url)) { | ||
} | ||
url = $("<div/>").html(url).text(); | ||
url = root.resolveUrl(url); | ||
@@ -281,3 +285,7 @@ var isCompletedProxyUrl = root.parseProxyUrl(url); | ||
if (parsedUrl.host === location.host && parsedUrl.protocol === location.protocol) { | ||
parsedUrl.query[root.REQUEST_DESCRIPTOR_QUERY_KEY] = [ TCC.ORIGIN_URL_OBJ.protocol, TCC.ORIGIN_URL_OBJ.host, jobUid, jobOwnerToken ].join(root.REQUEST_DESCRIPTOR_VALUES_SEPARATOR); | ||
var query = [ TCC.ORIGIN_URL_OBJ.protocol, TCC.ORIGIN_URL_OBJ.host, jobUid, jobOwnerToken ]; | ||
if (isIFrame) { | ||
query.push(isIFrame); | ||
} | ||
parsedUrl.query[root.REQUEST_DESCRIPTOR_QUERY_KEY] = query.join(root.REQUEST_DESCRIPTOR_VALUES_SEPARATOR); | ||
return root.formatUrl(parsedUrl); | ||
@@ -299,3 +307,7 @@ } | ||
} | ||
originQuery[root.REQUEST_DESCRIPTOR_QUERY_KEY] = [ parsedOriginUrl.protocol, parsedOriginUrl.host, jobUid, jobOwnerToken ].join(root.REQUEST_DESCRIPTOR_VALUES_SEPARATOR); | ||
var query = [ parsedOriginUrl.protocol, parsedOriginUrl.host, jobUid, jobOwnerToken ]; | ||
if (isIFrame) { | ||
query.push(isIFrame); | ||
} | ||
originQuery[root.REQUEST_DESCRIPTOR_QUERY_KEY] = query.join(root.REQUEST_DESCRIPTOR_VALUES_SEPARATOR); | ||
return root.formatUrl({ | ||
@@ -321,3 +333,3 @@ protocol: "http:", | ||
var descriptorValues = descriptor.split(root.REQUEST_DESCRIPTOR_VALUES_SEPARATOR); | ||
var originProtocol = descriptorValues[0], originHost = descriptorValues[1], jobUid = descriptorValues[2], jobOwnerToken = descriptorValues[3]; | ||
var originProtocol = descriptorValues[0], originHost = descriptorValues[1], jobUid = descriptorValues[2], jobOwnerToken = descriptorValues[3], isIFrame = descriptorValues.length > 4 ? descriptorValues[4] : false; | ||
if (!originHost || !originProtocol) { | ||
@@ -348,3 +360,4 @@ return; | ||
ownerToken: jobOwnerToken | ||
} | ||
}, | ||
isIFrame: isIFrame | ||
}; | ||
@@ -351,0 +364,0 @@ }; |
{ | ||
"name": "testcafe", | ||
"description": "Functional testing for the web", | ||
"version": "13.1.1", | ||
"version": "13.1.2", | ||
"dependencies": { | ||
@@ -17,3 +17,4 @@ "async": "0.2.6", | ||
"revalidator": "0.1.5", | ||
"useragent": "2.0.6" | ||
"useragent": "2.0.6", | ||
"webauth": "0.1.0" | ||
}, | ||
@@ -20,0 +21,0 @@ "main": "index", |
@@ -1,5 +0,5 @@ | ||
TestCaf� - functional testing for the web. | ||
TestCafe - functional testing for the web. | ||
Copyright (C) 2011-2013 Developer Express Inc. | ||
Visit TestCaf� online documentation at: | ||
Visit TestCafe online documentation at: | ||
http://testcafe.devexpress.com/Documentation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1674060
66
6482
13
13
6
+ Addedwebauth@0.1.0
+ Addedwebauth@0.1.0(transitive)