Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testcafe-browser-tools

Package Overview
Dependencies
Maintainers
4
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcafe-browser-tools - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

bin/mac/find-window-cocoa

53

lib/api/close.js

@@ -28,6 +28,6 @@ 'use strict';

* @name close
* @param {string} pageTitle - Specifies the title of the web page opened in the browser.
* @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow.
*/
exports.default = function callee$0$0(pageTitle) {
exports.default = function callee$0$0(windowDescriptor) {
var windowDescription, closeWindowArguments;

@@ -37,10 +37,23 @@ return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {

case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 6;
break;
}
case 2:
windowDescription = context$1$0.sent;
context$1$0.next = 3;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 3:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 7;
break;
case 6:
context$1$0.t0 = windowDescriptor;
case 7:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 5;
context$1$0.next = 10;
break;

@@ -51,7 +64,7 @@ }

case 5:
case 10:
closeWindowArguments = void 0;
if (!_osFamily2.default.win) {
context$1$0.next = 10;
context$1$0.next = 15;
break;

@@ -61,8 +74,8 @@ }

closeWindowArguments = [windowDescription.hwnd];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 10:
case 15:
if (!_osFamily2.default.mac) {
context$1$0.next = 14;
context$1$0.next = 19;
break;

@@ -72,8 +85,8 @@ }

closeWindowArguments = [windowDescription.windowId, windowDescription.bundleId];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 14:
case 19:
if (!_osFamily2.default.linux) {
context$1$0.next = 18;
context$1$0.next = 23;
break;

@@ -83,13 +96,13 @@ }

closeWindowArguments = [windowDescription.windowId];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 18:
case 23:
return context$1$0.abrupt('return');
case 19:
context$1$0.next = 21;
case 24:
context$1$0.next = 26;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.close, closeWindowArguments));
case 21:
case 26:
case 'end':

@@ -96,0 +109,0 @@ return context$1$0.stop();

@@ -21,2 +21,11 @@ 'use strict';

/**
* Retrieves a platform-specific window descriptor for the window that contains a web page with the specified title.
* @function
* @async
* @name findWindow
* @param {string} pageTitle - The title of the web page opened in a window whose descriptor should be retrieved.
* @returns {object} a platform-specific window descriptor that can be used as a window identifier.
**/
exports.default = function callee$0$0(pageTitle) {

@@ -35,11 +44,24 @@ var res, windowParams;

res = context$1$0.sent;
context$1$0.next = 11;
if (!_osFamily2.default.mac) {
context$1$0.next = 10;
break;
}
context$1$0.next = 9;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.findWindowCocoa, [pageTitle]));
case 9:
res += context$1$0.sent;
case 10:
context$1$0.next = 15;
break;
case 8:
context$1$0.prev = 8;
case 12:
context$1$0.prev = 12;
context$1$0.t0 = context$1$0['catch'](2);
return context$1$0.abrupt('return', null);
case 11:
case 15:

@@ -49,3 +71,3 @@ windowParams = res.split(_os.EOL);

if (!_osFamily2.default.win) {
context$1$0.next = 14;
context$1$0.next = 18;
break;

@@ -56,13 +78,13 @@ }

case 14:
case 18:
if (!_osFamily2.default.mac) {
context$1$0.next = 16;
context$1$0.next = 20;
break;
}
return context$1$0.abrupt('return', { bundleId: windowParams[0], windowId: windowParams[1] });
return context$1$0.abrupt('return', { bundleId: windowParams[0], windowId: windowParams[1], cocoaId: windowParams[2] });
case 16:
case 20:
if (!_osFamily2.default.linux) {
context$1$0.next = 18;
context$1$0.next = 22;
break;

@@ -73,9 +95,9 @@ }

case 18:
case 22:
case 'end':
return context$1$0.stop();
}
}, null, this, [[2, 8]]);
}, null, this, [[2, 12]]);
};
module.exports = exports.default;

@@ -7,2 +7,4 @@ 'use strict';

var _Object$assign = require('babel-runtime/core-js/object/assign').default;
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default').default;

@@ -93,9 +95,9 @@

