tia
Version:
Time is All (logs driven test engine with ExtJs support)
71 lines • 2.57 kB
JavaScript
;
/* globals gT, gIn */
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
/**
* Initializes TIA ExtJs exploration helpers.
* Loads and runs the e-br-explore.js script in context of current browser window.
*
* Sets default handlers for debug and explorations.
* Ctrl/Meta + Alt + LClick - shows info about ExtJs component under mouse cursor.
* And Ctrl/Meta + Alt + t - shows components hierarchy.
* Removes previous handlers (if they exist).
*
* Sets debug mode for browser JS TIA part.
*
* Sets body clicker to avoid session expiration.
*
* @param {boolean} [enableLog] - is logging needed for this action.
*
* @returns a promise which will be resolved with script return value.
*/
function init(enableLog) {
return (gIn
.wrap({
msg: 'Initialization of TIA ExtJs Exp helpers ... ',
enableLog,
act: () => {
const scriptStr = fs.readFileSync(path.join(gT.tiaDir, 'src', 'api', 'extjs', 'browser-part', 'e-br-explore.js'), 'utf8');
// gIn.tracer.msg3('init: script: ' + scriptStr);
return gT.s.browser.executeScriptWrapper(scriptStr);
},
})
.then(() => {
const scriptStr = `
try {
document.removeEventListener('click', tiaEJOnMouseDown);
document.removeEventListener('keydown', tiaEJOnKeyDown);
} catch(e) {
}
window.tiaEJOnMouseDown = function (e) {
if ((e.ctrlKey || e.metaKey) && e.altKey && e.which === 1) {
e.preventDefault();
e.stopImmediatePropagation();
tiaEJExp.showCompInfoFromPoint(e);
}
};
window.tiaEJOnKeyDown = function (e) {
if ((e.ctrlKey || e.metaKey) && e.altKey && e.keyCode === 84) {
e.preventDefault();
e.stopImmediatePropagation();
tiaEJExp.showCompHierarchy();
}
};
document.addEventListener('click', tiaEJOnMouseDown);
document.addEventListener('keydown', tiaEJOnKeyDown);
`;
return gT.s.browser.executeScriptWrapper(scriptStr);
})
// .then(() => gT.s.browser.setDebugMode())
.then(() => gT.s.browser.setBodyClicker()));
}
exports.init = init;
//# sourceMappingURL=extjs-exploration.js.map