Innovenergy_trunk/frontend/node_modules/testcafe/lib/test-run/browser-console-messages.js

75 lines
11 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
const NATIVE_METHODS_PROPERTY_NAME = '_nativeMethods';
class BrowserConsoleMessages {
constructor(data, nativeMethods) {
const resultNativeMethods = this._ensureNativeMethods(nativeMethods);
resultNativeMethods.objectDefineProperty(this, NATIVE_METHODS_PROPERTY_NAME, { value: resultNativeMethods });
this.concat(data);
}
_ensureNativeMethods(nativeMethods) {
return nativeMethods || {
objectKeys: Object.keys,
arrayForEach: Array.prototype.forEach,
arrayConcat: Array.prototype.concat,
arraySlice: Array.prototype.slice,
objectDefineProperty: Object.defineProperty,
};
}
_getWindowIds(consoleMessages) {
return this[NATIVE_METHODS_PROPERTY_NAME].objectKeys(consoleMessages);
}
_copyArray(array) {
return this[NATIVE_METHODS_PROPERTY_NAME].arraySlice.call(array);
}
_concatArrays(array, anotherArray) {
return this[NATIVE_METHODS_PROPERTY_NAME].arrayConcat.call(array, anotherArray);
}
ensureMessageContainer(windowId) {
if (this[windowId])
return;
this[windowId] = {
log: [],
info: [],
warn: [],
error: [],
};
}
concat(consoleMessages) {
if (!consoleMessages)
return this;
const windowIds = this._getWindowIds(consoleMessages);
this[NATIVE_METHODS_PROPERTY_NAME].arrayForEach.call(windowIds, windowId => {
this.ensureMessageContainer(windowId);
this[windowId].log = this._concatArrays(this[windowId].log, consoleMessages[windowId].log);
this[windowId].info = this._concatArrays(this[windowId].info, consoleMessages[windowId].info);
this[windowId].warn = this._concatArrays(this[windowId].warn, consoleMessages[windowId].warn);
this[windowId].error = this._concatArrays(this[windowId].error, consoleMessages[windowId].error);
});
return this;
}
addMessage(type, msg, windowId) {
this.ensureMessageContainer(windowId);
this[windowId][type].push(msg);
}
getCopy() {
const copy = {};
const windowIds = this._getWindowIds(this);
this[NATIVE_METHODS_PROPERTY_NAME].arrayForEach.call(windowIds, windowId => {
copy[windowId] = {
log: this._copyArray(this[windowId].log),
info: this._copyArray(this[windowId].info),
warn: this._copyArray(this[windowId].warn),
error: this._copyArray(this[windowId].error),
};
});
return copy;
}
}
exports.default = BrowserConsoleMessages;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nlci1jb25zb2xlLW1lc3NhZ2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QtcnVuL2Jyb3dzZXItY29uc29sZS1tZXNzYWdlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsZ0VBQWdFO0FBQ2hFLGdFQUFnRTtBQUNoRSwrQ0FBK0M7QUFDL0MsZ0VBQWdFOztBQUVoRSxNQUFNLDRCQUE0QixHQUFHLGdCQUFnQixDQUFDO0FBRXRELE1BQXFCLHNCQUFzQjtJQUN2QyxZQUFhLElBQUksRUFBRSxhQUFhO1FBQzVCLE1BQU0sbUJBQW1CLEdBQUcsSUFBSSxDQUFDLG9CQUFvQixDQUFDLGFBQWEsQ0FBQyxDQUFDO1FBRXJFLG1CQUFtQixDQUFDLG9CQUFvQixDQUFDLElBQUksRUFBRSw0QkFBNEIsRUFBRSxFQUFFLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxDQUFDLENBQUM7UUFFN0csSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUN0QixDQUFDO0lBRUQsb0JBQW9CLENBQUUsYUFBYTtRQUMvQixPQUFPLGFBQWEsSUFBSTtZQUNwQixVQUFVLEVBQVksTUFBTSxDQUFDLElBQUk7WUFDakMsWUFBWSxFQUFVLEtBQUssQ0FBQyxTQUFTLENBQUMsT0FBTztZQUM3QyxXQUFXLEVBQVcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNO1l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