function findWindowsBrowsers() {
var installations, regKey, regKeyEsc, browserRe, stdout, match, name, path, edgeAlias;
return _regeneratorRuntime.async(function findWindowsBrowsers$(context$1$0) {
function searchInRegistry(registryRoot) {
var installations, regKey, regKeyEsc, browserRe, stdout, match, name, path;
return _regeneratorRuntime.async(function searchInRegistry$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
installations = {};
regKey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Clients\\StartMenuInternet\\';
regKey = registryRoot + '\\SOFTWARE\\Clients\\StartMenuInternet\\';
regKeyEsc = regKey.replace(/\\/g, '\\\\');

@@ -127,6 +129,31 @@ browserRe = new RegExp(regKeyEsc + '([^\\\\]+)\\\\shell\\\\open\\\\command' + '\\s+\\([^)]+\\)\\s+reg_sz\\s+([^\n]+)\n', 'gi');

case 16:
context$1$0.next = 18;
return context$1$0.abrupt('return', installations);
case 17:
case 'end':
return context$1$0.stop();
}
}, null, this);
}
function findWindowsBrowsers() {
var machineRegisteredBrowsers, userRegisteredBrowsers, installations, edgeAlias;
return _regeneratorRuntime.async(function findWindowsBrowsers$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(searchInRegistry('HKEY_LOCAL_MACHINE'));
case 2:
machineRegisteredBrowsers = context$1$0.sent;
context$1$0.next = 5;
return _regeneratorRuntime.awrap(searchInRegistry('HKEY_CURRENT_USER'));
case 5:
userRegisteredBrowsers = context$1$0.sent;
installations = _Object$assign(machineRegisteredBrowsers, userRegisteredBrowsers);
context$1$0.next = 9;
return _regeneratorRuntime.awrap(detectMicrosoftEdge());
case 18:
case 9:
edgeAlias = context$1$0.sent;

@@ -138,3 +165,3 @@

case 21:
case 12:
case 'end':

@@ -141,0 +168,0 @@ return context$1$0.stop();

@@ -30,7 +30,7 @@ 'use strict';

* @name isMaximized
* @param {string} pageTitle - The title of the web page opened in the window to check if this window is maximized.
* @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow.
* @return {boolean} `true` if the browser window is maximized
**/
exports.default = function callee$0$0(pageTitle) {
exports.default = function callee$0$0(windowDescriptor) {
var windowDescription, commandArguments, result;

@@ -40,10 +40,23 @@ return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {

case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 6;
break;
}
case 2:
windowDescription = context$1$0.sent;
context$1$0.next = 3;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 3:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 7;
break;
case 6:
context$1$0.t0 = windowDescriptor;
case 7:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 5;
context$1$0.next = 10;
break;

@@ -54,7 +67,7 @@ }

case 5:
case 10:
commandArguments = void 0;
if (!_osFamily2.default.win) {
context$1$0.next = 10;
context$1$0.next = 15;
break;

@@ -64,17 +77,17 @@ }

commandArguments = [windowDescription.hwnd];
context$1$0.next = 11;
context$1$0.next = 16;
break;
case 10:
case 15:
return context$1$0.abrupt('return', false);
case 11:
context$1$0.next = 13;
case 16:
context$1$0.next = 18;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.maximize, commandArguments.concat('status')));
case 13:
case 18:
result = context$1$0.sent;
return context$1$0.abrupt('return', result.replace(_os.EOL, '').toLowerCase() === 'true');
case 15:
case 20:
case 'end':

@@ -81,0 +94,0 @@ return context$1$0.stop();

@@ -96,6 +96,6 @@ 'use strict';

* @name maximize
* @param {string} pageTitle - The title of the web page opened in the window that should be maximized.
* @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow.
**/
exports.default = function callee$0$0(pageTitle) {
exports.default = function callee$0$0(windowDescriptor) {
var windowDescription, commandArguments;

@@ -105,10 +105,23 @@ return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {

case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 6;
break;
}
case 2:
windowDescription = context$1$0.sent;
context$1$0.next = 3;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 3:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 7;
break;
case 6:
context$1$0.t0 = windowDescriptor;
case 7:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 5;
context$1$0.next = 10;
break;

@@ -119,7 +132,7 @@ }

case 5:
case 10:
commandArguments = void 0;
if (!_osFamily2.default.win) {
context$1$0.next = 10;
context$1$0.next = 15;
break;

@@ -129,8 +142,8 @@ }

commandArguments = [windowDescription.hwnd];
context$1$0.next = 21;
context$1$0.next = 26;
break;
case 10:
case 15:
if (!_osFamily2.default.linux) {
context$1$0.next = 14;
context$1$0.next = 19;
break;

@@ -140,25 +153,25 @@ }

commandArguments = [windowDescription.windowId];
context$1$0.next = 21;
context$1$0.next = 26;
break;
case 14:
case 19:
if (!_osFamily2.default.mac) {
context$1$0.next = 20;
context$1$0.next = 25;
break;
}
context$1$0.next = 17;
context$1$0.next = 22;
return _regeneratorRuntime.awrap(maximizeWindowMac(windowDescription));
case 17:
case 22:
return context$1$0.abrupt('return');
case 20:
case 25:
return context$1$0.abrupt('return');
case 21:
context$1$0.next = 23;
case 26:
context$1$0.next = 28;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.maximize, commandArguments));
case 23:
case 28:
case 'end':

@@ -165,0 +178,0 @@ return context$1$0.stop();

@@ -42,3 +42,3 @@ 'use strict';

* @name resize
* @param {string} pageTitle - Specifies the title of the web page opened in the browser.
* @param {string | object} windowDescriptor - Specifies the title of the web page opened in the window or a descriptor returned by findWindow.
* @param {number} currentWidth - Specifies the current width of the browser's client area, in pixels. Use the window.innerWidth property to determine it.

@@ -50,3 +50,3 @@ * @param {number} currentHeight - Specifies the current height of the browser's client area, in pixels. Use the window.innerHeight property to determine it.

exports.default = function callee$0$0(pageTitle, currentWidth, currentHeight, width, height) {
exports.default = function callee$0$0(windowDescriptor, currentWidth, currentHeight, width, height) {
var windowDescription, resizeArguments, currentClientAreaSize, requestedSize, currentWindowSize, correctedSize;

@@ -56,10 +56,23 @@ return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {

case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 6;
break;
}
case 2:
windowDescription = context$1$0.sent;
context$1$0.next = 3;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 3:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 7;
break;
case 6:
context$1$0.t0 = windowDescriptor;
case 7:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 5;
context$1$0.next = 10;
break;

@@ -70,7 +83,7 @@ }

case 5:
case 10:
resizeArguments = void 0;
if (!_osFamily2.default.win) {
context$1$0.next = 10;
context$1$0.next = 15;
break;

@@ -80,8 +93,8 @@ }

resizeArguments = [windowDescription.hwnd];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 10:
case 15:
if (!_osFamily2.default.mac) {
context$1$0.next = 14;
context$1$0.next = 19;
break;

@@ -91,8 +104,8 @@ }

resizeArguments = [windowDescription.windowId, windowDescription.bundleId];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 14:
case 19:
if (!_osFamily2.default.linux) {
context$1$0.next = 18;
context$1$0.next = 23;
break;

@@ -102,19 +115,19 @@ }

resizeArguments = [windowDescription.windowId];
context$1$0.next = 19;
context$1$0.next = 24;
break;
case 18:
case 23:
return context$1$0.abrupt('return');
case 19:
case 24:
currentClientAreaSize = { width: currentWidth, height: currentHeight };
requestedSize = { width: width, height: height };
context$1$0.next = 23;
context$1$0.next = 28;
return _regeneratorRuntime.awrap(_getWindowSize2.default(windowDescription));
case 23:
case 28:
currentWindowSize = context$1$0.sent;
if (currentWindowSize) {
context$1$0.next = 26;
context$1$0.next = 31;
break;

@@ -125,3 +138,3 @@ }

case 26:
case 31:
correctedSize = getCorrectedSize(currentClientAreaSize, currentWindowSize, requestedSize);

@@ -131,6 +144,6 @@

context$1$0.next = 30;
context$1$0.next = 35;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.resize, resizeArguments));
case 30:
case 35:
case 'end':

@@ -137,0 +150,0 @@ return context$1$0.stop();

@@ -32,8 +32,8 @@ 'use strict';

* @name screenshot
* @param {string} pageTitle - Specifies the title of the web page opened in the browser.
* @param {string | object} windowDescriptor - Specifies the title of the web page opened in the window or a descriptor returned by findWindow.
* @param {string} screenshotPath - Specifies the full path to the screenshot file. For example, D:\Temp\chrome-screenshot.jpg.
*/
exports.default = function callee$0$0(pageTitle, screenshotPath) {
var windowDescription, windowParams;
exports.default = function callee$0$0(windowDescriptor, screenshotPath) {
var windowDescription, screenshotArguments;
return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {

@@ -50,17 +50,23 @@ while (1) switch (context$1$0.prev = context$1$0.next) {

case 2:
windowDescription = void 0;
if (!(_osFamily2.default.win || _osFamily2.default.linux)) {
context$1$0.next = 12;
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 8;
break;
}
context$1$0.next = 6;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
context$1$0.next = 5;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 6:
windowParams = context$1$0.sent;
case 5:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 9;
break;
if (windowParams) {
context$1$0.next = 9;
case 8:
context$1$0.t0 = windowDescriptor;
case 9:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 12;
break;

@@ -71,26 +77,11 @@ }

case 9:
case 12:
screenshotArguments = void 0;
if (_osFamily2.default.win) windowDescription = [windowParams.hwnd, windowParams.browser];else windowDescription = [windowParams.windowId];
context$1$0.next = 17;
break;
if (_osFamily2.default.win) screenshotArguments = [windowDescription.hwnd, windowDescription.browser];else if (_osFamily2.default.mac) screenshotArguments = [windowDescription.cocoaId];else screenshotArguments = [windowDescription.windowId];
case 12:
if (!_osFamily2.default.mac) {
context$1$0.next = 16;
break;
}
context$1$0.next = 16;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.screenshot, screenshotArguments.concat(screenshotPath)));
windowDescription = [pageTitle];
context$1$0.next = 17;
break;
case 16:
return context$1$0.abrupt('return');
case 17:
context$1$0.next = 19;
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.screenshot, windowDescription.concat(screenshotPath)));
case 19:
case 'end':

@@ -97,0 +88,0 @@ return context$1$0.stop();

@@ -27,3 +27,3 @@ 'use strict';

* @name watchWindow
* @param {string} pageTitle - The title of the web page opened in the window that should be watched.
* @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow
* @param {number} [watchingInterval=2000] - A time interval in milliseconds between checking the window state

@@ -33,3 +33,3 @@ * @returns Promise<undefined> A Promise which resolves when the browser window is closed.

exports.default = function callee$0$0(pageTitle) {
exports.default = function callee$0$0(windowDescriptor) {
var watchingInterval = arguments.length <= 1 || arguments[1] === undefined ? DEFAULT_WATCHING_INTERVAL : arguments[1];

@@ -40,10 +40,23 @@ var windowDescription, windowSize;

case 0:
context$1$0.next = 2;
return _regeneratorRuntime.awrap(_findWindow2.default(pageTitle));
if (!(typeof windowDescriptor === 'string')) {
context$1$0.next = 6;
break;
}
case 2:
windowDescription = context$1$0.sent;
context$1$0.next = 3;
return _regeneratorRuntime.awrap(_findWindow2.default(windowDescriptor));
case 3:
context$1$0.t0 = context$1$0.sent;
context$1$0.next = 7;
break;
case 6:
context$1$0.t0 = windowDescriptor;
case 7:
windowDescription = context$1$0.t0;
if (windowDescription) {
context$1$0.next = 5;
context$1$0.next = 10;
break;

@@ -54,28 +67,28 @@ }

case 5:
context$1$0.next = 7;
case 10:
context$1$0.next = 12;
return _regeneratorRuntime.awrap(_getWindowSize2.default(windowDescription));
case 7:
case 12:
windowSize = context$1$0.sent;
case 8:
case 13:
if (!(windowSize && windowSize.width && windowSize.height)) {
context$1$0.next = 16;
context$1$0.next = 21;
break;
}
context$1$0.next = 11;
context$1$0.next = 16;
return _regeneratorRuntime.awrap(_utilsDelay2.default(watchingInterval));
case 11:
context$1$0.next = 13;
case 16:
context$1$0.next = 18;
return _regeneratorRuntime.awrap(_getWindowSize2.default(windowDescription));
case 13:
case 18:
windowSize = context$1$0.sent;
context$1$0.next = 8;
context$1$0.next = 13;
break;
case 16:
case 21:
case 'end':

@@ -82,0 +95,0 @@ return context$1$0.stop();

@@ -31,2 +31,3 @@ 'use strict';

findWindow: _readFileRelative.toAbsPath('../bin/mac/find-window.scpt'),
findWindowCocoa: _readFileRelative.toAbsPath('../bin/mac/find-window-cocoa'),
getWindowSize: _readFileRelative.toAbsPath('../bin/mac/get-window-size.scpt'),

@@ -33,0 +34,0 @@ getWindowBounds: _readFileRelative.toAbsPath('../bin/mac/get-window-bounds.scpt'),

{
"name": "testcafe-browser-tools",
"version": "1.3.1",
"version": "1.4.0",
"description": "An utility library for performing platform-dependent actions on browsers.",

@@ -45,3 +45,3 @@ "homepage": "https://github.com/DevExpress/testcafe-browser-tools",

"gulp-mocha": "^2.1.3",
"gulp-msbuild": "^0.2.12",
"gulp-msbuild": "^0.5.2",
"gulp-remote-src": "^0.4.1",

@@ -48,0 +48,0 @@ "hogan-express": "^0.5.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc